Skip to content

Commit

Permalink
Fix raw SQL
Browse files Browse the repository at this point in the history
Other mins fixs
  • Loading branch information
tsmr committed Nov 25, 2024
1 parent 1b705eb commit 42edaf0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
8 changes: 2 additions & 6 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function plugin_activity_uninstall()
];

foreach ($tables as $table) {
$DB->query("DROP TABLE IF EXISTS `$table`;");
$DB->dropTable($table);
}

$tables_glpi = [
Expand All @@ -210,11 +210,7 @@ function plugin_activity_uninstall()
];

foreach ($tables_glpi as $table_glpi) {
$DB->query(
"DELETE
FROM `$table_glpi`
WHERE `itemtype` LIKE 'PluginActivity%'"
);
$DB->delete($table_glpi, ['itemtype' => ['LIKE' => 'PluginActivity%']]);
}

// Delete notifications
Expand Down
2 changes: 1 addition & 1 deletion inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function showForm ($ID, $options = []) {
'used' => $used_entities]);
echo "</td>";
// is_recursive
echo "<td>".__('Is recursive')."</td>";
echo "<td>".__('Is recursive', 'activity')."</td>";
echo "<td>";
Dropdown::showYesNo('is_recursive');
echo "</td>";
Expand Down
2 changes: 1 addition & 1 deletion inc/dashboard.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
along with Activity. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/

#[AllowDynamicProperties]
class PluginActivityDashboard extends CommonGLPI
{
public $widgets = [];
Expand Down
26 changes: 16 additions & 10 deletions inc/profile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,15 @@ public static function migrateOneProfile()
// Add or update rights
foreach ($matching as $old => $new) {
if (isset($used[$profile_data['profiles_id']][$new])) {
$query = "UPDATE `glpi_profilerights`
SET `rights`='".self::translateARight($profile_data[$old])."'
WHERE `name`='$new' AND `profiles_id`='".$profile_data['profiles_id']."'";
$DB->query($query);
$DB->update('glpi_profilerights', ['rights' => self::translateARight($profile_data[$old])], [
'name' => $new,
'profiles_id' => $profile_data['profiles_id']
]);
} else {
$query = "INSERT INTO `glpi_profilerights` (`profiles_id`, `name`, `rights`) VALUES ('".$profile_data['profiles_id']."', '$new', '".self::translateARight($profile_data[$old])."');";
$DB->query($query);
$DB->add('glpi_profilerights', ['rights' => self::translateARight($profile_data[$old])], [
'name' => $new,
'profiles_id' => $profile_data['profiles_id']
]);
}
}
}
Expand All @@ -250,10 +252,14 @@ public static function initProfile()
// Migration old rights in new ones
self::migrateOneProfile();

foreach ($DB->request("SELECT *
FROM `glpi_profilerights`
WHERE `profiles_id`='".$_SESSION['glpiactiveprofile']['id']."'
AND `name` LIKE '%plugin_activity%'") as $prof) {
$it = $DB->request([
'FROM' => 'glpi_profilerights',
'WHERE' => [
'profiles_id' => $_SESSION['glpiactiveprofile']['id'],
'name' => ['LIKE', '%plugin_activity%']
]
]);
foreach ($it as $prof) {
if (isset($_SESSION['glpiactiveprofile'])) {
$_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights'];
}
Expand Down

0 comments on commit 42edaf0

Please sign in to comment.