Skip to content

Commit

Permalink
Fix raw SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmr committed Nov 25, 2024
1 parent 38a2d73 commit 6530399
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
4 changes: 1 addition & 3 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 18 additions & 13 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);
}
}
}
Expand All @@ -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'];
}
Expand Down

0 comments on commit 6530399

Please sign in to comment.