From f3d65c41a46be226dbe6ee987a8f6caff13bf6df Mon Sep 17 00:00:00 2001 From: And Kustra Date: Mon, 31 Jan 2022 14:16:11 +0100 Subject: [PATCH 1/3] The changes required for the latest version of GLPI (v10.0.0) have been added. --- inc/common.class.php | 15 ++++++++------- inc/licensehelper.class.php | 4 ++-- inc/userslicenses.class.php | 8 ++++---- setup.php | 6 +++--- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/inc/common.class.php b/inc/common.class.php index b633219..27934f1 100755 --- a/inc/common.class.php +++ b/inc/common.class.php @@ -174,8 +174,9 @@ private static function usersUnassignedToALicense(int $license_id): array ); $users_assigned_to_a_license = []; - while ($data = $result->next()) { - $users_assigned_to_a_license[] = $data['users_id']; + + foreach ($result as $data => $content) { + $users_assigned_to_a_license[] = $content['users_id']; } if (empty($users_assigned_to_a_license)) { @@ -188,8 +189,9 @@ private static function usersUnassignedToALicense(int $license_id): array } $users_unassigned_to_a_license = []; - while ($data = $result->next()) { - $users_unassigned_to_a_license[] = $data['id']; + + foreach ($result as $data => $content) { + $users_unassigned_to_a_license[] = $content['id']; } return $users_unassigned_to_a_license; @@ -409,7 +411,6 @@ static function showForLicense(SoftwareLicense $license): void return; } - echo "
"; $can_edit = PluginFpsoftwareVersionhelper::checkRights( "software", [CREATE, UPDATE, DELETE, PURGE], @@ -428,9 +429,9 @@ static function showForLicense(SoftwareLicense $license): void $number_of_assigned_licenses = $license_helper->getNumberOfAssignedLicenses(); if ($number_of_assigned_licenses < 1) { - echo ""; + echo "
"; echo ""; - echo "
" . __('No item found') . "
\n"; + echo "" . PHP_EOL; return; } diff --git a/inc/licensehelper.class.php b/inc/licensehelper.class.php index 4f00295..8c54541 100644 --- a/inc/licensehelper.class.php +++ b/inc/licensehelper.class.php @@ -37,8 +37,8 @@ private function getNumberOfLicenses(): int ); $number_of_licenses = []; - while ($data = $result->next()) { - $number_of_licenses[] = $data['number']; + foreach ($result as $data => $content) { + $number_of_licenses[] = $content['number']; } return $number_of_licenses[0]; diff --git a/inc/userslicenses.class.php b/inc/userslicenses.class.php index e2c8b03..e4e1086 100755 --- a/inc/userslicenses.class.php +++ b/inc/userslicenses.class.php @@ -251,8 +251,8 @@ public static function getUserLicenses(int $user_id): array ); $user_licenses = []; - while ($data = $result->next()) { - $user_licenses[] = $data['softwarelicenses_id']; + foreach ($result as $data => $content) { + $user_licenses[] = $content['softwarelicenses_id']; } return $user_licenses; @@ -280,8 +280,8 @@ public static function getLicensesUnassignedToUser(int $user_id): array } $licenses = []; - while ($data = $result->next()) { - $licenses[] = $data['id']; + foreach ($result as $data => $content) { + $licenses[] = $content['id']; } return $licenses; diff --git a/setup.php b/setup.php index 32fb7da..bf9fe4f 100755 --- a/setup.php +++ b/setup.php @@ -45,7 +45,7 @@ function plugin_version_fpsoftware() { return array( 'name' => "FP Software", - 'version' => '1.6.1', + 'version' => '2.0.0', 'author' => 'Future Processing', 'license' => 'GPLv2+', 'homepage' => 'http://www.future-processing.com', @@ -64,8 +64,8 @@ function plugin_version_fpsoftware() */ function plugin_fpsoftware_check_prerequisites() { - if (version_compare(GLPI_VERSION, '0.84', '<') || version_compare(GLPI_VERSION, '9.6', '>=')) { - echo "This plugin requires GLPI >= 0.84 and GLPI < 9.6"; + if (version_compare(GLPI_VERSION, '0.84', '<') || version_compare(GLPI_VERSION, '10.0.0', '>=')) { + echo "This plugin requires GLPI >= 0.84 and GLPI <= 10.0.0"; return false; } From 139dfcea792321ca02aa898dff66e44fac0be75f Mon Sep 17 00:00:00 2001 From: And Kustra Date: Mon, 31 Jan 2022 14:25:38 +0100 Subject: [PATCH 2/3] small fix in setup file. --- setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.php b/setup.php index bf9fe4f..8196e80 100755 --- a/setup.php +++ b/setup.php @@ -65,7 +65,7 @@ function plugin_version_fpsoftware() function plugin_fpsoftware_check_prerequisites() { if (version_compare(GLPI_VERSION, '0.84', '<') || version_compare(GLPI_VERSION, '10.0.0', '>=')) { - echo "This plugin requires GLPI >= 0.84 and GLPI <= 10.0.0"; + echo "This plugin requires GLPI >= 0.84 and GLPI >= 10.0.0"; return false; } From 4c01d8ed3c69b96a711b57227677c9ab8781a9e5 Mon Sep 17 00:00:00 2001 From: And Kustra Date: Wed, 2 Feb 2022 13:25:16 +0100 Subject: [PATCH 3/3] Updated glpi version requirement. --- setup.php | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/setup.php b/setup.php index 8196e80..3aa2620 100755 --- a/setup.php +++ b/setup.php @@ -49,28 +49,8 @@ function plugin_version_fpsoftware() 'author' => 'Future Processing', 'license' => 'GPLv2+', 'homepage' => 'http://www.future-processing.com', - 'minGlpiVersion' => '0.84' - ); // For compatibility / no install in version < 0.80 -} - -/** - * Blocking a specific version of GLPI. - * GLPI constantly evolving in terms of functions of the heart, it is advisable - * to create a plugin blocking the current version, quite to modify the function - * to a later version of GLPI. In this example, the plugin will be operational - * with the 0.84 and 0.85 versions of GLPI. - * - * @return boolean - */ -function plugin_fpsoftware_check_prerequisites() -{ - if (version_compare(GLPI_VERSION, '0.84', '<') || version_compare(GLPI_VERSION, '10.0.0', '>=')) { - echo "This plugin requires GLPI >= 0.84 and GLPI >= 10.0.0"; - - return false; - } - - return true; + 'minGlpiVersion' => '9.5' + ); } /**