diff --git a/CHANGELOG.md b/CHANGELOG.md index 73d05ca..2b7346c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.1] - 2021-02-16 + +### Added + +- New "Switch Authentication" sub-section to "Users". +- New Fields in "Edit User". + ## [0.3.0] - 2021-02-15 ### Added @@ -175,7 +182,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 _Initial major release.._ -[unreleased]: https://github.com/ManuelGil/alternate-admin/compare/v0.3.0...HEAD +[unreleased]: https://github.com/ManuelGil/alternate-admin/compare/v0.3.1...HEAD +[0.3.1]: https://github.com/ManuelGil/alternate-admin/compare/v0.3.0...v0.3.1 [0.3.0]: https://github.com/ManuelGil/alternate-admin/compare/v0.2.3...v0.3.0 [0.2.3]: https://github.com/ManuelGil/alternate-admin/compare/v0.2.2...v0.2.3 [0.2.2]: https://github.com/ManuelGil/alternate-admin/compare/v0.2.1...v0.2.2 diff --git a/app/App.php b/app/App.php index 6ea59d0..2a6f4c0 100644 --- a/app/App.php +++ b/app/App.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/config/Config.php b/app/config/Config.php index 1c6542e..1b2398d 100644 --- a/app/config/Config.php +++ b/app/config/Config.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/ActivityController.php b/app/controllers/ActivityController.php index c427ce0..8c83acb 100644 --- a/app/controllers/ActivityController.php +++ b/app/controllers/ActivityController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php index 37a9565..b3d9945 100644 --- a/app/controllers/AdminController.php +++ b/app/controllers/AdminController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php index 251e604..d670fda 100644 --- a/app/controllers/BaseController.php +++ b/app/controllers/BaseController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/CourseController.php b/app/controllers/CourseController.php index e73a887..093d3a8 100644 --- a/app/controllers/CourseController.php +++ b/app/controllers/CourseController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/EnrollmentController.php b/app/controllers/EnrollmentController.php index 1b89df1..45a6c2a 100644 --- a/app/controllers/EnrollmentController.php +++ b/app/controllers/EnrollmentController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 01/25/2021 $ + * @version $Revision: 0.3.1 $ $Date: 01/25/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/MainController.php b/app/controllers/MainController.php index 44af3b9..4cd08ce 100644 --- a/app/controllers/MainController.php +++ b/app/controllers/MainController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 9395e61..e760977 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -27,7 +27,7 @@ * * Problem: Add more function to tradiccional admin. * @author $Author: Manuel Gil. $ - * @version $Revision: 0.3.0 $ $Date: 02/15/2021 $ + * @version $Revision: 0.3.1 $ $Date: 02/16/2021 $ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -279,106 +279,6 @@ public function getListCoursesUser() return $this->render('/users/list-courses-user.mustache', $params); } - /** - * This method load the 'suspend-user' route.
- * post: access to GET method. - */ - public function getSuspendUser() - { - // Imports Config and Current User. - global $CFG, $USER; - - // Parsing the users. - $users = addslashes( - json_encode( - get_users_listing(), - JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT - ) - ); - - $params = array( - 'COMPANY' => COMPANY, - 'BASE_URL' => BASE_URL, - 'wwwroot' => $CFG->wwwroot, - 'USER' => $USER, - 'users' => $users - ); - - // Render template. - return $this->render('/users/suspend-user.mustache', $params); - } - - /** - * This method load the 'suspend-user' route.
- * post: access to POST method. - */ - public function postSuspendUser() - { - // Imports Config, Database and Current User. - global $CFG, $DB, $USER; - - // Define the count variables. - $successes = 0; - $failures = 0; - - if (isset($_POST['users'])) { - // Loop through the users. - foreach ($_POST['users'] as $userid) { - try { - $DB->set_field('user', 'suspended', '1', ['id' => $userid]); - - // Add one user to the count. - $successes++; - } catch (\Throwable $e) { - // Add one fault to the count. - $failures++; - } - } - } - - $message = ""; - - // Add a message with the number of hits. - if ($successes > 0) { - $message .= "
- - Well done! {$successes} users were suspended. -
"; - } - - // Add a message with the number of failures. - if ($failures > 0) { - $message .= "
- - Heads up! {$failures} users could not be suspended. -
"; - } - - // Parsing the users. - $users = addslashes( - json_encode( - get_users_listing(), - JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT - ) - ); - - $params = array( - 'COMPANY' => COMPANY, - 'BASE_URL' => BASE_URL, - 'wwwroot' => $CFG->wwwroot, - 'USER' => $USER, - 'users' => $users, - 'message' => $message - ); - - // Render template. - return $this->render('/users/suspend-user.mustache', $params); - } - /** * This method load the 'user-data' route.
* post: access to GET method.
@@ -453,13 +353,32 @@ public function getEditUser() ) ); + $countries = addslashes( + json_encode( + get_string_manager()->get_list_of_countries(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $choices = \core_date::get_list_of_timezones(); + $choices['99'] = get_string('serverlocaltime'); + + $timezones = addslashes( + json_encode( + $choices, + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + $params = array( 'COMPANY' => COMPANY, 'BASE_URL' => BASE_URL, 'wwwroot' => $CFG->wwwroot, 'USER' => $USER, 'users' => $users, - 'authplugins' => $authplugins + 'authplugins' => $authplugins, + 'countries' => $countries, + 'timezones' => $timezones ); // Render template. @@ -498,6 +417,21 @@ public function postEditUser() if (isset($_POST['email']) && !empty(trim($_POST['email']))) { $data->email = trim($_POST['email']); } + if (isset($_POST['maildisplay']) && !empty(trim($_POST['maildisplay']))) { + $data->maildisplay = trim($_POST['maildisplay']); + } + if (isset($_POST['moodlenetprofile']) && !empty(trim($_POST['moodlenetprofile']))) { + $data->moodlenetprofile = trim($_POST['moodlenetprofile']); + } + if (isset($_POST['city']) && !empty(trim($_POST['city']))) { + $data->city = trim($_POST['city']); + } + if (isset($_POST['country']) && !empty(trim($_POST['country']))) { + $data->country = trim($_POST['country']); + } + if (isset($_POST['timezone']) && !empty(trim($_POST['timezone']))) { + $data->timezone = trim($_POST['timezone']); + } if (isset($_POST['suspended'])) { $data->suspended = 1; } else { @@ -559,6 +493,23 @@ public function postEditUser() ) ); + $countries = addslashes( + json_encode( + get_string_manager()->get_list_of_countries(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $choices = \core_date::get_list_of_timezones(); + $choices['99'] = get_string('serverlocaltime'); + + $timezones = addslashes( + json_encode( + $choices, + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + $params = array( 'COMPANY' => COMPANY, 'BASE_URL' => BASE_URL, @@ -566,10 +517,228 @@ public function postEditUser() 'USER' => $USER, 'users' => $users, 'authplugins' => $authplugins, + 'countries' => $countries, + 'timezones' => $timezones, 'message' => $message ); // Render template. return $this->render('/users/edit-user.mustache', $params); } + + /** + * This method load the 'suspend-user' route.
+ * post: access to GET method. + */ + public function getSuspendUser() + { + // Imports Config and Current User. + global $CFG, $USER; + + // Parsing the users. + $users = addslashes( + json_encode( + get_users_listing(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $params = array( + 'COMPANY' => COMPANY, + 'BASE_URL' => BASE_URL, + 'wwwroot' => $CFG->wwwroot, + 'USER' => $USER, + 'users' => $users + ); + + // Render template. + return $this->render('/users/suspend-user.mustache', $params); + } + + /** + * This method load the 'suspend-user' route.
+ * post: access to POST method. + */ + public function postSuspendUser() + { + // Imports Config, Database and Current User. + global $CFG, $DB, $USER; + + // Define the count variables. + $successes = 0; + $failures = 0; + + if (isset($_POST['users'])) { + // Loop through the users. + foreach ($_POST['users'] as $userid) { + try { + $DB->set_field('user', 'suspended', '1', ['id' => $userid]); + + // Add one user to the count. + $successes++; + } catch (\Throwable $e) { + // Add one fault to the count. + $failures++; + } + } + } + + $message = ""; + + // Add a message with the number of hits. + if ($successes > 0) { + $message .= "
+ + Well done! {$successes} users were suspended. +
"; + } + + // Add a message with the number of failures. + if ($failures > 0) { + $message .= "
+ + Heads up! {$failures} users could not be suspended. +
"; + } + + // Parsing the users. + $users = addslashes( + json_encode( + get_users_listing(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $params = array( + 'COMPANY' => COMPANY, + 'BASE_URL' => BASE_URL, + 'wwwroot' => $CFG->wwwroot, + 'USER' => $USER, + 'users' => $users, + 'message' => $message + ); + + // Render template. + return $this->render('/users/suspend-user.mustache', $params); + } + + /** + * This method load the 'switch-authentication' route.
+ * post: access to GET method. + */ + public function getSwitchAuthentication() + { + // Imports Config and Current User. + global $CFG, $USER; + + // Parsing the users. + $users = addslashes( + json_encode( + get_users_listing(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $authplugins = addslashes( + json_encode( + get_enabled_auth_plugins(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $params = array( + 'COMPANY' => COMPANY, + 'BASE_URL' => BASE_URL, + 'wwwroot' => $CFG->wwwroot, + 'USER' => $USER, + 'users' => $users, + 'authplugins' => $authplugins + ); + + // Render template. + return $this->render('/users/switch-authentication.mustache', $params); + } + + /** + * This method load the 'switch-authentication' route.
+ * post: access to POST method. + */ + public function postSwitchAuthentication() + { + // Imports Config, Database and Current User. + global $CFG, $DB, $USER; + + // Define the count variables. + $successes = 0; + $failures = 0; + + if (isset($_POST['users'])) { + // Loop through the users. + foreach ($_POST['users'] as $userid) { + try { + $DB->set_field('user', 'auth', $_POST['auth'], ['id' => $userid]); + + // Add one user to the count. + $successes++; + } catch (\Throwable $e) { + // Add one fault to the count. + $failures++; + } + } + } + + $message = ""; + + // Add a message with the number of hits. + if ($successes > 0) { + $message .= "
+ + Well done! {$successes} users were updated. +
"; + } + + // Add a message with the number of failures. + if ($failures > 0) { + $message .= "
+ + Heads up! {$failures} users could not be updated. +
"; + } + + // Parsing the users. + $users = addslashes( + json_encode( + get_users_listing(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $authplugins = addslashes( + json_encode( + get_enabled_auth_plugins(), + JSON_HEX_AMP | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT + ) + ); + + $params = array( + 'COMPANY' => COMPANY, + 'BASE_URL' => BASE_URL, + 'wwwroot' => $CFG->wwwroot, + 'USER' => $USER, + 'users' => $users, + 'authplugins' => $authplugins, + 'message' => $message + ); + + // Render template. + return $this->render('/users/switch-authentication.mustache', $params); + } } diff --git a/app/views/users/edit-user.mustache b/app/views/users/edit-user.mustache index d611865..a66028c 100644 --- a/app/views/users/edit-user.mustache +++ b/app/views/users/edit-user.mustache @@ -43,7 +43,7 @@
- +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +