From 702a23883384807dd0bd68413833398ce2e1ff0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Thu, 14 Nov 2019 15:24:21 +0100 Subject: [PATCH] Add GLPI 9.5 compatibility * Remove usage of dropped 'SELECT DISTINCT' * Replace usage of deprecated 'DBMysql::fetch_assoc()' * Replace usage of deprecated 'DBMysql::fetch_array()' * Add marketplace compatibility * Add icon for fields container * Use GLPI 9.5 min required PHP version * Add 1.11.0 version definition --- .travis.yml | 13 +- composer.json | 15 +- composer.lock | 834 +++++++++++++++++++++------------ front/container.form.php | 6 +- hook.php | 6 +- inc/container.class.php | 27 +- inc/dropdown.class.php | 18 +- inc/field.class.php | 13 +- inc/labeltranslation.class.php | 4 +- inc/menu.class.php | 21 +- inc/toolbox.class.php | 3 +- plugin.xml | 4 +- setup.php | 50 +- tests/bootstrap.php | 16 +- 14 files changed, 628 insertions(+), 402 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25a68933..c5435a5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php php: - - 5.6 + - 7.2 - 7.4 - - nightly services: - mysql @@ -11,12 +10,12 @@ env: global: - DB=mysql matrix: - - GLPIVER=9.4/bugfixes + - GLPIVER=9.5/bugfixes before_script: - composer self-update - git clone --depth=1 https://github.com/glpi-project/glpi -b $GLPIVER ../glpi && cd ../glpi - - composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest + - bin/console dependencies install - mysql -u root -e 'create database glpitest;' - bin/console glpi:database:install --config-dir=./tests --no-interaction --db-name=glpitest --db-host=127.0.0.1 --db-user=root - mv ../fields plugins/fields @@ -26,11 +25,7 @@ before_script: script: - vendor/bin/robo --no-interaction code:cs --strict - mysql -u root -e 'select version();' - - ./vendor/bin/atoum --debug -bf tests/bootstrap.php -d tests/units/ - -matrix: - allow_failures: - - php: nightly + - php vendor/bin/atoum -p 'php -d memory_limit=512M' --debug --force-terminal --use-dot-report --bootstrap-file tests/bootstrap.php --no-code-coverage --max-children-number 1 -d tests/units cache: directories: diff --git a/composer.json b/composer.json index f19312b0..7f281522 100644 --- a/composer.json +++ b/composer.json @@ -1,15 +1,16 @@ { - "require-dev": { - "glpi-project/tools": "^0.1", - "atoum/atoum": "^3.1" - }, "require": { - "php": ">=5.6" + "php": "^7.2" + }, + "require-dev": { + "atoum/atoum": "^3.1", + "glpi-project/tools": "^0.1" }, "config": { "optimize-autoloader": true, "platform": { - "php": "5.6" - } + "php": "7.2.0" + }, + "sort-packages": true } } diff --git a/composer.lock b/composer.lock index 78da80ab..3531ded2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5e43bf50d5c8fddf89b745c926a5c05f", + "content-hash": "60eb7d1cf0f21f4b53c8aaeea526703a", "packages": [], "packages-dev": [ { "name": "atoum/atoum", - "version": "3.4.1", + "version": "3.4.2", "source": { "type": "git", "url": "https://github.com/atoum/atoum.git", - "reference": "35714b3044ccbfea6d9d78a7a7107347ee1b5ce9" + "reference": "e90606b89e62c5c18c5d02596078edf55f35b3c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/atoum/atoum/zipball/35714b3044ccbfea6d9d78a7a7107347ee1b5ce9", - "reference": "35714b3044ccbfea6d9d78a7a7107347ee1b5ce9", + "url": "https://api.github.com/repos/atoum/atoum/zipball/e90606b89e62c5c18c5d02596078edf55f35b3c3", + "reference": "e90606b89e62c5c18c5d02596078edf55f35b3c3", "shasum": "" }, "require": { @@ -88,35 +88,35 @@ "test", "unit testing" ], - "time": "2020-01-22T14:16:11+00:00" + "time": "2020-03-04T10:29:09+00:00" }, { "name": "consolidation/annotated-command", - "version": "2.12.0", + "version": "4.1.1", "source": { "type": "git", "url": "https://github.com/consolidation/annotated-command.git", - "reference": "512a2e54c98f3af377589de76c43b24652bcb789" + "reference": "efc58dc0f34a45539787c5190b41b5d2a50a08da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/512a2e54c98f3af377589de76c43b24652bcb789", - "reference": "512a2e54c98f3af377589de76c43b24652bcb789", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/efc58dc0f34a45539787c5190b41b5d2a50a08da", + "reference": "efc58dc0f34a45539787c5190b41b5d2a50a08da", "shasum": "" }, "require": { - "consolidation/output-formatters": "^3.4", - "php": ">=5.4.5", - "psr/log": "^1", - "symfony/console": "^2.8|^3|^4", - "symfony/event-dispatcher": "^2.5|^3|^4", - "symfony/finder": "^2.5|^3|^4" + "consolidation/output-formatters": "^4.1.1", + "php": ">=7.1.3", + "psr/log": "^1|^2", + "symfony/console": "^4.4.8|^5", + "symfony/event-dispatcher": "^4.4.8|^5", + "symfony/finder": "^4.4.8|^5" }, "require-dev": { "g1a/composer-test-scenarios": "^3", - "php-coveralls/php-coveralls": "^1", + "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^6", - "squizlabs/php_codesniffer": "^2.7" + "squizlabs/php_codesniffer": "^3" }, "type": "library", "extra": { @@ -130,42 +130,10 @@ "php": "7.1.3" } } - }, - "symfony2": { - "require": { - "symfony/console": "^2.8" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36" - }, - "remove": [ - "php-coveralls/php-coveralls" - ], - "config": { - "platform": { - "php": "5.4.8" - } - }, - "scenario-options": { - "create-lockfile": "false" - } - }, - "phpunit4": { - "require-dev": { - "phpunit/phpunit": "^4.8.36" - }, - "remove": [ - "php-coveralls/php-coveralls" - ], - "config": { - "platform": { - "php": "5.4.8" - } - } } }, "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "4.x-dev" } }, "autoload": { @@ -184,7 +152,7 @@ } ], "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2019-03-08T16:55:03+00:00" + "time": "2020-05-27T21:11:36+00:00" }, { "name": "consolidation/config", @@ -269,74 +237,45 @@ }, { "name": "consolidation/log", - "version": "1.1.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/consolidation/log.git", - "reference": "b2e887325ee90abc96b0a8b7b474cd9e7c896e3a" + "reference": "ba0bf6af1fbd09ed4dc18fc2f27b12ceff487cbf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/log/zipball/b2e887325ee90abc96b0a8b7b474cd9e7c896e3a", - "reference": "b2e887325ee90abc96b0a8b7b474cd9e7c896e3a", + "url": "https://api.github.com/repos/consolidation/log/zipball/ba0bf6af1fbd09ed4dc18fc2f27b12ceff487cbf", + "reference": "ba0bf6af1fbd09ed4dc18fc2f27b12ceff487cbf", "shasum": "" }, "require": { - "php": ">=5.4.5", + "php": ">=7.1.3", "psr/log": "^1.0", - "symfony/console": "^2.8|^3|^4" + "symfony/console": "^4|^5" }, "require-dev": { "g1a/composer-test-scenarios": "^3", - "php-coveralls/php-coveralls": "^1", + "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^6", - "squizlabs/php_codesniffer": "^2" + "squizlabs/php_codesniffer": "^3" }, "type": "library", "extra": { "scenarios": { "symfony4": { - "require": { - "symfony/console": "^4.0" - }, - "config": { - "platform": { - "php": "7.1.3" - } - } - }, - "symfony2": { - "require": { - "symfony/console": "^2.8" - }, "require-dev": { - "phpunit/phpunit": "^4.8.36" - }, - "remove": [ - "php-coveralls/php-coveralls" - ], - "config": { - "platform": { - "php": "5.4.8" - } - } - }, - "phpunit4": { - "require-dev": { - "phpunit/phpunit": "^4.8.36" + "symfony/console": "^4" }, - "remove": [ - "php-coveralls/php-coveralls" - ], "config": { "platform": { - "php": "5.4.8" + "php": "7.1.3" } } } }, "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { @@ -355,35 +294,35 @@ } ], "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", - "time": "2019-01-01T17:30:51+00:00" + "time": "2020-05-27T17:06:13+00:00" }, { "name": "consolidation/output-formatters", - "version": "3.5.0", + "version": "4.1.1", "source": { "type": "git", "url": "https://github.com/consolidation/output-formatters.git", - "reference": "99ec998ffb697e0eada5aacf81feebfb13023605" + "reference": "9deeddd6a916d0a756b216a8b40ce1016e17c0b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/99ec998ffb697e0eada5aacf81feebfb13023605", - "reference": "99ec998ffb697e0eada5aacf81feebfb13023605", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/9deeddd6a916d0a756b216a8b40ce1016e17c0b9", + "reference": "9deeddd6a916d0a756b216a8b40ce1016e17c0b9", "shasum": "" }, "require": { "dflydev/dot-access-data": "^1.1.0", - "php": ">=5.4.0", - "symfony/console": "^2.8|^3|^4", - "symfony/finder": "^2.5|^3|^4" + "php": ">=7.1.3", + "symfony/console": "^4|^5", + "symfony/finder": "^4|^5" }, "require-dev": { "g1a/composer-test-scenarios": "^3", - "php-coveralls/php-coveralls": "^1", - "phpunit/phpunit": "^5.7.27", - "squizlabs/php_codesniffer": "^2.7", - "symfony/var-dumper": "^2.8|^3|^4", - "victorjonsson/markdowndocs": "^1.3" + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^6", + "squizlabs/php_codesniffer": "^3", + "symfony/var-dumper": "^4", + "symfony/yaml": "^4" }, "suggest": { "symfony/var-dumper": "For using the var_dump formatter" @@ -395,49 +334,15 @@ "require": { "symfony/console": "^4.0" }, - "require-dev": { - "phpunit/phpunit": "^6" - }, "config": { "platform": { "php": "7.1.3" } } - }, - "symfony3": { - "require": { - "symfony/console": "^3.4", - "symfony/finder": "^3.4", - "symfony/var-dumper": "^3.4" - }, - "config": { - "platform": { - "php": "5.6.32" - } - } - }, - "symfony2": { - "require": { - "symfony/console": "^2.8" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.36" - }, - "remove": [ - "php-coveralls/php-coveralls" - ], - "config": { - "platform": { - "php": "5.4.8" - } - }, - "scenario-options": { - "create-lockfile": "false" - } } }, "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "4.x-dev" } }, "autoload": { @@ -456,30 +361,30 @@ } ], "description": "Format text by applying transformations provided by plug-in formatters.", - "time": "2019-05-30T23:16:01+00:00" + "time": "2020-05-27T20:51:17+00:00" }, { "name": "consolidation/robo", - "version": "1.4.11", + "version": "1.4.12", "source": { "type": "git", "url": "https://github.com/consolidation/Robo.git", - "reference": "5fa1d901776a628167a325baa9db95d8edf13a80" + "reference": "eb45606f498b3426b9a98b7c85e300666a968e51" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/Robo/zipball/5fa1d901776a628167a325baa9db95d8edf13a80", - "reference": "5fa1d901776a628167a325baa9db95d8edf13a80", + "url": "https://api.github.com/repos/consolidation/Robo/zipball/eb45606f498b3426b9a98b7c85e300666a968e51", + "reference": "eb45606f498b3426b9a98b7c85e300666a968e51", "shasum": "" }, "require": { - "consolidation/annotated-command": "^2.11.0", - "consolidation/config": "^1.2", - "consolidation/log": "~1", - "consolidation/output-formatters": "^3.1.13", - "consolidation/self-update": "^1", - "grasmash/yaml-expander": "^1.3", - "league/container": "^2.2", + "consolidation/annotated-command": "^2.11.0|^4.1", + "consolidation/config": "^1.2.1", + "consolidation/log": "^1.1.1|^2", + "consolidation/output-formatters": "^3.1.13|^4.1", + "consolidation/self-update": "^1.1.5", + "grasmash/yaml-expander": "^1.4", + "league/container": "^2.4.1", "php": ">=5.5.0", "symfony/console": "^2.8|^3|^4", "symfony/event-dispatcher": "^2.5|^3|^4", @@ -491,20 +396,13 @@ "codegyre/robo": "< 1.0" }, "require-dev": { - "codeception/aspect-mock": "^1|^2.1.1", - "codeception/base": "^2.3.7", - "codeception/verify": "^0.3.2", "g1a/composer-test-scenarios": "^3", - "goaop/framework": "~2.1.2", - "goaop/parser-reflection": "^1.1.0", "natxet/cssmin": "3.0.4", - "nikic/php-parser": "^3.1.5", - "patchwork/jsqueeze": "~2", + "patchwork/jsqueeze": "^2", "pear/archive_tar": "^1.4.4", "php-coveralls/php-coveralls": "^1", - "phpunit/php-code-coverage": "~2|~4", - "sebastian/comparator": "^1.2.4", - "squizlabs/php_codesniffer": "^2.8" + "phpunit/phpunit": "^5.7.27", + "squizlabs/php_codesniffer": "^3" }, "suggest": { "henrikbjorn/lurker": "For monitoring filesystem changes in taskWatch", @@ -532,8 +430,11 @@ "require": { "symfony/console": "^2.8" }, + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, "remove": [ - "goaop/framework" + "php-coveralls/php-coveralls" ], "config": { "platform": { @@ -546,7 +447,7 @@ } }, "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { @@ -565,26 +466,26 @@ } ], "description": "Modern task runner", - "time": "2019-10-29T15:50:02+00:00" + "time": "2020-02-18T17:31:26+00:00" }, { "name": "consolidation/self-update", - "version": "1.1.5", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/consolidation/self-update.git", - "reference": "a1c273b14ce334789825a09d06d4c87c0a02ad54" + "reference": "dba6b2c0708f20fa3ba8008a2353b637578849b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/self-update/zipball/a1c273b14ce334789825a09d06d4c87c0a02ad54", - "reference": "a1c273b14ce334789825a09d06d4c87c0a02ad54", + "url": "https://api.github.com/repos/consolidation/self-update/zipball/dba6b2c0708f20fa3ba8008a2353b637578849b4", + "reference": "dba6b2c0708f20fa3ba8008a2353b637578849b4", "shasum": "" }, "require": { "php": ">=5.5.0", - "symfony/console": "^2.8|^3|^4", - "symfony/filesystem": "^2.5|^3|^4" + "symfony/console": "^2.8|^3|^4|^5", + "symfony/filesystem": "^2.5|^3|^4|^5" }, "bin": [ "scripts/release" @@ -605,17 +506,17 @@ "MIT" ], "authors": [ - { - "name": "Greg Anderson", - "email": "greg.1.anderson@greenknowe.org" - }, { "name": "Alexander Menk", "email": "menk@mestrona.net" + }, + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" } ], "description": "Provides a self:update command for Symfony Console applications.", - "time": "2018-10-28T01:52:03+00:00" + "time": "2020-04-13T02:49:20+00:00" }, { "name": "container-interop/container-interop", @@ -746,16 +647,16 @@ }, { "name": "glpi-project/tools", - "version": "0.1.8", + "version": "0.1.13", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "39ca503a00454e6c5d7d97bd8baff358d262a897" + "reference": "2028ecf9acd8b838cff37771dcab77ced9391f41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/39ca503a00454e6c5d7d97bd8baff358d262a897", - "reference": "39ca503a00454e6c5d7d97bd8baff358d262a897", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/2028ecf9acd8b838cff37771dcab77ced9391f41", + "reference": "2028ecf9acd8b838cff37771dcab77ced9391f41", "shasum": "" }, "require": { @@ -792,7 +693,7 @@ "plugins", "tools" ], - "time": "2019-06-07T09:46:17+00:00" + "time": "2020-06-19T10:29:26+00:00" }, { "name": "grasmash/expander", @@ -1094,16 +995,16 @@ }, { "name": "psr/log", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801" + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801", - "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", "shasum": "" }, "require": { @@ -1137,20 +1038,20 @@ "psr", "psr-3" ], - "time": "2019-11-01T11:05:21+00:00" + "time": "2020-03-23T09:12:05+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.4", + "version": "3.5.5", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dceec07328401de6211037abbb18bda423677e26" + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", - "reference": "dceec07328401de6211037abbb18bda423677e26", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/73e2e7f57d958e7228fce50dc0c61f58f017f9f6", + "reference": "73e2e7f57d958e7228fce50dc0c61f58f017f9f6", "shasum": "" }, "require": { @@ -1188,29 +1089,33 @@ "phpcs", "standards" ], - "time": "2020-01-30T22:20:29+00:00" + "time": "2020-04-17T01:09:41+00:00" }, { "name": "symfony/console", - "version": "v3.4.37", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "7c5bdd346f9d90a2d22d4e1fe61e02dc19b98f12" + "reference": "326b064d804043005526f5a0494cfb49edb59bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/7c5bdd346f9d90a2d22d4e1fe61e02dc19b98f12", - "reference": "7c5bdd346f9d90a2d22d4e1fe61e02dc19b98f12", + "url": "https://api.github.com/repos/symfony/console/zipball/326b064d804043005526f5a0494cfb49edb59bb0", + "reference": "326b064d804043005526f5a0494cfb49edb59bb0", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0|~4.0", - "symfony/polyfill-mbstring": "~1.0" + "php": ">=7.1.3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/polyfill-php80": "^1.15", + "symfony/service-contracts": "^1.1|^2" }, "conflict": { "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3|>=5", + "symfony/lock": "<4.4", "symfony/process": "<3.3" }, "provide": { @@ -1218,11 +1123,12 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.3|~4.0" + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/event-dispatcher": "^4.3", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^3.4|^4.0|^5.0", + "symfony/var-dumper": "^4.3|^5.0" }, "suggest": { "psr/log": "For using the console logger", @@ -1233,7 +1139,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1260,41 +1166,69 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2020-01-10T07:52:48+00:00" + "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": "2020-05-30T20:06:45+00:00" }, { - "name": "symfony/debug", - "version": "v3.4.37", + "name": "symfony/event-dispatcher", + "version": "v4.4.10", "source": { "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "70dd18e93bb8bdf3c4db7fde832619fef9828cf8" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "a5370aaa7807c7a439b21386661ffccf3dff2866" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/70dd18e93bb8bdf3c4db7fde832619fef9828cf8", - "reference": "70dd18e93bb8bdf3c4db7fde832619fef9828cf8", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a5370aaa7807c7a439b21386661ffccf3dff2866", + "reference": "a5370aaa7807c7a439b21386661ffccf3dff2866", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" + "php": ">=7.1.3", + "symfony/event-dispatcher-contracts": "^1.1" }, "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + "symfony/dependency-injection": "<3.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "1.1" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0|~4.0" + "psr/log": "~1.0", + "symfony/config": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/service-contracts": "^1.1|^2", + "symfony/stopwatch": "^3.4|^4.0|^5.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\Debug\\": "" + "Symfony\\Component\\EventDispatcher\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -1314,54 +1248,55 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Debug Component", + "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2020-01-08T16:36:15+00:00" + "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": "2020-05-20T08:37:50+00:00" }, { - "name": "symfony/event-dispatcher", - "version": "v3.4.37", + "name": "symfony/event-dispatcher-contracts", + "version": "v1.1.7", "source": { "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "79ede8f2836e5ec910ebb325bde40f987244baa8" + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/79ede8f2836e5ec910ebb325bde40f987244baa8", - "reference": "79ede8f2836e5ec910ebb325bde40f987244baa8", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/stopwatch": "~2.8|~3.0|~4.0" + "php": "^7.1.3" }, "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" + "psr/event-dispatcher": "", + "symfony/event-dispatcher-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "1.1-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Symfony\\Contracts\\EventDispatcher\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1369,40 +1304,48 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony EventDispatcher Component", + "description": "Generic abstractions related to dispatching event", "homepage": "https://symfony.com", - "time": "2020-01-04T12:05:51+00:00" + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-09-17T09:54:03+00:00" }, { "name": "symfony/filesystem", - "version": "v3.4.37", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "0a0d3b4bda11aa3a0464531c40e681e184e75628" + "reference": "b27f491309db5757816db672b256ea2e03677d30" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/0a0d3b4bda11aa3a0464531c40e681e184e75628", - "reference": "0a0d3b4bda11aa3a0464531c40e681e184e75628", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/b27f491309db5757816db672b256ea2e03677d30", + "reference": "b27f491309db5757816db672b256ea2e03677d30", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": ">=7.1.3", "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1429,29 +1372,43 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2020-01-17T08:50:08+00:00" + "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": "2020-05-30T18:50:54+00:00" }, { "name": "symfony/finder", - "version": "v3.4.37", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "a90a9d3b9f458a5cdeabfa4090b20c000ca3962f" + "reference": "5729f943f9854c5781984ed4907bbb817735776b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a90a9d3b9f458a5cdeabfa4090b20c000ca3962f", - "reference": "a90a9d3b9f458a5cdeabfa4090b20c000ca3962f", + "url": "https://api.github.com/repos/symfony/finder/zipball/5729f943f9854c5781984ed4907bbb817735776b", + "reference": "5729f943f9854c5781984ed4907bbb817735776b", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1478,20 +1435,34 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-01-01T11:03:25+00:00" + "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": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.1", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", "shasum": "" }, "require": { @@ -1503,7 +1474,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1536,20 +1511,34 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "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": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "7110338d81ce1cbc3e273136e4574663627037a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7", "shasum": "" }, "require": { @@ -1561,7 +1550,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1595,29 +1588,199 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "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": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", + "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "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 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "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": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "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": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/process", - "version": "v3.4.37", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "5b9d2bcffe4678911a4c941c00b7c161252cf09a" + "reference": "c714958428a85c86ab97e3a0c96db4c4f381b7f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/5b9d2bcffe4678911a4c941c00b7c161252cf09a", - "reference": "5b9d2bcffe4678911a4c941c00b7c161252cf09a", + "url": "https://api.github.com/repos/symfony/process/zipball/c714958428a85c86ab97e3a0c96db4c4f381b7f5", + "reference": "c714958428a85c86ab97e3a0c96db4c4f381b7f5", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1644,31 +1807,103 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2020-01-01T11:03:25+00:00" + "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": "2020-05-30T20:06:45+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "reference": "ffc7f5692092df31515df2a5ecf3b7302b3ddacf", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "psr/container": "^1.0" + }, + "suggest": { + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "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 writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-10-14T12:27:06+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.37", + "version": "v4.4.10", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "aa46bc2233097d5212332c907f9911533acfbf80" + "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/aa46bc2233097d5212332c907f9911533acfbf80", - "reference": "aa46bc2233097d5212332c907f9911533acfbf80", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", + "reference": "c2d2cc66e892322cfcc03f8f12f8340dbd7a3f8a", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": ">=7.1.3", "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~3.4|~4.0" + "symfony/console": "^3.4|^4.0|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -1676,7 +1911,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -1703,7 +1938,21 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-01-13T08:00:59+00:00" + "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": "2020-05-20T08:37:50+00:00" } ], "aliases": [], @@ -1712,10 +1961,11 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.6" + "php": "^7.2" }, "platform-dev": [], "platform-overrides": { - "php": "5.6" - } + "php": "7.2.0" + }, + "plugin-api-version": "1.1.0" } diff --git a/front/container.form.php b/front/container.form.php index e75346ca..5ef6b125 100644 --- a/front/container.form.php +++ b/front/container.form.php @@ -10,17 +10,17 @@ if (isset($_POST["add"])) { $container->check(-1, CREATE, $_POST); $newID = $container->add($_POST); - Html::redirect($CFG_GLPI["root_doc"]."/plugins/fields/front/container.form.php?id=$newID"); + Html::redirect(PLUGINFIELDS_WEB_DIR."/front/container.form.php?id=$newID"); } else if (isset($_POST["delete"])) { $container->check($_POST['id'], DELETE); $ok = $container->delete($_POST); - Html::redirect($CFG_GLPI["root_doc"]."/plugins/fields/front/container.php"); + Html::redirect(PLUGINFIELDS_WEB_DIR."/front/container.php"); } else if (isset($_REQUEST["purge"])) { $container->check($_REQUEST['id'], PURGE); $container->delete($_REQUEST, 1); - Html::redirect($CFG_GLPI["root_doc"]."/plugins/fields/front/container.php"); + Html::redirect(PLUGINFIELDS_WEB_DIR."/front/container.php"); } else if (isset($_POST["update"])) { $container->check($_POST['id'], UPDATE); diff --git a/hook.php b/hook.php index 45aaf360..0c58689a 100644 --- a/hook.php +++ b/hook.php @@ -61,7 +61,7 @@ function plugin_fields_install() { echo ""; //load all classes - $dir = GLPI_ROOT . "/plugins/fields/inc/"; + $dir = PLUGINFIELDS_DIR . "/inc/"; include_once ("{$dir}toolbox.class.php"); foreach ($classesToInstall as $class) { if ($plug = isPluginItemType($class)) { @@ -131,7 +131,7 @@ function plugin_fields_uninstall() { foreach ($classesToUninstall as $class) { if ($plug = isPluginItemType($class)) { - $dir = GLPI_ROOT . "/plugins/fields/inc/"; + $dir = PLUGINFIELDS_DIR . "/inc/"; $item = strtolower($plug['class']); if (file_exists("$dir$item.class.php")) { @@ -255,7 +255,7 @@ function plugin_fields_rule_matched($params = []) { WHERE f.name = '$field'"; $res = $DB->query($query); if ($DB->numrows($res) > 0) { - $data = $DB->fetch_assoc($res); + $data = $DB->fetchAssoc($res); //retrieve computer $agents_id = $params['input']['plugin_fusioninventory_agents_id']; diff --git a/inc/container.class.php b/inc/container.class.php index 00cee03d..b2ca2ca7 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -155,7 +155,7 @@ static function install(Migration $migration, $version) { foreach ($existings as $existing) { $data = []; foreach ($fieldnames as $oldname => $newname) { - $data[$newname] = $existing[$olddname]; + $data[$newname] = $existing[$oldname]; } $compdata->add($data); } @@ -184,13 +184,13 @@ static function install(Migration $migration, $version) { foreach ($itemtypes as $itemtype) { $sysname = self::getSystemName($itemtype, $container['name']); $class_filename = $sysname.".class.php"; - if (file_exists(GLPI_ROOT."/plugins/fields/inc/$class_filename")) { - unlink(GLPI_ROOT."/plugins/fields/inc/$class_filename"); + if (file_exists(PLUGINFIELDS_DIR."/inc/$class_filename")) { + unlink(PLUGINFIELDS_DIR."/inc/$class_filename"); } $injclass_filename = $sysname."injection.class.php"; - if (file_exists(GLPI_ROOT."/plugins/fields/inc/$injclass_filename")) { - unlink(GLPI_ROOT."/plugins/fields/inc/$injclass_filename"); + if (file_exists(PLUGINFIELDS_DIR."/inc/$injclass_filename")) { + unlink(PLUGINFIELDS_DIR."/inc/$injclass_filename"); } } @@ -458,8 +458,7 @@ public static function generateTemplate($fields) { $sysname = self::getSystemName($itemtype, $fields['name']); $classname = self::getClassname($itemtype, $fields['name']); - $template_class = file_get_contents(GLPI_ROOT . - "/plugins/fields/templates/container.class.tpl"); + $template_class = file_get_contents(PLUGINFIELDS_DIR."/templates/container.class.tpl"); $template_class = str_replace("%%CLASSNAME%%", $classname, $template_class); $template_class = str_replace("%%ITEMTYPE%%", $itemtype, $template_class); $template_class = str_replace("%%CONTAINER%%", $fields['id'], $template_class); @@ -471,8 +470,7 @@ public static function generateTemplate($fields) { } // Generate Datainjection files - $template_class = file_get_contents(GLPI_ROOT . - "/plugins/fields/templates/injection.class.tpl"); + $template_class = file_get_contents(PLUGINFIELDS_DIR."/templates/injection.class.tpl"); $template_class = str_replace("%%CLASSNAME%%", $classname, $template_class); $template_class = str_replace("%%ITEMTYPE%%", $itemtype, $template_class); $template_class = str_replace("%%CONTAINER_ID%%", $fields['id'], $template_class); @@ -920,7 +918,7 @@ static function getUsedItemtypes($type = 'all', $must_be_active = false) { FROM `glpi_plugin_fields_containers` WHERE '.$where; $result = $DB->query($query); - while (list($data) = $DB->fetch_array($result)) { + while (list($data) = $DB->fetchArray($result)) { $jsonitemtype = json_decode($data); $itemtypes = array_merge($itemtypes, $jsonitemtype); } @@ -1166,7 +1164,7 @@ static function validateValues($data, $itemtype, $massiveaction) { $db_result = []; if ($result = $DB->query($query)) { - $db_result = $DB->fetch_assoc($result); + $db_result = $DB->fetchAssoc($result); if (isset($db_result[$name])) { $value = $db_result[$name]; } @@ -1453,7 +1451,7 @@ static function getAddSearchOptions($itemtype, $containers_id = false) { AND fields.type != 'header' ORDER BY fields.id ASC"; $res = $DB->query($query); - while ($data = $DB->fetch_assoc($res)) { + while ($data = $DB->fetchAssoc($res)) { if ($containers_id !== false) { // Filter by container (don't filter by SQL for have $i value with few containers for a itemtype) @@ -1611,4 +1609,9 @@ static function getClassname($itemtype = "", $raw_name = "") { static function getSystemName($itemtype = "", $raw_name = "") { return strtolower($itemtype.preg_replace('/s$/', '', $raw_name)); } + + + static function getIcon() { + return "fas fa-tasks"; + } } diff --git a/inc/dropdown.class.php b/inc/dropdown.class.php index edb8f311..35c8a169 100644 --- a/inc/dropdown.class.php +++ b/inc/dropdown.class.php @@ -27,18 +27,18 @@ static function install(Migration $migration, $version) { foreach ($fields as $field) { //First, drop old fields from plugin directories $class_filename = $field['name']."dropdown.class.php"; - if (file_exists(GLPI_ROOT."/plugins/fields/inc/$class_filename")) { - unlink(GLPI_ROOT."/plugins/fields/inc/$class_filename"); + if (file_exists(PLUGINFIELDS_DIR."/inc/$class_filename")) { + unlink(PLUGINFIELDS_DIR."/inc/$class_filename"); } $front_filename = $field['name']."dropdown.php"; - if (file_exists(GLPI_ROOT."/plugins/fields/front/$front_filename")) { - unlink(GLPI_ROOT."/plugins/fields/front/$front_filename"); + if (file_exists(PLUGINFIELDS_DIR."/front/$front_filename")) { + unlink(PLUGINFIELDS_DIR."/front/$front_filename"); } $form_filename = $field['name']."dropdown.form.php"; - if (file_exists(GLPI_ROOT."/plugins/fields/front/$form_filename")) { - unlink(GLPI_ROOT."/plugins/fields/front/$form_filename"); + if (file_exists(PLUGINFIELDS_DIR."/front/$form_filename")) { + unlink(PLUGINFIELDS_DIR."/front/$form_filename"); } //Second, create new files @@ -65,7 +65,7 @@ static function uninstall() { static function create($input) { //get class template - $template_class = file_get_contents(GLPI_ROOT."/plugins/fields/templates/dropdown.class.tpl"); + $template_class = file_get_contents(PLUGINFIELDS_DIR."/templates/dropdown.class.tpl"); if ($template_class === false) { return false; } @@ -101,7 +101,7 @@ static function create($input) { } //get front template - $template_front = file_get_contents(GLPI_ROOT."/plugins/fields/templates/dropdown.tpl"); + $template_front = file_get_contents(PLUGINFIELDS_DIR."/templates/dropdown.tpl"); if ($template_front === false) { Toolbox::logDebug("Error : get dropdown front template error"); return false; @@ -117,7 +117,7 @@ static function create($input) { } //get form template - $template_form = file_get_contents(GLPI_ROOT."/plugins/fields/templates/dropdown.form.tpl"); + $template_form = file_get_contents(PLUGINFIELDS_DIR."/templates/dropdown.form.tpl"); if ($template_form === false) { return false; } diff --git a/inc/field.class.php b/inc/field.class.php index d71b8ee6..6cf57c68 100644 --- a/inc/field.class.php +++ b/inc/field.class.php @@ -234,7 +234,7 @@ function getNextRanking() { $result = $DB->query($sql); if ($DB->numrows($result) > 0) { - $data = $DB->fetch_assoc($result); + $data = $DB->fetchAssoc($result); return $data["rank"] + 1; } return 0; @@ -328,12 +328,12 @@ function showSummary($container) { Session::initNavigateListItems('PluginFieldsField', __('Fields list')); - while ($data = $DB->fetch_array($result)) { + while ($data = $DB->fetchArray($result)) { if ($this->getFromDB($data['id'])) { echo ""; echo ""; - echo "{$this->fields['label']}"; + echo "getID()}'>{$this->fields['label']}"; echo ""; echo "".$fields_type[$this->fields['type']].""; echo "".$this->fields['default_value'].""; @@ -407,7 +407,7 @@ function showForm($ID, $options = []) { Html::autocompletionTextField($this, 'default_value', ['value' => $this->fields["default_value"]]); if ($this->fields["type"] == "dropdown") { - echo ' '.__('Configure', 'fields').' @@ -456,8 +456,7 @@ static function showForTabContainer($c_id, $items_id, $itemtype) { //get fields for this container $field_obj = new self(); $fields = $field_obj->find(['plugin_fields_containers_id' => $c_id, 'is_active' => 1], "ranking"); - echo "
"; + echo ""; echo Html::hidden('plugin_fields_containers_id', ['value' => $c_id]); echo Html::hidden('items_id', ['value' => $items_id]); echo Html::hidden('itemtype', ['value' => $itemtype]); @@ -849,7 +848,7 @@ static function showSingle($itemtype, $searchOption, $massiveaction = false) { return false; } - $data = $DB->fetch_assoc($res); + $data = $DB->fetchAssoc($res); //display an hidden post field to store container id echo Html::hidden('c_id', ['value' => $data['plugin_fields_containers_id']]); diff --git a/inc/labeltranslation.class.php b/inc/labeltranslation.class.php index bd74393a..d7ab7497 100644 --- a/inc/labeltranslation.class.php +++ b/inc/labeltranslation.class.php @@ -97,7 +97,7 @@ static function showTranslations(CommonDBTM $item) { echo Html::scriptBlock(' addTranslation' . $item->getID() . $rand . ' = function() { $("#viewtranslation' . $item->getID() . $rand . '").load( - "' . $CFG_GLPI['root_doc'] . '/plugins/fields/ajax/viewtranslations.php", + "' . Plugin::getWebDir('fields') . '/ajax/viewtranslations.php", ' . json_encode([ 'type' => __CLASS__, 'itemtype' => $item::getType(), @@ -151,7 +151,7 @@ static function showTranslations(CommonDBTM $item) { echo Html::scriptBlock(' viewEditTranslation' . $data['id'] . $rand . ' = function() { $("#viewtranslation' . $item->getID() . $rand . '").load( - "' . $CFG_GLPI['root_doc'] . '/plugins/fields/ajax/viewtranslations.php", + "' . Plugin::getWebDir('fields') . '/ajax/viewtranslations.php", ' . json_encode([ 'type' => __CLASS__, 'itemtype' => $item::getType(), diff --git a/inc/menu.class.php b/inc/menu.class.php index a7837c13..87837987 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -12,17 +12,24 @@ static function getMenuContent() { return; } - $front_fields = "/plugins/fields/front"; - $menu = []; - $menu['title'] = self::getMenuName(); - $menu['page'] = "$front_fields/container.php"; + $front_fields = Plugin::getPhpDir('fields', false)."/front"; + $menu = [ + 'title' => self::getMenuName(), + 'page' => "$front_fields/container.php", + 'icon' => PluginFieldsContainer::getIcon(), + ]; $itemtypes = ['PluginFieldsContainer' => 'fieldscontainer']; foreach ($itemtypes as $itemtype => $option) { - $menu['options'][$option]['title'] = $itemtype::getTypeName(2); - $menu['options'][$option]['page'] = $itemtype::getSearchURL(false); - $menu['options'][$option]['links']['search'] = $itemtype::getSearchURL(false); + $menu['options'][$option] = [ + 'title' => $itemtype::getTypeName(2), + 'page' => $itemtype::getSearchURL(false), + 'links' => [ + 'search' => $itemtype::getSearchURL(false) + ] + ]; + if ($itemtype::canCreate()) { $menu['options'][$option]['links']['add'] = $itemtype::getFormURL(false); } diff --git a/inc/toolbox.class.php b/inc/toolbox.class.php index 0bf5a6fb..845204ac 100644 --- a/inc/toolbox.class.php +++ b/inc/toolbox.class.php @@ -123,7 +123,8 @@ public function fixFieldsNames(Migration $migration, $condition) { foreach ($sql_fields_to_rename as $old_field_name => $new_field_name) { $tables_to_update = $DB->request( [ - 'SELECT DISTINCT' => 'TABLE_NAME', + 'SELECT' => 'TABLE_NAME', + 'DISTINCT' => true, 'FROM' => 'INFORMATION_SCHEMA.COLUMNS', 'WHERE' => [ 'TABLE_SCHEMA' => $DB->dbdefault, diff --git a/plugin.xml b/plugin.xml index b01d6330..02572cac 100644 --- a/plugin.xml +++ b/plugin.xml @@ -98,9 +98,9 @@ Il existe un [script de migration](https://github.com/pluginsGLPI/customfields/b - 1.11.0-rc1 + 1.11.0 ~9.5.0 - https://github.com/pluginsGLPI/fields/releases/download/1.11.0-rc1/glpi-fields-1.11.0-rc1.tar.bz2 + https://github.com/pluginsGLPI/fields/releases/download/1.11.0/glpi-fields-1.11.0.tar.bz2 1.10.3 diff --git a/setup.php b/setup.php index 7e258680..f6d42b74 100644 --- a/setup.php +++ b/setup.php @@ -26,15 +26,18 @@ -------------------------------------------------------------------------- */ -define ('PLUGIN_FIELDS_VERSION', '1.10.3'); +define ('PLUGIN_FIELDS_VERSION', '1.11.0'); // Minimal GLPI version, inclusive -define("PLUGIN_FIELDS_MIN_GLPI", "9.4"); +define("PLUGIN_FIELDS_MIN_GLPI", "9.5"); // Maximum GLPI version, exclusive -define("PLUGIN_FIELDS_MAX_GLPI", "9.5"); +define("PLUGIN_FIELDS_MAX_GLPI", "9.6"); if (!defined("PLUGINFIELDS_DIR")) { - define("PLUGINFIELDS_DIR", GLPI_ROOT . "/plugins/fields"); + define("PLUGINFIELDS_DIR", Plugin::getPhpDir("fields")); +} +if (!defined("PLUGINFIELDS_WEB_DIR")) { + define("PLUGINFIELDS_WEB_DIR", Plugin::getWebDir("fields")); } if (!defined("PLUGINFIELDS_DOC_DIR")) { @@ -186,34 +189,6 @@ function plugin_version_fields() { ]; } -/** - * Check pre-requisites before install - * OPTIONNAL, but recommanded - * - * @return boolean - */ -function plugin_fields_check_prerequisites() { - - //Version check is not done by core in GLPI < 9.2 but has to be delegated to core in GLPI >= 9.2. - if (!method_exists('Plugin', 'checkGlpiVersion')) { - $version = preg_replace('/^((\d+\.?)+).*$/', '$1', GLPI_VERSION); - $matchMinGlpiReq = version_compare($version, PLUGIN_FIELDS_MIN_GLPI, '>='); - $matchMaxGlpiReq = version_compare($version, PLUGIN_FIELDS_MAX_GLPI, '<'); - - if (!$matchMinGlpiReq || !$matchMaxGlpiReq) { - echo vsprintf( - 'This plugin requires GLPI >= %1$s and < %2$s.', - [ - PLUGIN_FIELDS_MIN_GLPI, - PLUGIN_FIELDS_MAX_GLPI, - ] - ); - return false; - } - } - - return true; -} /** * Check all stored containers files (classes & front) are present, or create they if needed @@ -264,14 +239,3 @@ function plugin_fields_checkFiles($force = false) { } } } - -/** - * Check configuration process - * - * @param boolean $verbose Whether to display message on failure. Defaults to false - * - * @return boolean - */ -function plugin_fields_check_config($verbose = false) { - return true; -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 74bed30e..6331453c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,11 +2,22 @@ // fix empty CFG_GLPI on boostrap; see https://github.com/sebastianbergmann/phpunit/issues/325 global $CFG_GLPI; +define('TU_USER', true); // Used by GLPI::initLogger() to create TestHandler for logs + //define plugin paths define("PLUGINFIELDS_DOC_DIR", __DIR__ . "/generated_test_data"); define('GLPI_ROOT', dirname(dirname(dirname(__DIR__)))); define("GLPI_CONFIG_DIR", GLPI_ROOT . "/tests"); + +define( + 'PLUGINS_DIRECTORIES', + [ + GLPI_ROOT . '/plugins', + GLPI_ROOT . '/tests/fixtures/plugins', + ] +); + include GLPI_ROOT . "/inc/includes.php"; include_once GLPI_ROOT . '/tests/GLPITestCase.php'; include_once GLPI_ROOT . '/tests/DbTestCase.php'; @@ -15,11 +26,6 @@ $plugin = new \Plugin(); $plugin->checkStates(true); $plugin->getFromDBbyDir('fields'); -//check from prerequisites as Plugin::install() does not! -if (!plugin_fields_check_prerequisites()) { - echo "\nPrerequisites are not met!"; - die(1); -} if (!$plugin->isInstalled('fields')) { $plugin->install($plugin->getID()); }