diff --git a/hook.php b/hook.php index 208d595..f5a24e9 100644 --- a/hook.php +++ b/hook.php @@ -329,7 +329,7 @@ function plugin_accounts_uninstall() "glpi_plugin_accounts_notificationstates"]; foreach ($tables as $table) { - $DB->query("DROP TABLE IF EXISTS `$table`;"); + $DB->dropTable($table); } //old versions @@ -347,7 +347,7 @@ function plugin_accounts_uninstall() "glpi_plugin_accounts_profiles"]; foreach ($tables as $table) { - $DB->query("DROP TABLE IF EXISTS `$table`;"); + $DB->dropTable($table); } $notif = new Notification(); @@ -401,18 +401,20 @@ function plugin_accounts_uninstall() "glpi_impactitems"]; foreach ($tables_glpi as $table_glpi) { - $DB->query("DELETE FROM `$table_glpi` - WHERE `itemtype` = 'PluginAccountsAccount' - OR `itemtype` = 'PluginAccountsHelpdesk' - OR `itemtype` = 'PluginAccountsGroup' - OR `itemtype` = 'PluginAccountsAccountState' - OR `itemtype` = 'PluginAccountsAccountType' ;"); + $DB->delete($table_glpi, ['itemtype' => ['LIKE' => 'PluginAccounts%']]); } - $DB->query("DELETE - FROM `glpi_impactrelations` - WHERE `itemtype_source` IN ('PluginAccountsAccount') - OR `itemtype_impacted` IN ('PluginAccountsAccount')"); + + $DB->delete('glpi_impactrelations', [ + 'OR' => [ + [ + 'itemtype_source' => ['PluginAccountsAccount'], + ], + [ + 'itemtype_impacted' => ['PluginAccountsAccount'], + ], + ] + ]); if (class_exists('PluginDatainjectionModel')) { PluginDatainjectionModel::clean(['itemtype' => 'PluginAccountsAccount']); diff --git a/inc/account.class.php b/inc/account.class.php index cc6e367..c5238c6 100644 --- a/inc/account.class.php +++ b/inc/account.class.php @@ -287,7 +287,7 @@ public function rawSearchOptions() 'table' => 'glpi_users', 'field' => 'name', 'linkfield' => 'users_id_tech', - 'name' => __('Technician in charge of the hardware'), + 'name' => __('Technician in charge'), 'datatype' => 'dropdown', 'right' => 'interface' ]; @@ -297,7 +297,7 @@ public function rawSearchOptions() 'table' => 'glpi_groups', 'field' => 'completename', 'linkfield' => 'groups_id_tech', - 'name' => __('Group in charge of the hardware'), + 'name' => __('Group in charge'), 'condition' => ['`is_assign`' => 1], 'datatype' => 'dropdown' ]; @@ -675,7 +675,7 @@ public function showForm($ID, $options = []) Html::showDateField("date_creation", ['value' => $this->fields["date_creation"]]); echo ""; - echo "" . __('Technician in charge of the hardware') . ""; + echo "" . __('Technician in charge') . ""; echo ""; User::dropdown(['name' => "users_id_tech", 'value' => $this->fields["users_id_tech"], @@ -694,7 +694,7 @@ public function showForm($ID, $options = []) Html::showDateField("date_expiration", ['value' => $this->fields["date_expiration"]]); echo ""; - echo "" . __('Group in charge of the hardware') . ""; + echo "" . __('Group in charge') . ""; Group::dropdown(['name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'condition' => ['is_assign' => 1]]); diff --git a/inc/notificationstate.class.php b/inc/notificationstate.class.php index 27e15da..6b40186 100644 --- a/inc/notificationstate.class.php +++ b/inc/notificationstate.class.php @@ -183,7 +183,6 @@ public function showNotificationForm($target) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); - Html::closeForm(); echo ""; } } diff --git a/inc/notificationtargetaccount.class.php b/inc/notificationtargetaccount.class.php index a94a8a1..19d67d2 100644 --- a/inc/notificationtargetaccount.class.php +++ b/inc/notificationtargetaccount.class.php @@ -58,8 +58,8 @@ public function getEvents() { public function addAdditionalTargets($event = '') { $this->addTarget(self::ACCOUNT_USER, __('Affected User', 'accounts')); $this->addTarget(self::ACCOUNT_GROUP, __('Affected Group', 'accounts')); - $this->addTarget(self::ACCOUNT_TECHUSER, __('Technician in charge of the hardware')); - $this->addTarget(self::ACCOUNT_TECHGROUP, __('Group in charge of the hardware')); + $this->addTarget(self::ACCOUNT_TECHUSER, __('Technician in charge')); + $this->addTarget(self::ACCOUNT_TECHGROUP, __('Group in charge')); } /** @@ -181,10 +181,10 @@ public function addDataForTemplate($event, $options = []) { $this->data['##account.groups##'] = Dropdown::getDropdownName('glpi_groups', $this->obj->getField('groups_id')); - $this->data['##lang.account.userstech##'] = __('Technician in charge of the hardware'); + $this->data['##lang.account.userstech##'] = __('Technician in charge'); $this->data['##account.userstech##'] = $dbu->getUserName($this->obj->getField("users_id_tech")); - $this->data['##lang.account.groupstech##'] = __('Group in charge of the hardware'); + $this->data['##lang.account.groupstech##'] = __('Group in charge'); $this->data['##account.groupstech##'] = Dropdown::getDropdownName('glpi_groups', $this->obj->getField('groups_id_tech')); @@ -225,8 +225,8 @@ public function addDataForTemplate($event, $options = []) { $this->data['##lang.account.login##'] = __('Login'); $this->data['##lang.account.users##'] = __('Affected User', 'accounts'); $this->data['##lang.account.groups##'] = __('Affected Group', 'accounts'); - $this->data['##lang.account.userstech##'] = __('Technician in charge of the hardware'); - $this->data['##lang.account.groupstech##'] = __('Group in charge of the hardware'); + $this->data['##lang.account.userstech##'] = __('Technician in charge'); + $this->data['##lang.account.groupstech##'] = __('Group in charge'); $this->data['##lang.account.location##'] = __('Location'); $this->data['##lang.account.others##'] = __('Others'); $this->data['##lang.account.datecreation##'] = __('Creation date'); @@ -275,8 +275,8 @@ function getTags() { 'account.login' => __('Login'), 'account.users' => __('Affected User', 'accounts'), 'account.groups' => __('Affected Group', 'accounts'), - 'account.userstech' => __('Technician in charge of the hardware'), - 'account.groupstech' => __('Group in charge of the hardware'), + 'account.userstech' => __('Technician in charge'), + 'account.groupstech' => __('Group in charge'), 'account.location' => __('Location'), 'account.others' => __('Others'), 'account.datecreation' => __('Creation date'), diff --git a/inc/profile.class.php b/inc/profile.class.php index 569bde0..bf71e41 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -278,10 +278,11 @@ public static function migrateOneProfile($profiles_id) return true; } - foreach ($DB->request( - 'glpi_plugin_accounts_profiles', - "`profiles_id`='$profiles_id'" - ) as $profile_data) { + $it = $DB->request([ + 'FROM' => 'glpi_plugin_accounts_profiles', + 'WHERE' => ['profiles_id' => $profiles_id] + ]); + foreach ($it as $profile_data) { $matching = ['accounts' => 'plugin_accounts', 'all_users' => 'plugin_accounts_see_all_users', 'my_groups' => 'plugin_accounts_my_groups', @@ -289,10 +290,10 @@ public static function migrateOneProfile($profiles_id) $current_rights = ProfileRight::getProfileRights($profiles_id, array_values($matching)); foreach ($matching as $old => $new) { if (!isset($current_rights[$old])) { - $query = "UPDATE `glpi_profilerights` - SET `rights`='" . self::translateARight($profile_data[$old]) . "' - WHERE `name`='$new' AND `profiles_id`='$profiles_id'"; - $DB->query($query); + $DB->update('glpi_profilerights', ['rights' => self::translateARight($profile_data[$old])], [ + 'name' => $new, + 'profiles_id' => $profiles_id + ]); } } } @@ -317,13 +318,21 @@ public static function initProfile() } //Migration old rights in new ones - foreach ($DB->request("SELECT `id` FROM `glpi_profiles`") as $prof) { + $it = $DB->request([ + 'SELECT' => ['id'], + 'FROM' => 'glpi_profiles' + ]); + foreach ($it as $prof) { self::migrateOneProfile($prof['id']); } - foreach ($DB->request("SELECT * - FROM `glpi_profilerights` - WHERE `profiles_id`='" . $_SESSION['glpiactiveprofile']['id'] . "' - AND `name` LIKE '%plugin_accounts%'") as $prof) { + $it = $DB->request([ + 'FROM' => 'glpi_profilerights', + 'WHERE' => [ + 'profiles_id' => $_SESSION['glpiactiveprofile']['id'], + 'name' => ['LIKE', '%plugin_accounts%'] + ] + ]); + foreach ($it as $prof) { if (isset($_SESSION['glpiactiveprofile'])) { $_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights']; } diff --git a/setup.php b/setup.php index 1804d62..9197ab1 100644 --- a/setup.php +++ b/setup.php @@ -135,7 +135,7 @@ function plugin_version_accounts() 'version' => PLUGIN_ACCOUNTS_VERSION, 'oldname' => 'compte', 'license' => 'GPLv2+', - 'author' => "Infotel, Franck Waechter", + 'author' => "Infotel, Franck Waechter", 'homepage' => 'https://github.com/InfotelGLPI/accounts', 'requirements' => [ 'glpi' => [