From 5eee3ade4a3ea65cc033b8dbcc85115515c47926 Mon Sep 17 00:00:00 2001 From: "edu.corral" Date: Thu, 3 Nov 2022 11:36:28 +0100 Subject: [PATCH] ent 9722 expired license --- pandora_console/include/auth/mysql.php | 39 +++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 13bd0428a0..0912be1a3d 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -809,7 +809,44 @@ function update_user(string $id_user, array $values) return false; } - return db_process_sql_update('tusuario', $values, ['id_user' => $id_user]); + $output = db_process_sql_update('tusuario', $values, ['id_user' => $id_user]); + + if (isset($values['is_admin']) === true && (bool) $values['is_admin'] === true) { + // Administrator user must be activated in all notifications sections. + $notificationSources = db_get_all_rows_filter('tnotification_source', [], 'id'); + + foreach ($notificationSources as $notification) { + $user_source = db_get_value_filter( + 'id_source', + 'tnotification_source_user', + [ + 'id_source' => $notification['id'], + 'id_user' => $id_user, + ] + ); + + if ($user_source !== false) { + @db_process_sql_update( + 'tnotification_source_user', + ['enabled' => 1], + [ + 'id_source' => $notification['id'], + 'id_user' => $id_user, + ] + ); + } else { + @db_process_sql_insert( + 'tnotification_source_user', + [ + 'id_source' => $notification['id'], + 'id_user' => $id_user, + ] + ); + } + } + } + + return $output; }