diff --git a/hook.php b/hook.php index 09ef3a1..475b964 100644 --- a/hook.php +++ b/hook.php @@ -225,9 +225,7 @@ function plugin_webapplications_uninstall() "glpi_dropdowntranslations"]; foreach ($tables_glpi as $table_glpi) { - $DB->doQuery("DELETE - FROM `$table_glpi` - WHERE `itemtype` LIKE 'PluginWebapplications%'"); + $DB->delete($table_glpi, ['itemtype' => ['LIKE' => 'PluginWebapplications%']]); } //Delete rights associated with the plugin diff --git a/inc/profile.class.php b/inc/profile.class.php index bad23c2..ac1fb67 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -269,10 +269,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->doQuery($query); + $DB->update('glpi_profilerights', ['rights' => self::translateARight($profile_data[$old])], [ + 'name' => $new, + 'profiles_id' => $profiles_id + ]); } } } @@ -297,17 +297,22 @@ 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_webapplications%'" - ) as $prof - ) { + + $it = $DB->request([ + 'FROM' => 'glpi_profilerights', + 'WHERE' => [ + 'profiles_id' => $_SESSION['glpiactiveprofile']['id'], + 'name' => ['LIKE', '%plugin_webapplications%'] + ] + ]); + foreach ($it as $prof) { if (isset($_SESSION['glpiactiveprofile'])) { $_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights']; }