From 2a8df0ab0a2710f670aa9e1a86edf0d223af0dc0 Mon Sep 17 00:00:00 2001 From: "Romain B." <8530352+Rom1-B@users.noreply.github.com> Date: Mon, 9 Sep 2024 08:28:31 +0200 Subject: [PATCH] Feat: php-cs-fixer (#154) * Feat: php-cs-fixer * fix rules * clean config * clean rules * trailing_comma_in_multiline * Revert "trailing_comma_in_multiline" This reverts commit e6acf111babcdd04232d7300d9f3c2ecf9e47ccc. * php 7.4 compatiblity * remove php_codesniffer --- .php-cs-fixer.php | 20 + ajax/display_alerts.php | 4 +- ajax/hide_alert.php | 4 +- ajax/targets.php | 26 +- composer.json | 4 +- composer.lock | 2108 ++++++++++++++++++++++++++++++++---- front/alert.form.php | 60 +- front/alert.php | 6 +- front/external.php | 2 +- front/hidden_alerts.php | 12 +- hook.php | 181 ++-- inc/alert.class.php | 450 ++++---- inc/alert_target.class.php | 73 +- inc/alert_user.class.php | 24 +- inc/profile.class.php | 8 +- setup.php | 34 +- 16 files changed, 2360 insertions(+), 656 deletions(-) create mode 100644 .php-cs-fixer.php diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..5fd203d --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,20 @@ +in(__DIR__) + ->name('*.php'); + +$config = new Config(); + +$rules = [ + '@PER-CS2.0' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arguments', 'array_destructuring', 'arrays']], // For PHP 7.4 compatibility +]; + +return $config + ->setRules($rules) + ->setFinder($finder) + ->setUsingCache(false); diff --git a/ajax/display_alerts.php b/ajax/display_alerts.php index 4a31d01..264b712 100644 --- a/ajax/display_alerts.php +++ b/ajax/display_alerts.php @@ -29,8 +29,8 @@ */ $AJAX_INCLUDE = 1; -include("../../../inc/includes.php"); -header("Content-Type: text/html; charset=UTF-8"); +include('../../../inc/includes.php'); +header('Content-Type: text/html; charset=UTF-8'); Html::header_nocache(); Session::checkLoginUser(); diff --git a/ajax/hide_alert.php b/ajax/hide_alert.php index ce63902..763b51c 100644 --- a/ajax/hide_alert.php +++ b/ajax/hide_alert.php @@ -29,8 +29,8 @@ */ $AJAX_INCLUDE = 1; -include("../../../inc/includes.php"); -header("Content-Type: text/html; charset=UTF-8"); +include('../../../inc/includes.php'); +header('Content-Type: text/html; charset=UTF-8'); Html::header_nocache(); Session::checkLoginUser(); diff --git a/ajax/targets.php b/ajax/targets.php index 8434dd2..0ee6c9b 100644 --- a/ajax/targets.php +++ b/ajax/targets.php @@ -29,22 +29,22 @@ */ $AJAX_INCLUDE = 1; -include("../../../inc/includes.php"); -header("Content-Type: text/html; charset=UTF-8"); +include('../../../inc/includes.php'); +header('Content-Type: text/html; charset=UTF-8'); Html::header_nocache(); Session::checkLoginUser(); if (isset($_POST['type']) && !empty($_POST['type'])) { echo ""; - echo ""; - echo "'; + echo '"; + echo ''; echo ""; - echo ""; - echo "
"; + echo '
'; switch ($_POST['type']) { case 'User': - User::dropdown(['name' => 'items_id', - 'right' => 'all', - 'entity' => $_POST['entities_id'], - 'entity_sons' => $_POST['is_recursive'], + User::dropdown(['name' => 'items_id', + 'right' => 'all', + 'entity' => $_POST['entities_id'], + 'entity_sons' => $_POST['is_recursive'], ]); break; @@ -53,14 +53,14 @@ break; case 'Profile': - Profile::dropdown(['name' => 'items_id', - 'toadd' => [-1 => __('All', 'news')] + Profile::dropdown(['name' => 'items_id', + 'toadd' => [-1 => __('All', 'news')], ]); break; } - echo "
"; + echo ''; + echo ''; } diff --git a/composer.json b/composer.json index 4bcb85b..60c63f1 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,10 @@ "php": ">=7.4" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.64", "glpi-project/tools": "^0.7.3", "php-parallel-lint/php-parallel-lint": "^1.4", - "phpstan/phpstan": "^1.12", - "squizlabs/php_codesniffer": "^3.10" + "phpstan/phpstan": "^1.12" }, "config": { "optimize-autoloader": true, diff --git a/composer.lock b/composer.lock index 42d655e..dd41d55 100644 --- a/composer.lock +++ b/composer.lock @@ -4,205 +4,323 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "74ed2cdb044b2436e95cc0760aeaedd2", + "content-hash": "be120f9e866d137931dc59d253a306ae", "packages": [], "packages-dev": [ { - "name": "glpi-project/tools", - "version": "0.7.3", + "name": "clue/ndjson-react", + "version": "v1.3.0", "source": { "type": "git", - "url": "https://github.com/glpi-project/tools.git", - "reference": "a076482b057a727a9dcf155af40dac6c26a7b7c6" + "url": "https://github.com/clue/reactphp-ndjson.git", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/a076482b057a727a9dcf155af40dac6c26a7b7c6", - "reference": "a076482b057a727a9dcf155af40dac6c26a7b7c6", + "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", "shasum": "" }, "require": { - "symfony/console": "^5.4 || ^6.0", - "twig/twig": "^3.3" + "php": ">=5.3", + "react/stream": "^1.2" }, "require-dev": { - "nikic/php-parser": "^4.13", - "phpstan/phpstan-src": "^1.10" + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.2" }, - "bin": [ - "bin/extract-locales", - "bin/licence-headers-check", - "tools/plugin-release" - ], "type": "library", "autoload": { "psr-4": { - "GlpiProject\\Tools\\": "src/" + "Clue\\React\\NDJson\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "GPL-3.0-or-later" + "MIT" ], "authors": [ { - "name": "Teclib'", - "email": "glpi@teclib.com", - "homepage": "http://teclib-group.com" + "name": "Christian Lück", + "email": "christian@clue.engineering" } ], - "description": "Various tools for GLPI and its plugins", + "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", + "homepage": "https://github.com/clue/reactphp-ndjson", "keywords": [ - "glpi", - "plugins", - "tools" + "NDJSON", + "json", + "jsonlines", + "newline", + "reactphp", + "streaming" ], "support": { - "issues": "https://github.com/glpi-project/tools/issues", - "source": "https://github.com/glpi-project/tools" + "issues": "https://github.com/clue/reactphp-ndjson/issues", + "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" }, - "time": "2024-06-20T08:36:22+00:00" + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-12-23T10:58:28+00:00" }, { - "name": "php-parallel-lint/php-parallel-lint", - "version": "v1.4.0", + "name": "composer/pcre", + "version": "3.3.1", "source": { "type": "git", - "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "6db563514f27e19595a19f45a4bf757b6401194e" + "url": "https://github.com/composer/pcre.git", + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", - "reference": "6db563514f27e19595a19f45a4bf757b6401194e", + "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", "shasum": "" }, "require": { - "ext-json": "*", - "php": ">=5.3.0" + "php": "^7.4 || ^8.0" }, - "replace": { - "grogy/php-parallel-lint": "*", - "jakub-onderka/php-parallel-lint": "*" + "conflict": { + "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "nette/tester": "^1.3 || ^2.0", - "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", - "squizlabs/php_codesniffer": "^3.6" + "phpstan/phpstan": "^1.11.10", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8 || ^9" }, - "suggest": { - "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } }, - "bin": [ - "parallel-lint" + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.1" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } ], + "time": "2024-08-27T18:44:43+00:00" + }, + { + "name": "composer/semver", + "version": "3.4.2", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "c51258e759afdb17f1fd1fe83bc12baaef6309d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/c51258e759afdb17f1fd1fe83bc12baaef6309d6", + "reference": "c51258e759afdb17f1fd1fe83bc12baaef6309d6", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, "autoload": { - "classmap": [ - "./src/" - ] + "psr-4": { + "Composer\\Semver\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-2-Clause" + "MIT" ], "authors": [ { - "name": "Jakub Onderka", - "email": "ahoj@jakubonderka.cz" + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" } ], - "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", - "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "description": "Semver library that offers utilities, version constraint parsing and validation.", "keywords": [ - "lint", - "static analysis" + "semantic", + "semver", + "validation", + "versioning" ], "support": { - "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", - "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.2" }, - "time": "2024-03-27T12:14:49+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-07-12T11:35:52+00:00" }, { - "name": "phpstan/phpstan", - "version": "1.12.0", + "name": "composer/xdebug-handler", + "version": "3.0.5", "source": { "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "384af967d35b2162f69526c7276acadce534d0e1" + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/384af967d35b2162f69526c7276acadce534d0e1", - "reference": "384af967d35b2162f69526c7276acadce534d0e1", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" }, - "conflict": { - "phpstan/phpstan-shim": "*" + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" }, - "bin": [ - "phpstan", - "phpstan.phar" - ], "type": "library", "autoload": { - "files": [ - "bootstrap.php" - ] + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "PHPStan - PHP Static Analysis Tool", + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", "keywords": [ - "dev", - "static analysis" + "Xdebug", + "performance" ], "support": { - "docs": "https://phpstan.org/user-guide/getting-started", - "forum": "https://github.com/phpstan/phpstan/discussions", - "issues": "https://github.com/phpstan/phpstan/issues", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" }, "funding": [ { - "url": "https://github.com/ondrejmirtes", - "type": "github" + "url": "https://packagist.com", + "type": "custom" }, { - "url": "https://github.com/phpstan", + "url": "https://github.com/composer", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" } ], - "time": "2024-08-27T09:18:05+00:00" + "time": "2024-05-06T16:37:16+00:00" }, { - "name": "psr/container", - "version": "1.1.2", + "name": "evenement/evenement", + "version": "v3.0.2", "source": { "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "url": "https://github.com/igorw/evenement.git", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", "shasum": "" }, "require": { - "php": ">=7.4.0" + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^6" }, "type": "library", "autoload": { "psr-4": { - "Psr\\Container\\": "src/" + "Evenement\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -211,158 +329,1524 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" } ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", + "description": "Événement is a very simple event dispatching library for PHP", "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" + "event-dispatcher", + "event-emitter" ], "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/v3.0.2" }, - "time": "2021-11-05T16:50:12+00:00" + "time": "2023-08-08T05:53:35+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.10.2", + "name": "fidry/cpu-core-counter", + "version": "1.2.0", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017" + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "8520451a140d3f46ac33042715115e290cf5785f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/86e5f5dd9a840c46810ebe5ff1885581c42a3017", - "reference": "86e5f5dd9a840c46810ebe5ff1885581c42a3017", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f", + "reference": "8520451a140d3f46ac33042715115e290cf5785f", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" + "php": "^7.2 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + "fidry/makefile": "^0.2.0", + "fidry/php-cs-fixer-config": "^1.1.2", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^1.9.2", + "phpstan/phpstan-deprecation-rules": "^1.0.0", + "phpstan/phpstan-phpunit": "^1.2.2", + "phpstan/phpstan-strict-rules": "^1.4.4", + "phpunit/phpunit": "^8.5.31 || ^9.5.26", + "webmozarts/strict-phpunit": "^7.5" }, - "bin": [ - "bin/phpcbf", - "bin/phpcs" - ], "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Greg Sherwood", - "role": "Former lead" + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2024-08-06T10:04:20+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.64.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "58dd9c931c785a79739310aef5178928305ffa67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/58dd9c931c785a79739310aef5178928305ffa67", + "reference": "58dd9c931c785a79739310aef5178928305ffa67", + "shasum": "" + }, + "require": { + "clue/ndjson-react": "^1.0", + "composer/semver": "^3.4", + "composer/xdebug-handler": "^3.0.3", + "ext-filter": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "fidry/cpu-core-counter": "^1.0", + "php": "^7.4 || ^8.0", + "react/child-process": "^0.6.5", + "react/event-loop": "^1.0", + "react/promise": "^2.0 || ^3.0", + "react/socket": "^1.0", + "react/stream": "^1.0", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", + "symfony/polyfill-mbstring": "^1.28", + "symfony/polyfill-php80": "^1.28", + "symfony/polyfill-php81": "^1.28", + "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" + }, + "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.3", + "infection/infection": "^0.29.5", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.1", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.7", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5", + "phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2", + "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" }, + "exclude-from-classmap": [ + "src/Fixer/Internal/*" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ { - "name": "Juliette Reinders Folmer", - "role": "Current lead" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "description": "A tool to automatically fix PHP code style", "keywords": [ - "phpcs", + "Static code analysis", + "fixer", "standards", "static analysis" ], "support": { - "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", - "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", - "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", - "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.64.0" }, "funding": [ { - "url": "https://github.com/PHPCSStandards", + "url": "https://github.com/keradus", "type": "github" + } + ], + "time": "2024-08-30T23:09:38+00:00" + }, + { + "name": "glpi-project/tools", + "version": "0.7.3", + "source": { + "type": "git", + "url": "https://github.com/glpi-project/tools.git", + "reference": "a076482b057a727a9dcf155af40dac6c26a7b7c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/a076482b057a727a9dcf155af40dac6c26a7b7c6", + "reference": "a076482b057a727a9dcf155af40dac6c26a7b7c6", + "shasum": "" + }, + "require": { + "symfony/console": "^5.4 || ^6.0", + "twig/twig": "^3.3" + }, + "require-dev": { + "nikic/php-parser": "^4.13", + "phpstan/phpstan-src": "^1.10" + }, + "bin": [ + "bin/extract-locales", + "bin/licence-headers-check", + "tools/plugin-release" + ], + "type": "library", + "autoload": { + "psr-4": { + "GlpiProject\\Tools\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-3.0-or-later" + ], + "authors": [ + { + "name": "Teclib'", + "email": "glpi@teclib.com", + "homepage": "http://teclib-group.com" + } + ], + "description": "Various tools for GLPI and its plugins", + "keywords": [ + "glpi", + "plugins", + "tools" + ], + "support": { + "issues": "https://github.com/glpi-project/tools/issues", + "source": "https://github.com/glpi-project/tools" + }, + "time": "2024-06-20T08:36:22+00:00" + }, + { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/6db563514f27e19595a19f45a4bf757b6401194e", + "reference": "6db563514f27e19595a19f45a4bf757b6401194e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.3.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", + "squizlabs/php_codesniffer": "^3.6" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool checks the syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "keywords": [ + "lint", + "static analysis" + ], + "support": { + "issues": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/issues", + "source": "https://github.com/php-parallel-lint/PHP-Parallel-Lint/tree/v1.4.0" + }, + "time": "2024-03-27T12:14:49+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "384af967d35b2162f69526c7276acadce534d0e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/384af967d35b2162f69526c7276acadce534d0e1", + "reference": "384af967d35b2162f69526c7276acadce534d0e1", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-08-27T09:18:05+00:00" + }, + { + "name": "psr/container", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", + "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.2" + }, + "time": "2021-11-05T16:50:12+00:00" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "react/cache", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2022-11-30T15:59:55+00:00" + }, + { + "name": "react/child-process", + "version": "v0.6.5", + "source": { + "type": "git", + "url": "https://github.com/reactphp/child-process.git", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/event-loop": "^1.2", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/socket": "^1.8", + "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\ChildProcess\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven library for executing child processes with ReactPHP.", + "keywords": [ + "event-driven", + "process", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/child-process/issues", + "source": "https://github.com/reactphp/child-process/tree/v0.6.5" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-09-16T13:41:56+00:00" + }, + { + "name": "react/dns", + "version": "v1.13.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.7 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4.3 || ^3 || ^2", + "react/promise-timer": "^1.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.13.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-06-13T14:18:03+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "suggest": { + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.5.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-13T13:48:05+00:00" + }, + { + "name": "react/promise", + "version": "v3.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpstan/phpstan": "1.10.39 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v3.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-05-24T10:39:05+00:00" + }, + { + "name": "react/socket", + "version": "v1.16.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", + "reference": "23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.13", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.6 || ^1.2.1", + "react/stream": "^1.4" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4.3 || ^3.3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.16.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-07-26T10:38:09+00:00" + }, + { + "name": "react/stream", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.4.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-06-11T12:45:25+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "symfony/console", + "version": "v5.4.41", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "6473d441a913cb997123b59ff2dbe3d1cf9e11ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/6473d441a913cb997123b59ff2dbe3d1cf9e11ba", + "reference": "6473d441a913cb997123b59ff2dbe3d1cf9e11ba", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.1|^6.0" + }, + "conflict": { + "psr/log": ">=3", + "symfony/dependency-injection": "<4.4", + "symfony/dotenv": "<5.1", + "symfony/event-dispatcher": "<4.4", + "symfony/lock": "<4.4", + "symfony/process": "<4.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0" + }, + "require-dev": { + "psr/log": "^1|^2", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/lock": "^4.4|^5.0|^6.0", + "symfony/process": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command-line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v5.4.41" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-06-28T07:48:55+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-24T14:02:46+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "a54e2a8a114065f31020d6a89ede83e34c3b27a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a54e2a8a114065f31020d6a89ede83e34c3b27a4", + "reference": "a54e2a8a114065f31020d6a89ede83e34c3b27a4", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/event-dispatcher-contracts": "^2|^3", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.5.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/540f4c73e87fd0c71ca44a6aa305d024ac68cb73", + "reference": "540f4c73e87fd0c71ca44a6aa305d024ac68cb73", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T13:51:25+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.4.41", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "6d29dd9340b372fa603f04e6df4dd76bb808591e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/6d29dd9340b372fa603f04e6df4dd76bb808591e", + "reference": "6d29dd9340b372fa603f04e6df4dd76bb808591e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/process": "^5.4|^6.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v5.4.41" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" }, { - "url": "https://github.com/jrfnl", + "url": "https://github.com/fabpot", "type": "github" }, { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } ], - "time": "2024-07-21T23:26:44+00:00" + "time": "2024-06-28T09:36:24+00:00" }, { - "name": "symfony/console", - "version": "v5.4.41", + "name": "symfony/finder", + "version": "v5.4.43", "source": { "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "6473d441a913cb997123b59ff2dbe3d1cf9e11ba" + "url": "https://github.com/symfony/finder.git", + "reference": "ae25a9145a900764158d439653d5630191155ca0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/6473d441a913cb997123b59ff2dbe3d1cf9e11ba", - "reference": "6473d441a913cb997123b59ff2dbe3d1cf9e11ba", + "url": "https://api.github.com/repos/symfony/finder/zipball/ae25a9145a900764158d439653d5630191155ca0", + "reference": "ae25a9145a900764158d439653d5630191155ca0", "shasum": "" }, "require": { "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.9", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/string": "^5.1|^6.0" - }, - "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" - }, - "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/event-dispatcher": "^4.4|^5.0|^6.0", - "symfony/lock": "^4.4|^5.0|^6.0", - "symfony/process": "^4.4|^5.0|^6.0", - "symfony/var-dumper": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" + "symfony/polyfill-php80": "^1.16" }, "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\Console\\": "" + "Symfony\\Component\\Finder\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -382,16 +1866,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Eases the creation of beautiful and testable command line interfaces", + "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", - "keywords": [ - "cli", - "command-line", - "console", - "terminal" - ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.41" + "source": "https://github.com/symfony/finder/tree/v5.4.43" }, "funding": [ { @@ -407,38 +1885,35 @@ "type": "tidelift" } ], - "time": "2024-06-28T07:48:55+00:00" + "time": "2024-08-13T14:03:51+00:00" }, { - "name": "symfony/deprecation-contracts", - "version": "v2.5.3", + "name": "symfony/options-resolver", + "version": "v5.4.40", "source": { "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d" + "url": "https://github.com/symfony/options-resolver.git", + "reference": "bd1afbde6613a8d6b956115e0e14b196191fd0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/bd1afbde6613a8d6b956115e0e14b196191fd0c4", + "reference": "bd1afbde6613a8d6b956115e0e14b196191fd0c4", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php73": "~1.0", + "symfony/polyfill-php80": "^1.16" }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, "autoload": { - "files": [ - "function.php" + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -447,18 +1922,23 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "A generic function and convention to trigger deprecation notices", + "description": "Provides an improved replacement for the array_replace PHP function", "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" + "source": "https://github.com/symfony/options-resolver/tree/v5.4.40" }, "funding": [ { @@ -474,7 +1954,7 @@ "type": "tidelift" } ], - "time": "2023-01-24T14:02:46+00:00" + "time": "2024-05-31T14:33:22+00:00" }, { "name": "symfony/polyfill-ctype", @@ -950,6 +2430,144 @@ ], "time": "2024-05-31T15:07:36+00:00" }, + { + "name": "symfony/polyfill-php81", + "version": "v1.30.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af", + "reference": "3fb075789fb91f9ad9af537c4012d523085bd5af", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.30.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-06-19T12:30:46+00:00" + }, + { + "name": "symfony/process", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/deedcb3bb4669cae2148bc920eafd2b16dc7c046", + "reference": "deedcb3bb4669cae2148bc920eafd2b16dc7c046", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, { "name": "symfony/service-contracts", "version": "v2.5.3", @@ -1033,6 +2651,68 @@ ], "time": "2023-04-21T15:04:16+00:00" }, + { + "name": "symfony/stopwatch", + "version": "v5.4.40", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/0e9daf3b7c805c747638b2cc48f1649e594f9625", + "reference": "0e9daf3b7c805c747638b2cc48f1649e594f9625", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/service-contracts": "^1|^2|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v5.4.40" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T14:33:22+00:00" + }, { "name": "symfony/string", "version": "v5.4.41", diff --git a/front/alert.form.php b/front/alert.form.php index 20eec7b..d96ffe3 100644 --- a/front/alert.form.php +++ b/front/alert.form.php @@ -30,10 +30,10 @@ use Glpi\Event; -include("../../../inc/includes.php"); +include('../../../inc/includes.php'); -if (!isset($_GET["id"])) { - $_GET["id"] = ""; +if (!isset($_GET['id'])) { + $_GET['id'] = ''; } $alert = new PluginNewsAlert(); @@ -42,23 +42,23 @@ $alert->check($_POST['id'], UPDATE); if ($alert->update($_POST)) { Event::log( - $_POST["id"], - "PluginNewsAlert", + $_POST['id'], + 'PluginNewsAlert', 4, - "admin", - sprintf(__('%s updates an item', 'news'), $_SESSION["glpiname"]) + 'admin', + sprintf(__('%s updates an item', 'news'), $_SESSION['glpiname']), ); } Html::back(); -} else if (isset($_POST['add'])) { +} elseif (isset($_POST['add'])) { $alert->check(-1, CREATE, $_POST); if ($newID = $alert->add($_POST)) { Event::log( $newID, - "PluginNewsAlert", + 'PluginNewsAlert', 4, - "admin", - sprintf(__('%1$s adds the item %2$s', 'news'), $_SESSION["glpiname"], $_POST["name"]) + 'admin', + sprintf(__('%1$s adds the item %2$s', 'news'), $_SESSION['glpiname'], $_POST['name']), ); if ($_SESSION['glpibackcreated']) { @@ -66,43 +66,43 @@ } } Html::back(); -} else if (isset($_POST['delete'])) { +} elseif (isset($_POST['delete'])) { $alert->check($_POST['id'], DELETE); if ($alert->delete($_POST)) { Event::log( - $_POST["id"], - "PluginNewsAlert", + $_POST['id'], + 'PluginNewsAlert', 4, - "admin", - sprintf(__('%s deletes an item', 'news'), $_SESSION["glpiname"]) + 'admin', + sprintf(__('%s deletes an item', 'news'), $_SESSION['glpiname']), ); } $alert->redirectToList(); -} else if (isset($_POST['restore'])) { +} elseif (isset($_POST['restore'])) { $alert->check($_POST['id'], DELETE); if ($alert->restore($_POST)) { Event::log( - $_POST["id"], - "PluginNewsAlert", + $_POST['id'], + 'PluginNewsAlert', 4, - "admin", - sprintf(__('%s restores an item', 'news'), $_SESSION["glpiname"]) + 'admin', + sprintf(__('%s restores an item', 'news'), $_SESSION['glpiname']), ); } Html::back(); -} else if (isset($_POST['purge'])) { +} elseif (isset($_POST['purge'])) { $alert->check($_POST['id'], PURGE); if ($alert->delete($_POST, true)) { Event::log( - $_POST["id"], - "PluginNewsAlert", + $_POST['id'], + 'PluginNewsAlert', 4, - "admin", - sprintf(__('%s purges an item', 'news'), $_SESSION["glpiname"]) + 'admin', + sprintf(__('%s purges an item', 'news'), $_SESSION['glpiname']), ); } $alert->redirectToList(); -} else if (isset($_POST["addvisibility"])) { +} elseif (isset($_POST['addvisibility'])) { $target = new PluginNewsAlert_Target(); $target->check(-1, CREATE, $_POST); $target->add($_POST); @@ -111,11 +111,11 @@ Html::header( __('Alerts', 'news'), - $_SERVER["PHP_SELF"], + $_SERVER['PHP_SELF'], 'tools', - "PluginNewsAlert" + 'PluginNewsAlert', ); -$alert->display(['id' => $_GET["id"]]); +$alert->display(['id' => $_GET['id']]); Html::footer(); diff --git a/front/alert.php b/front/alert.php index cccd9f8..81a2395 100644 --- a/front/alert.php +++ b/front/alert.php @@ -28,13 +28,13 @@ * ------------------------------------------------------------------------- */ -include("../../../inc/includes.php"); +include('../../../inc/includes.php'); Html::header( __('Alerts', 'news'), - $_SERVER["PHP_SELF"], + $_SERVER['PHP_SELF'], 'tools', - "PluginNewsAlert" + 'PluginNewsAlert', ); Search::show('PluginNewsAlert'); diff --git a/front/external.php b/front/external.php index a602e9a..158a852 100644 --- a/front/external.php +++ b/front/external.php @@ -28,7 +28,7 @@ * ------------------------------------------------------------------------- */ -include("../../../inc/includes.php"); +include('../../../inc/includes.php'); Html::nullHeader(PluginNewsAlert::getTypeName()); $logged = isset($_SESSION['glpiID']); diff --git a/front/hidden_alerts.php b/front/hidden_alerts.php index 7afc551..82e24a2 100644 --- a/front/hidden_alerts.php +++ b/front/hidden_alerts.php @@ -28,21 +28,21 @@ * ------------------------------------------------------------------------- */ -include("../../../inc/includes.php"); +include('../../../inc/includes.php'); -if ($_SESSION["glpiactiveprofile"]["interface"] != "central") { - Html::helpHeader(__('Alerts', 'news'), $_SERVER['PHP_SELF'], $_SESSION["glpiname"]); +if ($_SESSION['glpiactiveprofile']['interface'] != 'central') { + Html::helpHeader(__('Alerts', 'news'), $_SERVER['PHP_SELF'], $_SESSION['glpiname']); } else { Html::header( __('Alerts', 'news'), - $_SERVER["PHP_SELF"], + $_SERVER['PHP_SELF'], 'tools', - "PluginNewsAlert" + 'PluginNewsAlert', ); } PluginNewsAlert::displayAlerts(['show_only_login_alerts' => false, - 'show_hidden_alerts' => true + 'show_hidden_alerts' => true, ]); Html::footer(); diff --git a/hook.php b/hook.php index 0cf421f..a3bece9 100644 --- a/hook.php +++ b/hook.php @@ -35,15 +35,15 @@ function plugin_news_install() $migration = new Migration(Plugin::getInfo('news', 'version')); - $default_charset = DBConnection::getDefaultCharset(); + $default_charset = DBConnection::getDefaultCharset(); $default_collation = DBConnection::getDefaultCollation(); - $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); + $default_key_sign = DBConnection::getDefaultPrimaryKeySignOption(); - $alert_table = "glpi_plugin_news_alerts"; + $alert_table = 'glpi_plugin_news_alerts'; if (!$DB->tableExists($alert_table)) { - $white = PluginNewsAlert::WHITE; - $dark = PluginNewsAlert::DARK; + $white = PluginNewsAlert::WHITE; + $dark = PluginNewsAlert::DARK; $medium = PluginNewsAlert::MEDIUM; $DB->query(" CREATE TABLE IF NOT EXISTS `$alert_table` ( @@ -76,9 +76,9 @@ function plugin_news_install() ], [ 'AND' => [ - 'state' => PluginNewsAlert_User::HIDDEN, + 'state' => PluginNewsAlert_User::HIDDEN, PluginNewsAlert::getTable() . '.is_close_allowed' => 0, - ] + ], ], '', [ @@ -86,11 +86,11 @@ function plugin_news_install() PluginNewsAlert::getTable() => [ 'FKEY' => [ PluginNewsAlert_User::getTable() => 'plugin_news_alerts_id', - PluginNewsAlert::getTable() => 'id', - ] - ] - ] - ] + PluginNewsAlert::getTable() => 'id', + ], + ], + ], + ], ); } @@ -123,96 +123,96 @@ function plugin_news_install() "); } - /* Remove old table */ + /* Remove old table */ if ($DB->tableExists('glpi_plugin_news_profiles')) { - $DB->query("DROP TABLE IF EXISTS `glpi_plugin_news_profiles`;"); + $DB->query('DROP TABLE IF EXISTS `glpi_plugin_news_profiles`;'); } - // add displayed on login flag - if (!$DB->fieldExists($alert_table, "is_displayed_onlogin")) { - $migration->addField($alert_table, "is_displayed_onlogin", 'bool'); + // add displayed on login flag + if (!$DB->fieldExists($alert_table, 'is_displayed_onlogin')) { + $migration->addField($alert_table, 'is_displayed_onlogin', 'bool'); } - // add displayed on helpdesk flag - if (!$DB->fieldExists($alert_table, "is_displayed_onhelpdesk")) { - $migration->addField($alert_table, "is_displayed_onhelpdesk", 'bool'); + // add displayed on helpdesk flag + if (!$DB->fieldExists($alert_table, 'is_displayed_onhelpdesk')) { + $migration->addField($alert_table, 'is_displayed_onhelpdesk', 'bool'); } - if (!$DB->fieldExists($alert_table, "date_creation")) { - if ($migration->addField($alert_table, "date_creation", 'date')) { - $migration->addKey($alert_table, "date_creation"); + if (!$DB->fieldExists($alert_table, 'date_creation')) { + if ($migration->addField($alert_table, 'date_creation', 'date')) { + $migration->addKey($alert_table, 'date_creation'); } } - // add close allowed flag - if (!$DB->fieldExists($alert_table, "is_close_allowed")) { - $migration->addField($alert_table, "is_close_allowed", 'bool'); + // add close allowed flag + if (!$DB->fieldExists($alert_table, 'is_close_allowed')) { + $migration->addField($alert_table, 'is_close_allowed', 'bool'); } - // add type field on alert (to display icons) - if (!$DB->fieldExists($alert_table, "type")) { - $migration->addField($alert_table, "type", 'integer'); + // add type field on alert (to display icons) + if (!$DB->fieldExists($alert_table, 'type')) { + $migration->addField($alert_table, 'type', 'integer'); } - // add activity flag - if (!$DB->fieldExists($alert_table, "is_active")) { - if ($migration->addField($alert_table, "is_active", 'bool')) { - $migration->addKey($alert_table, "is_active"); + // add activity flag + if (!$DB->fieldExists($alert_table, 'is_active')) { + if ($migration->addField($alert_table, 'is_active', 'bool')) { + $migration->addKey($alert_table, 'is_active'); } } - // fix is_default default value + // fix is_default default value $alert_fields = $DB->listFields($alert_table); if ($alert_fields['is_deleted']['Default'] !== '0') { $migration->changeField( $alert_table, - "is_deleted", - "is_deleted", - "TINYINT NOT NULL DEFAULT 0" + 'is_deleted', + 'is_deleted', + 'TINYINT NOT NULL DEFAULT 0', ); } - // end/start dates can be null + // end/start dates can be null $migration->changeField( $alert_table, - "date_end", - "date_end", - "TIMESTAMP NULL DEFAULT NULL" + 'date_end', + 'date_end', + 'TIMESTAMP NULL DEFAULT NULL', ); $migration->changeField( $alert_table, - "date_start", - "date_start", - "TIMESTAMP NULL DEFAULT NULL" + 'date_start', + 'date_start', + 'TIMESTAMP NULL DEFAULT NULL', ); - if ($DB->fieldExists($alert_table, "profiles_id")) { - // migration of direct profiles into targets table + if ($DB->fieldExists($alert_table, 'profiles_id')) { + // migration of direct profiles into targets table $query_targets = "INSERT INTO glpi_plugin_news_alerts_targets (plugin_news_alerts_id, itemtype, items_id) SELECT id, 'Profile', profiles_id FROM $alert_table"; - $DB->query($query_targets) or die("fail to migration targets"); + $DB->query($query_targets) or die('fail to migration targets'); - //drop old field - $migration->dropField($alert_table, "profiles_id"); + //drop old field + $migration->dropField($alert_table, 'profiles_id'); } - // Replace -1 value usage in items_id foreign key - if (!$DB->fieldExists("glpi_plugin_news_alerts_targets", "all_items")) { - $migration->addField("glpi_plugin_news_alerts_targets", "all_items", 'bool'); + // Replace -1 value usage in items_id foreign key + if (!$DB->fieldExists('glpi_plugin_news_alerts_targets', 'all_items')) { + $migration->addField('glpi_plugin_news_alerts_targets', 'all_items', 'bool'); $migration->addPostQuery( $DB->buildUpdate( 'glpi_plugin_news_alerts_targets', ['items_id' => '0', 'all_items' => '1'], - ['items_id' => '-1'] - ) + ['items_id' => '-1'], + ), ); } - // install default display preferences + // install default display preferences $dpreferences = new DisplayPreference(); - $found_dpref = $dpreferences->find(['itemtype' => ['LIKE', '%PluginNews%']]); + $found_dpref = $dpreferences->find(['itemtype' => ['LIKE', '%PluginNews%']]); if (count($found_dpref) == 0) { $DB->query("INSERT INTO `glpi_displaypreferences` (`itemtype`, `num`, `rank`, `users_id`) @@ -222,103 +222,103 @@ function plugin_news_install() ('PluginNewsAlert', 6, 4, 0)"); } - // add displayed on central flag - if (!$DB->fieldExists($alert_table, "is_displayed_oncentral")) { + // add displayed on central flag + if (!$DB->fieldExists($alert_table, 'is_displayed_oncentral')) { $migration->addField( $alert_table, - "is_displayed_oncentral", + 'is_displayed_oncentral', 'bool', - ['value' => true] + ['value' => true], ); } - // Add background_color field + // Add background_color field if (!$DB->fieldExists($alert_table, 'background_color')) { $migration->addField( $alert_table, 'background_color', 'string', - ['value' => PluginNewsAlert::WHITE] + ['value' => PluginNewsAlert::WHITE], ); } - // Add text_color field + // Add text_color field if (!$DB->fieldExists($alert_table, 'text_color')) { $migration->addField( $alert_table, 'text_color', 'string', - ['value' => PluginNewsAlert::DARK] + ['value' => PluginNewsAlert::DARK], ); } - // Add emphasis_color field + // Add emphasis_color field if (!$DB->fieldExists($alert_table, 'emphasis_color')) { $migration->addField( $alert_table, 'emphasis_color', 'string', - ['value' => PluginNewsAlert::DARK] + ['value' => PluginNewsAlert::DARK], ); } - // Add size field + // Add size field if (!$DB->fieldExists($alert_table, 'size')) { $migration->addField( $alert_table, 'size', 'string', - ['value' => PluginNewsAlert::MEDIUM] + ['value' => PluginNewsAlert::MEDIUM], ); } - // Add icon field + // Add icon field if (!$DB->fieldExists($alert_table, 'icon')) { $migration->addField( $alert_table, 'icon', 'string', - ['value' => ''] + ['value' => ''], ); } - // Add display_dates field + // Add display_dates field if (!$DB->fieldExists($alert_table, 'display_dates')) { $migration->addField( $alert_table, 'display_dates', 'bool', - ['value' => '1'] + ['value' => '1'], ); } - // Build or rebuild templates data - // -> Will fill new columns (colors + icon) with the expected values for each - // templates - // -> Will update template values if changed in future updates + // Build or rebuild templates data + // -> Will fill new columns (colors + icon) with the expected values for each + // templates + // -> Will update template values if changed in future updates foreach (array_keys(PluginNewsAlert::getTypes()) as $type) { $migration->addPostQuery( $DB->buildUpdate( $alert_table, PluginNewsAlert::getTemplatesValues()[$type], ['type' => $type], - ) + ), ); } - // $migration->addRight() does not allow to copy an existing right, we must write some custom code + // $migration->addRight() does not allow to copy an existing right, we must write some custom code $right_exist = countElementsInTable( - "glpi_profilerights", - ["name" => PluginNewsAlert::$rightname] + 'glpi_profilerights', + ['name' => PluginNewsAlert::$rightname], ) > 0; - // Add the same standard rights on alerts as the rights already granted on - // public reminders + // Add the same standard rights on alerts as the rights already granted on + // public reminders if (!$right_exist) { $reminder_rights = $DB->request([ 'SELECT' => ['profiles_id', 'rights'], 'FROM' => 'glpi_profilerights', - 'WHERE' => ['name' => 'reminder_public'] + 'WHERE' => ['name' => 'reminder_public'], ]); foreach ($reminder_rights as $row) { @@ -332,14 +332,15 @@ function plugin_news_install() ])); if (($_SESSION['glpiactiveprofile']['id'] ?? null) === $profile_id) { - // Ensure menu will be displayed as soon as right is added. - $_SESSION['glpiactiveprofile'][PluginNewsAlert::$rightname] = $right_value; - unset($_SESSION['glpimenu']); + // Ensure menu will be displayed as soon as right is added. + $_SESSION['glpiactiveprofile'][PluginNewsAlert::$rightname] = $right_value; + unset($_SESSION['glpimenu']); } } } $migration->executeMigration(); + return true; } @@ -348,10 +349,10 @@ function plugin_news_uninstall() /** @var DBmysql $DB */ global $DB; - $DB->query("DROP TABLE IF EXISTS `glpi_plugin_news_alerts`;"); - $DB->query("DROP TABLE IF EXISTS `glpi_plugin_news_profiles`;"); - $DB->query("DROP TABLE IF EXISTS `glpi_plugin_news_alerts_users`;"); - $DB->query("DROP TABLE IF EXISTS `glpi_plugin_news_alerts_targets`;"); + $DB->query('DROP TABLE IF EXISTS `glpi_plugin_news_alerts`;'); + $DB->query('DROP TABLE IF EXISTS `glpi_plugin_news_profiles`;'); + $DB->query('DROP TABLE IF EXISTS `glpi_plugin_news_alerts_users`;'); + $DB->query('DROP TABLE IF EXISTS `glpi_plugin_news_alerts_targets`;'); $DB->query("DELETE FROM `glpi_profiles` WHERE `name` LIKE '%plugin_news%';"); $DB->query("DELETE FROM `glpi_displaypreferences` WHERE `itemtype` LIKE '%PluginNews%';"); diff --git a/inc/alert.class.php b/inc/alert.class.php index ba2ba44..99e615b 100644 --- a/inc/alert.class.php +++ b/inc/alert.class.php @@ -38,61 +38,60 @@ class PluginNewsAlert extends CommonDBTM { public static $rightname = 'plugin_news_alert'; - public $dohistory = true; - - // Available templates - const GENERAL = 1; - const INFO = 2; - const WARNING = 3; - const PROBLEM = 4; - - // Available sizes - const SMALL = 'small'; - const MEDIUM = 'medium'; - const BIG = 'big'; - const MAXIMUM = 'maximum'; - - // Available icons - const SETTINGS = 'settings'; - const ALERT_CIRCLE = 'alert-circle'; - const ALERT_TRIANGLE = 'alert-triangle'; - const ALERT_OCTAGON = 'alert-octagon'; - - // Available colors - const DARK = 'dark'; - const WHITE = 'white'; - const BLUE = 'blue'; - const CYAN = 'cyan'; - const INDIGO = 'indigo'; - const PURPLE = 'purple'; - const PINK = 'pink'; - const RED = 'red'; - const ORANGE = 'orange'; - const YELLOW = 'yellow'; - const LIME = 'lime'; + public $dohistory = true; + + // Available templates + public const GENERAL = 1; + public const INFO = 2; + public const WARNING = 3; + public const PROBLEM = 4; + + // Available sizes + public const SMALL = 'small'; + public const MEDIUM = 'medium'; + public const BIG = 'big'; + public const MAXIMUM = 'maximum'; + + // Available icons + public const SETTINGS = 'settings'; + public const ALERT_CIRCLE = 'alert-circle'; + public const ALERT_TRIANGLE = 'alert-triangle'; + public const ALERT_OCTAGON = 'alert-octagon'; + + // Available colors + public const DARK = 'dark'; + public const WHITE = 'white'; + public const BLUE = 'blue'; + public const CYAN = 'cyan'; + public const INDIGO = 'indigo'; + public const PURPLE = 'purple'; + public const PINK = 'pink'; + public const RED = 'red'; + public const ORANGE = 'orange'; + public const YELLOW = 'yellow'; + public const LIME = 'lime'; public static function canDelete() { return self::canPurge(); } - /** - * Returns the type name with consideration of plural - * - * @param number $nb Number of item(s) - * @return string Itemtype name - */ + /** + * Returns the type name with consideration of plural + * + * @param number $nb Number of item(s) + * @return string Itemtype name + */ public static function getTypeName($nb = 0) { return __('Alerts', 'news'); } - /** - * @see CommonGLPI::defineTabs() - **/ + /** + * @see CommonGLPI::defineTabs() + **/ public function defineTabs($options = []) { - $ong = []; $this->addDefaultFormTab($ong) ->addStandardTab('PluginNewsAlert_Target', $ong, $options) @@ -103,50 +102,49 @@ public function defineTabs($options = []) public function rawSearchOptions() { - $tab = []; $tab[] = [ - 'id' => 1, - 'table' => $this->getTable(), - 'field' => 'name', - 'name' => __('Name', 'news'), - 'datatype' => 'itemlink', - 'itemlink_type' => $this->getType(), - 'massiveaction' => false, + 'id' => 1, + 'table' => $this->getTable(), + 'field' => 'name', + 'name' => __('Name', 'news'), + 'datatype' => 'itemlink', + 'itemlink_type' => $this->getType(), + 'massiveaction' => false, ]; $tab[] = [ - 'id' => 2, - 'table' => $this->getTable(), - 'field' => 'date_start', - 'name' => __('Visibility start date', 'news'), - 'datatype' => 'date', + 'id' => 2, + 'table' => $this->getTable(), + 'field' => 'date_start', + 'name' => __('Visibility start date', 'news'), + 'datatype' => 'date', ]; $tab[] = [ - 'id' => 3, - 'table' => $this->getTable(), - 'field' => 'date_end', - 'name' => __('Visibility end date', 'news'), - 'datatype' => 'date', + 'id' => 3, + 'table' => $this->getTable(), + 'field' => 'date_end', + 'name' => __('Visibility end date', 'news'), + 'datatype' => 'date', ]; $tab[] = [ - 'id' => 4, - 'table' => 'glpi_entities', - 'field' => 'completename', - 'name' => __('Entity', 'news'), - 'massiveaction' => false, + 'id' => 4, + 'table' => 'glpi_entities', + 'field' => 'completename', + 'name' => __('Entity', 'news'), + 'massiveaction' => false, ]; $tab[] = [ - 'id' => 5, - 'table' => $this->getTable(), - 'field' => 'is_recursive', - 'name' => __('Recursive', 'news'), - 'datatype' => 'bool', - 'massiveaction' => false, + 'id' => 5, + 'table' => $this->getTable(), + 'field' => 'is_recursive', + 'name' => __('Recursive', 'news'), + 'datatype' => 'bool', + 'massiveaction' => false, ]; $tab[] = [ @@ -161,56 +159,56 @@ public function rawSearchOptions() ]; $tab[] = [ - 'id' => 7, - 'table' => $this->getTable(), - 'field' => 'is_close_allowed', - 'name' => __('Can close alert', 'news'), - 'datatype' => 'bool', - 'massiveaction' => false, + 'id' => 7, + 'table' => $this->getTable(), + 'field' => 'is_close_allowed', + 'name' => __('Can close alert', 'news'), + 'datatype' => 'bool', + 'massiveaction' => false, ]; $tab[] = [ - 'id' => 8, - 'table' => $this->getTable(), - 'field' => 'is_displayed_onlogin', - 'name' => __('Show on login page', 'news'), - 'datatype' => 'bool', - 'massiveaction' => false, + 'id' => 8, + 'table' => $this->getTable(), + 'field' => 'is_displayed_onlogin', + 'name' => __('Show on login page', 'news'), + 'datatype' => 'bool', + 'massiveaction' => false, ]; $tab[] = [ - 'id' => 9, - 'table' => $this->getTable(), - 'field' => 'is_displayed_onhelpdesk', - 'name' => __('Show on helpdesk page', 'news'), - 'datatype' => 'bool', - 'massiveaction' => false, + 'id' => 9, + 'table' => $this->getTable(), + 'field' => 'is_displayed_onhelpdesk', + 'name' => __('Show on helpdesk page', 'news'), + 'datatype' => 'bool', + 'massiveaction' => false, ]; $tab[] = [ - 'id' => 10, - 'table' => $this->getTable(), - 'field' => 'is_active', - 'name' => __('Active', 'news'), - 'datatype' => 'bool', + 'id' => 10, + 'table' => $this->getTable(), + 'field' => 'is_active', + 'name' => __('Active', 'news'), + 'datatype' => 'bool', ]; $tab[] = [ - 'id' => 19, - 'table' => $this->getTable(), - 'field' => 'date_mod', - 'name' => __('Last update', 'news'), - 'datatype' => 'datetime', - 'massiveaction' => false, + 'id' => 19, + 'table' => $this->getTable(), + 'field' => 'date_mod', + 'name' => __('Last update', 'news'), + 'datatype' => 'datetime', + 'massiveaction' => false, ]; $tab[] = [ - 'id' => 121, - 'table' => $this->getTable(), - 'field' => 'date_creation', - 'name' => __('Creation date', 'news'), - 'datatype' => 'datetime', - 'massiveaction' => false, + 'id' => 121, + 'table' => $this->getTable(), + 'field' => 'date_creation', + 'name' => __('Creation date', 'news'), + 'datatype' => 'datetime', + 'massiveaction' => false, ]; return $tab; @@ -228,16 +226,16 @@ public function post_updateItem($history = true) $all_alert = $alert_user->find( [ 'plugin_news_alerts_id' => $this->getID(), - 'state' => PluginNewsAlert_User::HIDDEN - ] + 'state' => PluginNewsAlert_User::HIDDEN, + ], ); foreach ($all_alert as $alert) { //update state to force display $alert_user->update( [ - 'id' => $alert['id'], - 'state' => PluginNewsAlert_User::VISIBLE - ] + 'id' => $alert['id'], + 'state' => PluginNewsAlert_User::VISIBLE, + ], ); } } @@ -248,11 +246,11 @@ public static function findAllToNotify($params = []) /** @var DBmysql $DB */ global $DB; - $p['show_only_login_alerts'] = false; - $p['show_only_central_alerts'] = false; - $p['show_hidden_alerts'] = false; - $p['show_only_helpdesk_alerts'] = false; - $p['entities_id'] = false; + $p['show_only_login_alerts'] = false; + $p['show_only_central_alerts'] = false; + $p['show_hidden_alerts'] = false; + $p['show_only_helpdesk_alerts'] = false; + $p['entities_id'] = false; foreach ($params as $key => $value) { $p[$key] = $value; } @@ -291,29 +289,29 @@ public static function findAllToNotify($params = []) [ 'AND' => [ "$ttable.itemtype" => 'Profile', - 'OR' => [ - "$ttable.items_id" => $_SESSION['glpiactiveprofile']['id'], + 'OR' => [ + "$ttable.items_id" => $_SESSION['glpiactiveprofile']['id'], "$ttable.all_items" => 1, ], - ] + ], ], [ 'AND' => [ "$ttable.itemtype" => 'Group', "$ttable.items_id" => $fndgroup, - ] + ], ], [ 'AND' => [ "$ttable.itemtype" => 'User', "$ttable.items_id" => $_SESSION['glpiID'], - ] + ], ], - ] + ], ], - ] + ], ]; - } else if ($p['show_only_login_alerts']) { + } elseif ($p['show_only_login_alerts']) { $login_sql = ["{$table}.is_displayed_onlogin" => 1]; } @@ -336,9 +334,9 @@ public static function findAllToNotify($params = []) $entity_sql = getEntitiesRestrictCriteria($table, '', $p['entities_id'], true); } $criteria = [ - 'SELECT' => ["$table.*"], - 'DISTINCT' => true, - 'FROM' => $table, + 'SELECT' => ["$table.*"], + 'DISTINCT' => true, + 'FROM' => $table, 'LEFT JOIN' => [ $utable => [ 'ON' => [ @@ -348,18 +346,18 @@ public static function findAllToNotify($params = []) 'AND' => [ "$utable.users_id" => $users_id, "$utable.state" => $hidstate, - ] - ] - ] - ] + ], + ], + ], + ], ], 'INNER JOIN' => [ $ttable => [ 'ON' => [ $ttable => 'plugin_news_alerts_id', - $table => 'id' - ] - ] + $table => 'id', + ], + ], ], 'WHERE' => [ $login_show_hidden_sql, @@ -367,17 +365,17 @@ public static function findAllToNotify($params = []) 'OR' => [ ["$table.date_start" => ['<=', $today]], ["$table.date_start" => null], - ] + ], ], [ 'OR' => [ ["$table.date_end" => ['>=', $today]], ["$table.date_end" => null], - ] + ], ], 'is_deleted' => 0, 'is_active' => 1, - ] + ], ]; if (!empty($targets_sql)) { $criteria['INNER JOIN'][$ttable]['ON'][] = $targets_sql; @@ -407,20 +405,21 @@ public static function findAllToNotify($params = []) public static function getMenuContent() { - $menu = parent::getMenuContent(); + $menu = parent::getMenuContent(); $menu['links']['search'] = PluginNewsAlert::getSearchURL(false); return $menu; } - public function checkDate($datetime) { if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', $datetime)) { - $datetime = explode(" ", $datetime); - list($year , $month , $day) = explode('-', $datetime[0]); - return checkdate((int)$month, (int)$day, (int)$year); + $datetime = explode(' ', $datetime); + list($year, $month, $day) = explode('-', $datetime[0]); + + return checkdate((int) $month, (int) $day, (int) $year); } + return false; } @@ -429,7 +428,7 @@ public function prepareInputForAdd($input) $errors = []; if ($this->isNewItem()) { - $missing_name = empty($input['name'] ?? ""); + $missing_name = empty($input['name'] ?? ''); } else { $missing_name = isset($input['name']) && empty($input['name']); } @@ -459,6 +458,7 @@ public function prepareInputForUpdate($input) if ($input['_transfer'] ?? false) { return $input; } + return $this->prepareInputForAdd($input); } @@ -473,7 +473,7 @@ public function post_addItem() 'itemtype' => 'Profile', 'items_id' => 0, 'all_items' => 1, - ] + ], ); } @@ -504,6 +504,7 @@ public function showForm($ID, $options = []) 'icons' => self::getIcons(), 'templates_values' => self::getTemplatesValues(), ]); + return true; } @@ -511,31 +512,31 @@ public static function displayOnCentral() { echo ""; self::displayAlerts(['show_only_central_alerts' => true]); - echo ""; + echo ''; } public static function displayOnLogin() { - echo Html::css(Plugin::getPhpDir('news', false) . "/css/styles.css"); + echo Html::css(Plugin::getPhpDir('news', false) . '/css/styles.css'); echo "
"; self::displayAlerts(['show_only_login_alerts' => true]); - echo "
"; + echo ''; } public static function displayOnTicket() { echo ""; self::displayAlerts(['show_only_helpdesk_alerts' => true]); - echo ""; + echo ''; } public static function displayAlerts($params = []) { - $p['show_only_login_alerts'] = false; - $p['show_only_central_alerts'] = false; - $p['show_hidden_alerts'] = false; - $p['show_only_helpdesk_alerts'] = false; - $p['entities_id'] = false; + $p['show_only_login_alerts'] = false; + $p['show_only_central_alerts'] = false; + $p['show_hidden_alerts'] = false; + $p['show_only_helpdesk_alerts'] = false; + $p['entities_id'] = false; foreach ($params as $key => $value) { $p[$key] = $value; } @@ -548,11 +549,11 @@ public static function displayAlerts($params = []) } $hidden_params = [ - 'show_hidden_alerts' => true, - 'show_only_login_alerts' => false, - 'show_only_central_alerts' => $p['show_only_central_alerts'], - 'show_only_helpdesk_alerts' => $p['show_only_helpdesk_alerts'], - 'entities_id' => $p['entities_id'] + 'show_hidden_alerts' => true, + 'show_only_login_alerts' => false, + 'show_only_central_alerts' => $p['show_only_central_alerts'], + 'show_only_helpdesk_alerts' => $p['show_only_helpdesk_alerts'], + 'entities_id' => $p['entities_id'], ]; if ( @@ -562,24 +563,24 @@ public static function displayAlerts($params = []) ) { echo "
"; echo ""; - echo __("You have hidden alerts valid for current date", 'news'); - echo ""; - echo "
"; + echo __('You have hidden alerts valid for current date', 'news'); + echo ''; + echo ''; } - echo ""; + echo ''; if ($p['show_only_login_alerts']) { - echo Html::script(Plugin::getPhpDir('news', false) . "/js/news.js"); + echo Html::script(Plugin::getPhpDir('news', false) . '/js/news.js'); } } - /** - * Compute alert size classes - * - * @param string $size Alert size - * - * @return string Bootstrap col classes - */ + /** + * Compute alert size classes + * + * @param string $size Alert size + * + * @return string Bootstrap col classes + */ public static function getSizeClasses(string $size): string { // Note: the 'w-100' class will be added using javascript when we are @@ -588,17 +589,17 @@ public static function getSizeClasses(string $size): string switch ($size) { case self::SMALL: - return "col-xxl-4 col-xl-4 col-12"; + return 'col-xxl-4 col-xl-4 col-12'; default: case self::MEDIUM: - return "col-xxl-6 col-xl-6 col-12"; + return 'col-xxl-6 col-xl-6 col-12'; case self::BIG: - return "col-xxl-8 col-xl-8 col-12"; + return 'col-xxl-8 col-xl-8 col-12'; case self::MAXIMUM: - return "col-12"; + return 'col-12'; } } @@ -614,41 +615,41 @@ public static function displayAlert($alert, $p) ]); } - /** - * Get available templates for alerts - * - * @return array - */ + /** + * Get available templates for alerts + * + * @return array + */ public static function getTypes(): array { return [ - self::GENERAL => __("General", 'news'), - self::INFO => __("Information", 'news'), - self::WARNING => __("Warning", 'news'), - self::PROBLEM => __("Problem", 'news'), + self::GENERAL => __('General', 'news'), + self::INFO => __('Information', 'news'), + self::WARNING => __('Warning', 'news'), + self::PROBLEM => __('Problem', 'news'), ]; } - /** - * Get available sizes for alerts - * - * @return array - */ + /** + * Get available sizes for alerts + * + * @return array + */ public static function getSizes(): array { return [ - self::SMALL => __("Small", 'news'), - self::MEDIUM => __("Medium", 'news'), - self::BIG => __("Big", 'news'), - self::MAXIMUM => __("Max", 'news'), + self::SMALL => __('Small', 'news'), + self::MEDIUM => __('Medium', 'news'), + self::BIG => __('Big', 'news'), + self::MAXIMUM => __('Max', 'news'), ]; } - /** - * Get available icons for alerts - * - * @return array - */ + /** + * Get available icons for alerts + * + * @return array + */ public static function getIcons(): array { return [ @@ -659,33 +660,33 @@ public static function getIcons(): array ]; } - /** - * Get available colors for alerts (text, background and accent) - * - * @return array - */ + /** + * Get available colors for alerts (text, background and accent) + * + * @return array + */ public static function getColors(): array { return [ - self::DARK => __("Black", 'news'), - self::WHITE => __("White", 'news'), - self::BLUE => __("Blue", 'news'), - self::CYAN => __("Cyan", 'news'), - self::INDIGO => __("Indigo", 'news'), - self::PURPLE => __("Purple", 'news'), - self::PINK => __("Pink", 'news'), - self::RED => __("Red", 'news'), - self::ORANGE => __("Orange", 'news'), - self::YELLOW => __("Yellow", 'news'), - self::LIME => __("Lime", 'news'), + self::DARK => __('Black', 'news'), + self::WHITE => __('White', 'news'), + self::BLUE => __('Blue', 'news'), + self::CYAN => __('Cyan', 'news'), + self::INDIGO => __('Indigo', 'news'), + self::PURPLE => __('Purple', 'news'), + self::PINK => __('Pink', 'news'), + self::RED => __('Red', 'news'), + self::ORANGE => __('Orange', 'news'), + self::YELLOW => __('Yellow', 'news'), + self::LIME => __('Lime', 'news'), ]; } - /** - * Get icon and colors values for each available templates - * - * @return array - */ + /** + * Get icon and colors values for each available templates + * + * @return array + */ public static function getTemplatesValues(): array { return [ @@ -733,25 +734,24 @@ public static function preItemForm($params = []) $entities_id = isset($params['item']->fields['entities_id']) ? $params['item']->fields['entities_id'] : false; // false to use current entity - self::displayAlerts(['show_only_helpdesk_alerts' => true, - 'show_hidden_alerts' => false, - 'entities_id' => $entities_id + self::displayAlerts(['show_only_helpdesk_alerts' => true, + 'show_hidden_alerts' => false, + 'entities_id' => $entities_id, ]); } } public static function preItemList($params = []) { - if (isset($params['itemtype']) && $params['itemtype'] == "Ticket") { + if (isset($params['itemtype']) && $params['itemtype'] == 'Ticket') { echo ""; self::displayAlerts(['show_only_helpdesk_alerts' => true]); - echo ""; + echo ''; } } - public static function getIcon() { - return "fas fa-bell"; + return 'fas fa-bell'; } } diff --git a/inc/alert_target.class.php b/inc/alert_target.class.php index e234a7b..f80e1fc 100644 --- a/inc/alert_target.class.php +++ b/inc/alert_target.class.php @@ -56,18 +56,18 @@ public static function canPurge() public function addNeededInfoToInput($input) { if ( - $input['itemtype'] == 'Profile' + $input['itemtype'] == 'Profile' && $input['items_id'] == -1 ) { $input['all_items'] = 1; - $input['items_id'] = 0; + $input['items_id'] = 0; } + return $input; } public static function getSpecificValueToDisplay($field, $values, array $options = []) { - if (!is_array($values)) { $values = [$field => $values]; } @@ -79,16 +79,18 @@ public static function getSpecificValueToDisplay($field, $values, array $options ) { $item = new $values['itemtype'](); if ( - $values['itemtype'] == "Profile" + $values['itemtype'] == 'Profile' && $values['all_items'] == 1 ) { - return $item->getTypeName() . " - " . __('All', 'news'); + return $item->getTypeName() . ' - ' . __('All', 'news'); } $item->getFromDB($values['items_id']); - return $item->getTypeName() . " - " . $item->getName(); + + return $item->getTypeName() . ' - ' . $item->getName(); } break; } + return parent::getSpecificValueToDisplay($field, $values, $options); } @@ -97,8 +99,9 @@ public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) if ($item instanceof PluginNewsAlert) { $nb = countElementsInTable( self::getTable(), - ['plugin_news_alerts_id' => $item->getID()] + ['plugin_news_alerts_id' => $item->getID()], ); + return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb); } @@ -123,26 +126,26 @@ public static function showForAlert(PluginNewsAlert $alert) $types = ['Group', 'Profile', 'User']; echo ""; - echo ""; - echo "'; + echo '"; - $params = ['type' => '__VALUE__', + echo ''; + $params = ['type' => '__VALUE__', 'entities_id' => $alert->fields['entities_id'], - 'is_recursive' => $alert->fields['is_recursive'] + 'is_recursive' => $alert->fields['is_recursive'], ]; Ajax::updateItemOnSelectEvent( - "dropdown_itemtype" . $addrand, + 'dropdown_itemtype' . $addrand, "visibility$rand", - Plugin::getWebDir('news') . "/ajax/targets.php", - $params + Plugin::getWebDir('news') . '/ajax/targets.php', + $params, ); - echo ""; - echo ""; - echo "
"; - echo __('Add a target', 'news') . ": "; + echo '
'; + echo __('Add a target', 'news') . ': '; $addrand = Dropdown::showItemTypes('itemtype', $types, ['width' => '']); - echo ""; + echo ''; echo ""; - echo "
"; + echo ''; + echo ''; + echo ''; Html::closeForm(); echo "
"; @@ -151,46 +154,46 @@ public static function showForAlert(PluginNewsAlert $alert) if ($nb = count($found_target) > 0) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams - = ['num_displayed' => $nb, + = ['num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, - 'specific_actions' => ['delete' => _x('button', 'Delete permanently', 'news')] + 'specific_actions' => ['delete' => _x('button', 'Delete permanently', 'news')], ]; Html::showMassiveActions($massiveactionparams); echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ''; + echo "'; + echo ''; + echo ''; + echo ''; foreach ($found_target as $current_target) { if (class_exists($current_target['itemtype'])) { $item = new $current_target['itemtype'](); $item->getFromDB($current_target['items_id']); $name = ($current_target['all_items'] == 1 - && $current_target['itemtype'] == "Profile") + && $current_target['itemtype'] == 'Profile') ? __('All', 'news') : $item->getName(['complete' => true]); echo ""; - echo ""; - echo ""; + echo ''; + echo ''; echo ""; - echo ""; + echo ''; } } - echo "
" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "" . __('Type', 'news') . "" . __('Recipient', 'news') . "
" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . '' . __('Type', 'news') . '' . __('Recipient', 'news') . '
"; - Html::showMassiveActionCheckBox(__CLASS__, $current_target["id"]); - echo "" . $item->getTypeName() . "'; + Html::showMassiveActionCheckBox(__CLASS__, $current_target['id']); + echo '' . $item->getTypeName() . '$name
"; + echo ''; $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } - echo "
"; + echo ''; return true; } diff --git a/inc/alert_user.class.php b/inc/alert_user.class.php index 6162792..16a6a1f 100644 --- a/inc/alert_user.class.php +++ b/inc/alert_user.class.php @@ -36,12 +36,12 @@ class PluginNewsAlert_User extends CommonDBRelation { // @codingStandardsIgnoreEnd - const HIDDEN = 1; + public const HIDDEN = 1; - const VISIBLE = 0; + public const VISIBLE = 0; - public static $itemtype_1 = 'PluginNewsAlert'; - public static $items_id_1 = 'plugin_news_alerts_id'; + public static $itemtype_1 = 'PluginNewsAlert'; + public static $items_id_1 = 'plugin_news_alerts_id'; public static $checkItem_1_Rights = self::HAVE_VIEW_RIGHT_ON_ITEM; public static $itemtype_2 = 'User'; @@ -57,7 +57,7 @@ public static function hideAlert($params = []) } $plugin_news_alerts_id = intval($params['id']); - $users_id = $_SESSION['glpiID']; + $users_id = $_SESSION['glpiID']; return $DB->updateOrInsert( self::getTable(), @@ -66,8 +66,8 @@ public static function hideAlert($params = []) ], [ 'plugin_news_alerts_id' => $plugin_news_alerts_id, - 'users_id' => $users_id, - ] + 'users_id' => $users_id, + ], ); } @@ -85,11 +85,11 @@ public function rawSearchOptions() $tab = parent::rawSearchOptions(); $tab[] = [ - 'id' => 5, - 'table' => $this->getTable(), - 'field' => 'state', - 'name' => __('Status', 'news'), - 'datatype' => 'dropdown', + 'id' => 5, + 'table' => $this->getTable(), + 'field' => 'state', + 'name' => __('Status', 'news'), + 'datatype' => 'dropdown', ]; return $tab; diff --git a/inc/profile.class.php b/inc/profile.class.php index 7d3b895..7998dba 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -63,7 +63,7 @@ class PluginNewsProfile extends Profile public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { return self::createTabEntry( - PluginNewsAlert::getTypeName(Session::getPluralNumber()) + PluginNewsAlert::getTypeName(Session::getPluralNumber()), ); } @@ -80,7 +80,7 @@ public static function displayTabContentForItem( $profile->getFromDB($item->getID()); $twig = TemplateRenderer::getInstance(); - $twig->display("@news/profile.html.twig", [ + $twig->display('@news/profile.html.twig', [ 'id' => $item->getID(), 'profile' => $profile, 'title' => PluginNewsAlert::getTypeName(Session::getPluralNumber()), @@ -89,8 +89,8 @@ public static function displayTabContentForItem( 'itemtype' => PluginNewsAlert::getType(), 'label' => PluginNewsAlert::getTypeName(Session::getPluralNumber()), 'field' => PluginNewsAlert::$rightname, - ] - ] + ], + ], ]); return true; diff --git a/setup.php b/setup.php index 10b406a..b104a8d 100644 --- a/setup.php +++ b/setup.php @@ -31,9 +31,9 @@ define('PLUGIN_NEWS_VERSION', '1.12.3'); // Minimal GLPI version, inclusive -define("PLUGIN_NEWS_MIN_GLPI", "10.0.0"); +define('PLUGIN_NEWS_MIN_GLPI', '10.0.0'); // Maximum GLPI version, exclusive -define("PLUGIN_NEWS_MAX_GLPI", "10.0.99"); +define('PLUGIN_NEWS_MAX_GLPI', '10.0.99'); function plugin_init_news() { @@ -52,15 +52,15 @@ function plugin_init_news() ) { Plugin::registerClass('PluginNewsProfile', ['addtabon' => 'Profile']); - $PLUGIN_HOOKS['add_css']['news'] = 'css/styles.css'; - $PLUGIN_HOOKS['add_javascript']['news'][] = "js/news.js"; - $PLUGIN_HOOKS['display_login']['news'] = [ - "PluginNewsAlert", "displayOnLogin" + $PLUGIN_HOOKS['add_css']['news'] = 'css/styles.css'; + $PLUGIN_HOOKS['add_javascript']['news'][] = 'js/news.js'; + $PLUGIN_HOOKS['display_login']['news'] = [ + 'PluginNewsAlert', 'displayOnLogin', ]; $PLUGIN_HOOKS['display_central']['news'] = [ - "PluginNewsAlert", "displayOnCentral" + 'PluginNewsAlert', 'displayOnCentral', ]; - $PLUGIN_HOOKS['pre_item_list']['news'] = ["PluginNewsAlert", "preItemList"]; + $PLUGIN_HOOKS['pre_item_list']['news'] = ['PluginNewsAlert', 'preItemList']; $PLUGIN_HOOKS['pre_item_form']['news'] = ['PluginNewsAlert', 'preItemForm']; @@ -70,7 +70,7 @@ function plugin_init_news() ]; $PLUGIN_HOOKS['config_page']['news'] = 'front/alert.php'; - // require tinymce (for glpi >= 9.2) + // require tinymce (for glpi >= 9.2) $CFG_GLPI['javascript']['tools']['pluginnewsalert'] = ['tinymce']; } } @@ -79,16 +79,16 @@ function plugin_init_news() function plugin_version_news() { return [ - 'name' => __('Alerts', 'news'), - 'version' => PLUGIN_NEWS_VERSION, - 'author' => "TECLIB'", - 'license' => "GPLv2+", - 'homepage' => 'https://github.com/pluginsGLPI/news', - 'requirements' => [ + 'name' => __('Alerts', 'news'), + 'version' => PLUGIN_NEWS_VERSION, + 'author' => "TECLIB'", + 'license' => 'GPLv2+', + 'homepage' => 'https://github.com/pluginsGLPI/news', + 'requirements' => [ 'glpi' => [ 'min' => PLUGIN_NEWS_MIN_GLPI, 'max' => PLUGIN_NEWS_MAX_GLPI, - ] - ] + ], + ], ]; }