2009-09-25 04:02:46 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows you to edit a users profile
|
|
|
|
*
|
|
|
|
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2014-02-18 10:12:42 +13:00
|
|
|
* @package core_user
|
2009-09-25 04:02:46 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('../config.php');
|
|
|
|
require_once($CFG->libdir.'/gdlib.php');
|
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
|
|
|
require_once($CFG->dirroot.'/user/editadvanced_form.php');
|
|
|
|
require_once($CFG->dirroot.'/user/editlib.php');
|
|
|
|
require_once($CFG->dirroot.'/user/profile/lib.php');
|
2013-08-19 17:03:39 +08:00
|
|
|
require_once($CFG->dirroot.'/user/lib.php');
|
2016-09-28 09:23:32 +01:00
|
|
|
require_once($CFG->dirroot.'/webservice/lib.php');
|
2009-09-25 04:02:46 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
$id = optional_param('id', $USER->id, PARAM_INT); // User id; -1 if creating new user.
|
|
|
|
$course = optional_param('course', SITEID, PARAM_INT); // Course id (defaults to Site).
|
2015-05-07 14:30:48 +08:00
|
|
|
$returnto = optional_param('returnto', null, PARAM_ALPHA); // Code determining where to return to after save.
|
2009-09-25 04:02:46 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
$PAGE->set_url('/user/editadvanced.php', array('course' => $course, 'id' => $id));
|
2009-09-25 04:02:46 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
$course = $DB->get_record('course', array('id' => $course), '*', MUST_EXIST);
|
2010-04-19 06:30:30 +00:00
|
|
|
|
2009-09-25 04:02:46 +00:00
|
|
|
if (!empty($USER->newadminuser)) {
|
2014-10-20 12:52:35 +13:00
|
|
|
// Ignore double clicks, we must finish all operations before cancelling request.
|
|
|
|
ignore_user_abort(true);
|
|
|
|
|
2009-09-25 04:02:46 +00:00
|
|
|
$PAGE->set_course($SITE);
|
2009-12-16 18:00:58 +00:00
|
|
|
$PAGE->set_pagelayout('maintenance');
|
2009-09-25 04:02:46 +00:00
|
|
|
} else {
|
2013-10-19 12:22:12 +02:00
|
|
|
if ($course->id == SITEID) {
|
|
|
|
require_login();
|
|
|
|
$PAGE->set_context(context_system::instance());
|
|
|
|
} else {
|
|
|
|
require_login($course);
|
|
|
|
}
|
2010-04-19 06:30:30 +00:00
|
|
|
$PAGE->set_pagelayout('admin');
|
2021-10-04 16:57:04 +02:00
|
|
|
$PAGE->add_body_class('limitedwidth');
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($course->id == SITEID) {
|
2014-02-18 10:12:42 +13:00
|
|
|
$coursecontext = context_system::instance(); // SYSTEM context.
|
2009-09-25 04:02:46 +00:00
|
|
|
} else {
|
2014-02-18 10:12:42 +13:00
|
|
|
$coursecontext = context_course::instance($course->id); // Course context.
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2012-07-26 11:38:02 +08:00
|
|
|
$systemcontext = context_system::instance();
|
2009-09-25 04:02:46 +00:00
|
|
|
|
|
|
|
if ($id == -1) {
|
2014-02-18 10:12:42 +13:00
|
|
|
// Creating new user.
|
2010-09-21 08:27:29 +00:00
|
|
|
$user = new stdClass();
|
2009-09-25 04:02:46 +00:00
|
|
|
$user->id = -1;
|
2010-06-06 14:06:30 +00:00
|
|
|
$user->auth = 'manual';
|
2009-09-25 04:02:46 +00:00
|
|
|
$user->confirmed = 1;
|
|
|
|
$user->deleted = 0;
|
2015-03-28 18:46:16 +13:00
|
|
|
$user->timezone = '99';
|
2010-04-19 06:30:30 +00:00
|
|
|
require_capability('moodle/user:create', $systemcontext);
|
|
|
|
admin_externalpage_setup('addnewuser', '', array('id' => -1));
|
2022-02-24 12:53:46 +05:30
|
|
|
$PAGE->set_primary_active_tab('siteadminnode');
|
|
|
|
$PAGE->navbar->add(get_string('addnewuser', 'moodle'), $PAGE->url);
|
2009-09-25 04:02:46 +00:00
|
|
|
} else {
|
2014-02-18 10:12:42 +13:00
|
|
|
// Editing existing user.
|
2009-09-25 04:02:46 +00:00
|
|
|
require_capability('moodle/user:update', $systemcontext);
|
2014-02-18 10:12:42 +13:00
|
|
|
$user = $DB->get_record('user', array('id' => $id), '*', MUST_EXIST);
|
2012-07-26 11:38:02 +08:00
|
|
|
$PAGE->set_context(context_user::instance($user->id));
|
2015-03-19 10:59:27 +08:00
|
|
|
$PAGE->navbar->includesettingsbase = true;
|
2013-10-19 12:22:12 +02:00
|
|
|
if ($user->id != $USER->id) {
|
2010-07-13 02:35:31 +00:00
|
|
|
$PAGE->navigation->extend_for_user($user);
|
2013-10-19 12:22:12 +02:00
|
|
|
} else {
|
|
|
|
if ($node = $PAGE->navigation->find('myprofile', navigation_node::TYPE_ROOTNODE)) {
|
|
|
|
$node->force_open();
|
|
|
|
}
|
2010-07-13 02:35:31 +00:00
|
|
|
}
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Remote users cannot be edited.
|
2009-09-25 04:02:46 +00:00
|
|
|
if ($user->id != -1 and is_mnet_remote_user($user)) {
|
|
|
|
redirect($CFG->wwwroot . "/user/view.php?id=$id&course={$course->id}");
|
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
if ($user->id != $USER->id and is_siteadmin($user) and !is_siteadmin($USER)) { // Only admins may edit other admins.
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('useradmineditadmin');
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
if (isguestuser($user->id)) { // The real guest user can not be edited.
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('guestnoeditprofileother');
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2009-09-25 04:02:46 +00:00
|
|
|
if ($user->deleted) {
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->heading(get_string('userdeleted'));
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Load user preferences.
|
2009-09-25 04:02:46 +00:00
|
|
|
useredit_load_preferences($user);
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Load custom profile fields data.
|
2009-09-25 04:02:46 +00:00
|
|
|
profile_load_data($user);
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// User interests.
|
2015-09-05 23:09:19 +08:00
|
|
|
$user->interests = core_tag_tag::get_item_tags_array('core', 'user', $id);
|
2009-09-25 04:02:46 +00:00
|
|
|
|
2009-11-04 06:14:06 +00:00
|
|
|
if ($user->id !== -1) {
|
2012-07-26 11:38:02 +08:00
|
|
|
$usercontext = context_user::instance($user->id);
|
2011-07-12 10:45:55 +08:00
|
|
|
$editoroptions = array(
|
|
|
|
'maxfiles' => EDITOR_UNLIMITED_FILES,
|
|
|
|
'maxbytes' => $CFG->maxbytes,
|
|
|
|
'trusttext' => false,
|
|
|
|
'forcehttps' => false,
|
|
|
|
'context' => $usercontext
|
|
|
|
);
|
|
|
|
|
2010-07-03 13:37:13 +00:00
|
|
|
$user = file_prepare_standard_editor($user, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
|
2009-11-04 06:14:06 +00:00
|
|
|
} else {
|
2010-03-31 07:41:31 +00:00
|
|
|
$usercontext = null;
|
2014-02-18 10:12:42 +13:00
|
|
|
// This is a new user, we don't want to add files here.
|
2011-07-28 11:27:07 +08:00
|
|
|
$editoroptions = array(
|
2014-02-18 10:12:42 +13:00
|
|
|
'maxfiles' => 0,
|
|
|
|
'maxbytes' => 0,
|
|
|
|
'trusttext' => false,
|
|
|
|
'forcehttps' => false,
|
2011-07-28 11:27:07 +08:00
|
|
|
'context' => $coursecontext
|
|
|
|
);
|
2009-11-04 06:14:06 +00:00
|
|
|
}
|
|
|
|
|
2012-06-13 17:27:17 +08:00
|
|
|
// Prepare filemanager draft area.
|
|
|
|
$draftitemid = 0;
|
|
|
|
$filemanagercontext = $editoroptions['context'];
|
|
|
|
$filemanageroptions = array('maxbytes' => $CFG->maxbytes,
|
|
|
|
'subdirs' => 0,
|
|
|
|
'maxfiles' => 1,
|
2020-08-11 14:50:06 +02:00
|
|
|
'accepted_types' => 'optimised_image');
|
2012-06-13 17:27:17 +08:00
|
|
|
file_prepare_draft_area($draftitemid, $filemanagercontext->id, 'user', 'newicon', 0, $filemanageroptions);
|
|
|
|
$user->imagefile = $draftitemid;
|
2014-02-18 10:12:42 +13:00
|
|
|
// Create form.
|
2015-05-07 14:30:48 +08:00
|
|
|
$userform = new user_editadvanced_form(new moodle_url($PAGE->url, array('returnto' => $returnto)), array(
|
2012-06-13 17:27:17 +08:00
|
|
|
'editoroptions' => $editoroptions,
|
2012-05-15 21:53:09 +04:00
|
|
|
'filemanageroptions' => $filemanageroptions,
|
2015-03-28 18:46:16 +13:00
|
|
|
'user' => $user));
|
2009-09-25 04:02:46 +00:00
|
|
|
|
2018-02-08 11:14:37 +00:00
|
|
|
|
|
|
|
// Deciding where to send the user back in most cases.
|
|
|
|
if ($returnto === 'profile') {
|
|
|
|
if ($course->id != SITEID) {
|
|
|
|
$returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
|
|
|
|
} else {
|
|
|
|
$returnurl = new moodle_url('/user/profile.php', array('id' => $user->id));
|
|
|
|
}
|
2022-12-30 17:10:42 +07:00
|
|
|
} else if ($user->id === -1) {
|
|
|
|
$returnurl = new moodle_url("/admin/user.php");
|
2018-02-08 11:14:37 +00:00
|
|
|
} else {
|
|
|
|
$returnurl = new moodle_url('/user/preferences.php', array('userid' => $user->id));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($userform->is_cancelled()) {
|
|
|
|
redirect($returnurl);
|
|
|
|
} else if ($usernew = $userform->get_data()) {
|
2014-05-23 11:40:31 +08:00
|
|
|
$usercreated = false;
|
2009-09-25 04:02:46 +00:00
|
|
|
|
|
|
|
if (empty($usernew->auth)) {
|
2014-02-18 10:12:42 +13:00
|
|
|
// User editing self.
|
2009-09-25 04:02:46 +00:00
|
|
|
$authplugin = get_auth_plugin($user->auth);
|
2014-02-18 10:12:42 +13:00
|
|
|
unset($usernew->auth); // Can not change/remove.
|
2009-09-25 04:02:46 +00:00
|
|
|
} else {
|
|
|
|
$authplugin = get_auth_plugin($usernew->auth);
|
2007-07-31 08:09:46 +00:00
|
|
|
}
|
2010-06-06 14:06:30 +00:00
|
|
|
|
|
|
|
$usernew->timemodified = time();
|
2013-07-01 09:16:59 +12:00
|
|
|
$createpassword = false;
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2009-09-25 04:02:46 +00:00
|
|
|
if ($usernew->id == -1) {
|
|
|
|
unset($usernew->id);
|
2013-07-01 09:16:59 +12:00
|
|
|
$createpassword = !empty($usernew->createpassword);
|
2013-06-30 11:10:17 +02:00
|
|
|
unset($usernew->createpassword);
|
2010-07-03 13:37:13 +00:00
|
|
|
$usernew = file_postupdate_standard_editor($usernew, 'description', $editoroptions, null, 'user', 'profile', null);
|
2014-02-18 10:12:42 +13:00
|
|
|
$usernew->mnethostid = $CFG->mnet_localhost_id; // Always local user.
|
2010-02-03 04:25:20 +00:00
|
|
|
$usernew->confirmed = 1;
|
|
|
|
$usernew->timecreated = time();
|
2013-12-04 18:00:23 +08:00
|
|
|
if ($authplugin->is_internal()) {
|
|
|
|
if ($createpassword or empty($usernew->newpassword)) {
|
|
|
|
$usernew->password = '';
|
|
|
|
} else {
|
|
|
|
$usernew->password = hash_internal_user_password($usernew->newpassword);
|
|
|
|
}
|
2013-06-30 11:10:17 +02:00
|
|
|
} else {
|
2013-12-04 18:00:23 +08:00
|
|
|
$usernew->password = AUTH_PASSWORD_NOT_CACHED;
|
2013-06-30 11:10:17 +02:00
|
|
|
}
|
2014-05-23 11:40:31 +08:00
|
|
|
$usernew->id = user_create_user($usernew, false, false);
|
2013-12-04 18:00:23 +08:00
|
|
|
|
|
|
|
if (!$authplugin->is_internal() and $authplugin->can_change_password() and !empty($usernew->newpassword)) {
|
|
|
|
if (!$authplugin->user_update_password($usernew, $usernew->newpassword)) {
|
|
|
|
// Do not stop here, we need to finish user creation.
|
2021-03-03 11:11:23 +02:00
|
|
|
debugging(get_string('cannotupdatepasswordonextauth', 'error', $usernew->auth), DEBUG_NONE);
|
2013-12-04 18:00:23 +08:00
|
|
|
}
|
|
|
|
}
|
2014-05-23 11:40:31 +08:00
|
|
|
$usercreated = true;
|
2009-09-25 04:02:46 +00:00
|
|
|
} else {
|
2010-07-03 13:37:13 +00:00
|
|
|
$usernew = file_postupdate_standard_editor($usernew, 'description', $editoroptions, $usercontext, 'user', 'profile', 0);
|
2013-08-19 17:03:39 +08:00
|
|
|
// Pass a true old $user here.
|
|
|
|
if (!$authplugin->user_update($user, $usernew)) {
|
|
|
|
// Auth update failed.
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('cannotupdateuseronexauth', '', '', $user->auth);
|
2007-01-25 18:02:48 +00:00
|
|
|
}
|
2014-05-23 11:40:31 +08:00
|
|
|
user_update_user($usernew, false, false);
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Set new password if specified.
|
2009-09-25 04:02:46 +00:00
|
|
|
if (!empty($usernew->newpassword)) {
|
|
|
|
if ($authplugin->can_change_password()) {
|
2014-02-18 10:12:42 +13:00
|
|
|
if (!$authplugin->user_update_password($usernew, $usernew->newpassword)) {
|
2022-04-12 09:38:41 +05:30
|
|
|
throw new \moodle_exception('cannotupdatepasswordonextauth', '', '', $usernew->auth);
|
2007-01-25 00:04:02 +00:00
|
|
|
}
|
2014-02-18 10:12:42 +13:00
|
|
|
unset_user_preference('create_password', $usernew); // Prevent cron from generating the password.
|
2014-10-22 14:11:11 +13:00
|
|
|
|
|
|
|
if (!empty($CFG->passwordchangelogout)) {
|
|
|
|
// We can use SID of other user safely here because they are unique,
|
|
|
|
// the problem here is we do not want to logout admin here when changing own password.
|
|
|
|
\core\session\manager::kill_user_sessions($usernew->id, session_id());
|
|
|
|
}
|
2016-09-28 09:23:32 +01:00
|
|
|
if (!empty($usernew->signoutofotherservices)) {
|
|
|
|
webservice::delete_user_ws_tokens($usernew->id);
|
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
}
|
|
|
|
}
|
2012-01-03 13:18:06 +01:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Force logout if user just suspended.
|
2012-01-03 13:18:06 +01:00
|
|
|
if (isset($usernew->suspended) and $usernew->suspended and !$user->suspended) {
|
2013-09-08 08:38:52 +02:00
|
|
|
\core\session\manager::kill_user_sessions($user->id);
|
2012-01-03 13:18:06 +01:00
|
|
|
}
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2012-07-26 11:38:02 +08:00
|
|
|
$usercontext = context_user::instance($usernew->id);
|
2008-09-05 11:02:48 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Update preferences.
|
2009-09-25 04:02:46 +00:00
|
|
|
useredit_update_user_preference($usernew);
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Update tags.
|
2015-09-05 23:09:19 +08:00
|
|
|
if (empty($USER->newadminuser) && isset($usernew->interests)) {
|
2009-09-25 04:02:46 +00:00
|
|
|
useredit_update_interests($usernew, $usernew->interests);
|
|
|
|
}
|
2007-07-31 08:09:46 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Update user picture.
|
2013-03-22 16:51:18 +01:00
|
|
|
if (empty($USER->newadminuser)) {
|
2015-10-15 19:34:58 +11:00
|
|
|
core_user::update_picture($usernew, $filemanageroptions);
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Update mail bounces.
|
2009-09-25 04:02:46 +00:00
|
|
|
useredit_update_bounces($user, $usernew);
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Update forum track preference.
|
2009-09-25 04:02:46 +00:00
|
|
|
useredit_update_trackforums($user, $usernew);
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Save custom profile fields data.
|
2009-09-25 04:02:46 +00:00
|
|
|
profile_save_data($usernew);
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Reload from db.
|
|
|
|
$usernew = $DB->get_record('user', array('id' => $usernew->id));
|
2009-08-10 05:50:10 +00:00
|
|
|
|
2014-06-05 13:41:20 +08:00
|
|
|
if ($createpassword) {
|
|
|
|
setnew_password_and_mail($usernew);
|
|
|
|
unset_user_preference('create_password', $usernew);
|
|
|
|
set_user_preference('auth_forcepasswordchange', 1, $usernew);
|
|
|
|
}
|
|
|
|
|
2014-05-23 11:40:31 +08:00
|
|
|
// Trigger update/create event, after all fields are stored.
|
|
|
|
if ($usercreated) {
|
|
|
|
\core\event\user_created::create_from_userid($usernew->id)->trigger();
|
|
|
|
} else {
|
|
|
|
\core\event\user_updated::create_from_userid($usernew->id)->trigger();
|
|
|
|
}
|
|
|
|
|
2009-09-25 04:02:46 +00:00
|
|
|
if ($user->id == $USER->id) {
|
2014-02-18 10:12:42 +13:00
|
|
|
// Override old $USER session variable.
|
2009-09-25 04:02:46 +00:00
|
|
|
foreach ((array)$usernew as $variable => $value) {
|
2013-09-23 21:15:59 +02:00
|
|
|
if ($variable === 'description' or $variable === 'password') {
|
|
|
|
// These are not set for security nad perf reasons.
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-25 04:02:46 +00:00
|
|
|
$USER->$variable = $value;
|
|
|
|
}
|
2014-02-18 10:12:42 +13:00
|
|
|
// Preload custom fields.
|
2010-07-25 21:00:59 +00:00
|
|
|
profile_load_custom_fields($USER);
|
|
|
|
|
2009-09-25 04:02:46 +00:00
|
|
|
if (!empty($USER->newadminuser)) {
|
|
|
|
unset($USER->newadminuser);
|
2014-02-18 10:12:42 +13:00
|
|
|
// Apply defaults again - some of them might depend on admin user info, backup, roles, etc.
|
2014-10-20 12:52:35 +13:00
|
|
|
admin_apply_default_settings(null, false);
|
|
|
|
// Admin account is fully configured - set flag here in case the redirect does not work.
|
|
|
|
unset_config('adminsetuppending');
|
2014-02-18 10:12:42 +13:00
|
|
|
// Redirect to admin/ to continue with installation.
|
2009-09-25 04:02:46 +00:00
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/");
|
2014-10-20 12:52:35 +13:00
|
|
|
} else if (empty($SITE->fullname)) {
|
|
|
|
// Somebody double clicked when editing admin user during install.
|
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/");
|
2007-03-14 07:51:53 +00:00
|
|
|
} else {
|
2020-12-15 14:55:38 +07:00
|
|
|
redirect($returnurl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
|
2007-01-25 00:04:02 +00:00
|
|
|
}
|
2022-11-18 18:36:13 +07:00
|
|
|
} else if ($returnto === 'profile') {
|
|
|
|
\core\session\manager::gc(); // Remove stale sessions.
|
|
|
|
redirect($returnurl, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
|
2009-09-25 04:02:46 +00:00
|
|
|
} else {
|
2013-09-08 08:38:52 +02:00
|
|
|
\core\session\manager::gc(); // Remove stale sessions.
|
2020-12-15 14:55:38 +07:00
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/user.php", get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
|
2007-01-25 00:04:02 +00:00
|
|
|
}
|
2014-02-18 10:12:42 +13:00
|
|
|
// Never reached..
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Display page header.
|
2009-09-25 04:02:46 +00:00
|
|
|
if ($user->id == -1 or ($user->id != $USER->id)) {
|
|
|
|
if ($user->id == -1) {
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header();
|
2007-01-25 00:04:02 +00:00
|
|
|
} else {
|
2015-04-17 11:35:05 +12:00
|
|
|
$streditmyprofile = get_string('editmyprofile');
|
2009-09-25 04:02:46 +00:00
|
|
|
$userfullname = fullname($user, true);
|
2015-03-16 13:13:07 +08:00
|
|
|
$PAGE->set_heading($userfullname);
|
2023-08-03 16:29:13 +08:00
|
|
|
$coursename = $course->id !== SITEID ? "$course->shortname" : '';
|
|
|
|
$PAGE->set_title("$streditmyprofile: $userfullname" . moodle_page::TITLE_SEPARATOR . $coursename);
|
2015-03-16 13:13:07 +08:00
|
|
|
echo $OUTPUT->header();
|
2009-09-25 04:02:46 +00:00
|
|
|
echo $OUTPUT->heading($userfullname);
|
|
|
|
}
|
|
|
|
} else if (!empty($USER->newadminuser)) {
|
|
|
|
$strinstallation = get_string('installation', 'install');
|
|
|
|
$strprimaryadminsetup = get_string('primaryadminsetup');
|
|
|
|
|
|
|
|
$PAGE->navbar->add($strprimaryadminsetup);
|
|
|
|
$PAGE->set_title($strinstallation);
|
|
|
|
$PAGE->set_heading($strinstallation);
|
|
|
|
$PAGE->set_cacheable(false);
|
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->box(get_string('configintroadmin', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
|
|
|
|
echo '<br />';
|
|
|
|
} else {
|
|
|
|
$streditmyprofile = get_string('editmyprofile');
|
|
|
|
$strparticipants = get_string('participants');
|
|
|
|
$strnewuser = get_string('newuser');
|
|
|
|
$userfullname = fullname($user, true);
|
|
|
|
|
|
|
|
$PAGE->set_title("$course->shortname: $streditmyprofile");
|
2015-03-16 13:13:07 +08:00
|
|
|
$PAGE->set_heading($userfullname);
|
2009-09-25 04:02:46 +00:00
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2015-03-27 16:17:30 +08:00
|
|
|
echo $OUTPUT->heading($streditmyprofile);
|
2009-09-25 04:02:46 +00:00
|
|
|
}
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Finally display THE form.
|
2009-09-25 04:02:46 +00:00
|
|
|
$userform->display();
|
2007-01-25 00:04:02 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// And proper footer.
|
2009-09-25 04:02:46 +00:00
|
|
|
echo $OUTPUT->footer();
|