From 4d65d4e84b7f5319e85c7266462150d4c5538910 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 5 Jul 2018 18:25:42 -0500 Subject: [PATCH] Admin: Add multiple-selection enabling/disabling of users --- main/admin/user_list.php | 73 ++++++++++++++++++++++++++---- main/lang/english/trad4all.inc.php | 14 +++++- main/lang/french/trad4all.inc.php | 10 +++- main/lang/spanish/trad4all.inc.php | 12 +++++ 4 files changed, 97 insertions(+), 12 deletions(-) diff --git a/main/admin/user_list.php b/main/admin/user_list.php index 9016330806..9fa2e9ec30 100755 --- a/main/admin/user_list.php +++ b/main/admin/user_list.php @@ -439,7 +439,7 @@ function get_number_of_users() * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) - * + * @return array Users list * @see SortableTable#get_table_data($from) */ function get_user_data($from, $number_of_items, $column, $direction) @@ -512,6 +512,8 @@ function email_filter($email) * Returns a mailto-link. * * @param string $email An email-address + * @param array $params Deprecated + * @param array $row * * @return string HTML-code with a mailto-link */ @@ -528,6 +530,7 @@ function user_filter($name, $params, $row) * @param array Row of elements to alter * * @return string Some HTML-code with modify-buttons + * @throws Exception */ function modify_filter($user_id, $url_params, $row) { @@ -808,9 +811,7 @@ function active_filter($active, $params, $row) /** * Instead of displaying the integer of the status, we give a translation for the status. - * * @param int $status - * * @return string translation * * @version march 2008 @@ -887,17 +888,17 @@ if (!empty($action)) { case 'delete': if (api_is_platform_admin()) { $number_of_selected_users = count($_POST['id']); - $number_of_deleted_users = 0; + $number_of_affected_users = 0; if (is_array($_POST['id'])) { foreach ($_POST['id'] as $index => $user_id) { if ($user_id != $_user['user_id']) { if (UserManager::delete_user($user_id)) { - $number_of_deleted_users++; + $number_of_affected_users++; } } } } - if ($number_of_selected_users == $number_of_deleted_users) { + if ($number_of_selected_users == $number_of_affected_users) { $message = Display::return_message( get_lang('SelectedUsersDeleted'), 'confirmation' @@ -910,6 +911,58 @@ if (!empty($action)) { } } break; + case 'disable': + if (api_is_platform_admin()) { + $number_of_selected_users = count($_POST['id']); + $number_of_affected_users = 0; + if (is_array($_POST['id'])) { + foreach ($_POST['id'] as $index => $user_id) { + if ($user_id != $_user['user_id']) { + if (UserManager::disable($user_id)) { + $number_of_affected_users++; + } + } + } + } + if ($number_of_selected_users == $number_of_affected_users) { + $message = Display::return_message( + get_lang('SelectedUsersDisabled'), + 'confirmation' + ); + } else { + $message = Display::return_message( + get_lang('SomeUsersNotDisabled'), + 'error' + ); + } + } + break; + case 'enable': + if (api_is_platform_admin()) { + $number_of_selected_users = count($_POST['id']); + $number_of_affected_users = 0; + if (is_array($_POST['id'])) { + foreach ($_POST['id'] as $index => $user_id) { + if ($user_id != $_user['user_id']) { + if (UserManager::enable($user_id)) { + $number_of_affected_users++; + } + } + } + } + if ($number_of_selected_users == $number_of_affected_users) { + $message = Display::return_message( + get_lang('SelectedUsersEnabled'), + 'confirmation' + ); + } else { + $message = Display::return_message( + get_lang('SomeUsersNotEnabled'), + 'error' + ); + } + } + break; } Security::clear_token(); } @@ -1053,13 +1106,15 @@ $table->set_column_filter(8, 'active_filter'); $table->set_column_filter(10, 'modify_filter'); // Only show empty actions bar if delete users has been blocked +$actionsList = []; if (api_is_platform_admin() && !api_get_configuration_value('deny_delete_users') ) { - $table->set_form_actions(['delete' => get_lang('DeleteFromPlatform')]); -} else { - $table->set_form_actions(['none' => get_lang('NoActionAvailable')]); + $actionsList['delete'] = get_lang('DeleteFromPlatform'); } +$actionsList['disable'] = get_lang('Disable'); +$actionsList['enable'] = get_lang('Enable'); +$table->set_form_actions($actionsList); $table_result = $table->return_table(); $extra_search_options = ''; diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 312a157e2f..31d998327c 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -1776,7 +1776,7 @@ $UserLocked = "User locked"; $UserUnlocked = "User unlocked"; $CannotDeleteUser = "You cannot delete this user"; $SelectedUsersDeleted = "Selected users deleted"; -$SomeUsersNotDeleted = "Some users has not been deleted"; +$SomeUsersNotDeleted = "Some of the selected users have not been deleted. We recommend you confirm which, by using the advanced search."; $ExternalAuthentication = "External authentification"; $RegistrationDate = "Registration date"; $UserUpdated = "User updated"; @@ -8146,4 +8146,16 @@ $DocumentAutoLaunch = "Auto-launch for documents"; $RedirectToTheDocumentList = "Redirect to the document list"; $TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToTheExerciseList = "The exercises auto-launch feature configuration is enabled. Learners will be automatically redirected to exercise list."; $PostedExpirationDate = "Posted deadline for sending the work (Visible to the learner)"; +$BossAlertMsgSentToUserXTitle = "Follow up message about student %s"; +$BossAlertUserXSentMessageToUserYWithLinkZ = "Hi,

+ +User %s sent a follow up message about student %s.

+ +The message can be seen here %s"; +$include_services = "Include services"; +$culqi_enable = "Enable culqi"; +$SelectedUsersDisabled = "The selected users have all been disabled"; +$SomeUsersNotDisabled = "Some of the selected users have not been disabled. We recommend you confirm which, by using the advanced search."; +$SelectedUsersEnabled = "The selected users were all enabled."; +$SomeUsersNotEnabled = "Some of the selected users have not been enabled. We recommend you confirm which, by using the advanced search."; ?> \ No newline at end of file diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php index 41800f42e8..53ca606ea2 100644 --- a/main/lang/french/trad4all.inc.php +++ b/main/lang/french/trad4all.inc.php @@ -8084,9 +8084,15 @@ $RedirectToTheDocumentList = "Rediriger vers la liste des documents"; $TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToTheExerciseList = "La fonctionnalité d'auto-démarrage des exercices est activée. Les apprenants seront automatiquement redirigés vers la liste des exercices."; $PostedExpirationDate = "Date limite affichée d'envoi du travail (visible par l'apprenant)"; $BossAlertMsgSentToUserXTitle = "Message de suivi concernant l'apprenant %s"; -$BossAlertUserXSentMessageToUserYWithLinkZ = "Bonjour, +$BossAlertUserXSentMessageToUserYWithLinkZ = "Bonjour,

-L'utilisateur %s a envoyé un message de suivi concernant l'apprenant %s. +L'utilisateur %s a envoyé un message de suivi concernant l'apprenant %s.

Le message est visible sur %s"; +$include_services = "Inclure les services"; +$culqi_enable = "Activé culqi"; +$SelectedUsersDisabled = "Les utilisateurs sélectionnés ont tous été désactivés."; +$SomeUsersNotDisabled = "Certains des utilisateurs sélectionnés n'ont pas été supprimés. Nous vous recommandons de confirmer lesquels en utilisant la recherche avancée."; +$SelectedUsersEnabled = "Tous les utilisateurs sélectionnés ont été activés."; +$SomeUsersNotEnabled = "Certains des utilisateurs sélectionnés n'ont pas été activés. Nous vous recommandons de confirmer lesquels en utilisant la recherche avancée."; ?> \ No newline at end of file diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index 1a521615ff..786d7b1187 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -8170,4 +8170,16 @@ $DocumentAutoLaunch = "Lanzamiento automático para documentos"; $RedirectToTheDocumentList = "Redirigir a la lista de documentos"; $TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToTheExerciseList = "La funcionalidad de lanzamiento automático de ejercicios está activada. Los estudiantes serán automáticamente redirigidos a la lista de ejercicios."; $PostedExpirationDate = "Fecha límite publicada para enviar el trabajo (visible para el alumno)"; +$BossAlertMsgSentToUserXTitle = "Mensaje de seguimiento sobre alumno %s"; +$BossAlertUserXSentMessageToUserYWithLinkZ = "Hola,

+ +El usuario %s ha enviado un mensaje de seguimiento sobre el alumno %s.

+ +El mensaje se puede ver en %s"; +$include_services = "Incluir los servicios"; +$culqi_enable = "Activar Culqi"; +$SelectedUsersDisabled = "Todos los usuarios seleccionados han sido desactivado."; +$SomeUsersNotDisabled = "Algunos de los usuarios seleccionados no han sido desactivado. Le recomendamos una verificación adicional a través de la búsqueda avanzada."; +$SelectedUsersEnabled = "Todos los usuarios seleccionados han sido activado."; +$SomeUsersNotEnabled = "Algunos de los usuarios seleccionados no han sido activado. Le recomendamos una verificación adicional a través de la búsqueda avanzada."; ?> \ No newline at end of file