You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
535 lines
19 KiB
535 lines
19 KiB
15 years ago
|
<?php
|
||
|
/* For licensing terms, see /license.txt */
|
||
10 years ago
|
|
||
5 years ago
|
use ChamiloSession as Session;
|
||
|
|
||
18 years ago
|
/**
|
||
8 years ago
|
* @package chamilo.admin
|
||
7 years ago
|
*/
|
||
15 years ago
|
$cidReset = true;
|
||
8 years ago
|
require_once __DIR__.'/../inc/global.inc.php';
|
||
15 years ago
|
|
||
|
$this_section = SECTION_PLATFORM_ADMIN;
|
||
18 years ago
|
|
||
13 years ago
|
api_protect_admin_script(true);
|
||
18 years ago
|
|
||
13 years ago
|
$user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : intval($_POST['user_id']);
|
||
13 years ago
|
api_protect_super_admin($user_id, null, true);
|
||
|
$is_platform_admin = api_is_platform_admin() ? 1 : 0;
|
||
9 years ago
|
$userInfo = api_get_user_info($user_id);
|
||
|
|
||
18 years ago
|
$htmlHeadXtra[] = '
|
||
13 years ago
|
<script>
|
||
13 years ago
|
var is_platform_id = "'.$is_platform_admin.'";
|
||
12 years ago
|
|
||
13 years ago
|
function enable_expiration_date() {
|
||
8 years ago
|
document.user_edit.radio_expiration_date[0].checked=false;
|
||
|
document.user_edit.radio_expiration_date[1].checked=true;
|
||
18 years ago
|
}
|
||
17 years ago
|
|
||
15 years ago
|
function password_switch_radio_button(){
|
||
8 years ago
|
var input_elements = document.getElementsByTagName("input");
|
||
|
for (var i = 0; i < input_elements.length; i++) {
|
||
|
if(input_elements.item(i).name == "reset_password" && input_elements.item(i).value == "2") {
|
||
|
input_elements.item(i).checked = true;
|
||
|
}
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
17 years ago
|
function display_drh_list(){
|
||
13 years ago
|
var $radios = $("input:radio[name=platform_admin]");
|
||
8 years ago
|
if (document.getElementById("status_select").value=='.COURSEMANAGER.') {
|
||
13 years ago
|
if (is_platform_id == 1)
|
||
|
document.getElementById("id_platform_admin").style.display="block";
|
||
8 years ago
|
} else if (document.getElementById("status_select").value=='.STUDENT.') {
|
||
13 years ago
|
if (is_platform_id == 1)
|
||
|
document.getElementById("id_platform_admin").style.display="none";
|
||
13 years ago
|
$radios.filter("[value=0]").attr("checked", true);
|
||
8 years ago
|
} else {
|
||
13 years ago
|
if (is_platform_id == 1)
|
||
12 years ago
|
document.getElementById("id_platform_admin").style.display="none";
|
||
13 years ago
|
$radios.filter("[value=0]").attr("checked", true);
|
||
8 years ago
|
}
|
||
17 years ago
|
}
|
||
15 years ago
|
|
||
16 years ago
|
function show_image(image,width,height) {
|
||
8 years ago
|
width = parseInt(width) + 20;
|
||
|
height = parseInt(height) + 20;
|
||
|
window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \' , resizable=0\');
|
||
15 years ago
|
}
|
||
11 years ago
|
|
||
|
function confirmation(name) {
|
||
9 years ago
|
if (confirm("'.get_lang('AreYouSureToDeleteJS', '').' " + name + " ?")) {
|
||
11 years ago
|
document.forms["profile"].submit();
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
18 years ago
|
</script>';
|
||
|
|
||
7 years ago
|
//$htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
|
||
|
//$htmlHeadXtra[] = api_get_asset('cropper/dist/cropper.min.js');
|
||
5 years ago
|
$tool_name = get_lang('Edit user information');
|
||
18 years ago
|
|
||
5 years ago
|
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('Administration')];
|
||
|
$interbreadcrumb[] = ['url' => 'user_list.php', 'name' => get_lang('User list')];
|
||
18 years ago
|
|
||
18 years ago
|
$table_user = Database::get_main_table(TABLE_MAIN_USER);
|
||
|
$table_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
|
||
10 years ago
|
$sql = "SELECT u.*, a.user_id AS is_admin FROM $table_user u
|
||
10 years ago
|
LEFT JOIN $table_admin a ON a.user_id = u.id
|
||
|
WHERE u.id = '".$user_id."'";
|
||
15 years ago
|
$res = Database::query($sql);
|
||
15 years ago
|
if (Database::num_rows($res) != 1) {
|
||
10 years ago
|
header('Location: user_list.php');
|
||
|
exit;
|
||
18 years ago
|
}
|
||
15 years ago
|
|
||
|
$user_data = Database::fetch_array($res, 'ASSOC');
|
||
18 years ago
|
$user_data['platform_admin'] = is_null($user_data['is_admin']) ? 0 : 1;
|
||
|
$user_data['send_mail'] = 0;
|
||
|
$user_data['old_password'] = $user_data['password'];
|
||
15 years ago
|
//Convert the registration date of the user
|
||
13 years ago
|
|
||
10 years ago
|
$user_data['registration_date'] = api_get_local_time($user_data['registration_date']);
|
||
18 years ago
|
unset($user_data['password']);
|
||
17 years ago
|
|
||
18 years ago
|
// Create the form
|
||
10 years ago
|
$form = new FormValidator(
|
||
|
'user_edit',
|
||
|
'post',
|
||
9 years ago
|
api_get_self().'?user_id='.$user_id,
|
||
10 years ago
|
''
|
||
|
);
|
||
9 years ago
|
$form->addElement('header', $tool_name);
|
||
15 years ago
|
$form->addElement('hidden', 'user_id', $user_id);
|
||
18 years ago
|
|
||
15 years ago
|
if (api_is_western_name_order()) {
|
||
8 years ago
|
// Firstname
|
||
5 years ago
|
$form->addElement('text', 'firstname', get_lang('First name'));
|
||
8 years ago
|
$form->applyFilter('firstname', 'html_filter');
|
||
|
$form->applyFilter('firstname', 'trim');
|
||
5 years ago
|
$form->addRule('firstname', get_lang('Required field'), 'required');
|
||
8 years ago
|
// Lastname
|
||
5 years ago
|
$form->addElement('text', 'lastname', get_lang('Last name'));
|
||
8 years ago
|
$form->applyFilter('lastname', 'html_filter');
|
||
|
$form->applyFilter('lastname', 'trim');
|
||
5 years ago
|
$form->addRule('lastname', get_lang('Required field'), 'required');
|
||
15 years ago
|
} else {
|
||
8 years ago
|
// Lastname
|
||
5 years ago
|
$form->addElement('text', 'lastname', get_lang('Last name'));
|
||
8 years ago
|
$form->applyFilter('lastname', 'html_filter');
|
||
|
$form->applyFilter('lastname', 'trim');
|
||
5 years ago
|
$form->addRule('lastname', get_lang('Required field'), 'required');
|
||
8 years ago
|
// Firstname
|
||
5 years ago
|
$form->addElement('text', 'firstname', get_lang('First name'));
|
||
8 years ago
|
$form->applyFilter('firstname', 'html_filter');
|
||
|
$form->applyFilter('firstname', 'trim');
|
||
5 years ago
|
$form->addRule('firstname', get_lang('Required field'), 'required');
|
||
15 years ago
|
}
|
||
18 years ago
|
|
||
|
// Official code
|
||
5 years ago
|
$form->addElement('text', 'official_code', get_lang('Code'), ['size' => '40']);
|
||
15 years ago
|
$form->applyFilter('official_code', 'html_filter');
|
||
|
$form->applyFilter('official_code', 'trim');
|
||
18 years ago
|
|
||
5 years ago
|
// e-mail
|
||
|
$form->addElement('text', 'email', get_lang('e-mail'));
|
||
|
$form->addRule('email', get_lang('e-mailWrong'), 'email');
|
||
12 years ago
|
if (api_get_setting('registration', 'email') == 'true') {
|
||
5 years ago
|
$form->addRule('email', get_lang('e-mailWrong'), 'required');
|
||
12 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
if (api_get_setting('login_is_email') == 'true') {
|
||
5 years ago
|
$form->addRule('email', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
|
||
|
$form->addRule('email', get_lang('This login is already in use'), 'username_available', $user_data['username']);
|
||
13 years ago
|
}
|
||
18 years ago
|
|
||
|
// Phone
|
||
5 years ago
|
$form->addElement('text', 'phone', get_lang('Phone number'));
|
||
18 years ago
|
|
||
|
// Picture
|
||
8 years ago
|
$form->addFile(
|
||
|
'picture',
|
||
5 years ago
|
get_lang('Add image'),
|
||
7 years ago
|
['id' => 'picture', 'class' => 'picture-form', 'crop_image' => true, 'crop_ratio' => '1 / 1']
|
||
8 years ago
|
);
|
||
8 years ago
|
$allowed_picture_types = api_get_supported_image_extensions(false);
|
||
9 years ago
|
|
||
9 years ago
|
$form->addRule(
|
||
8 years ago
|
'picture',
|
||
5 years ago
|
get_lang('Only PNG, JPG or GIF images allowed').' ('.implode(',', $allowed_picture_types).')',
|
||
8 years ago
|
'filetype',
|
||
|
$allowed_picture_types
|
||
9 years ago
|
);
|
||
15 years ago
|
if (strlen($user_data['picture_uri']) > 0) {
|
||
5 years ago
|
$form->addElement('checkbox', 'delete_picture', '', get_lang('Remove picture'));
|
||
18 years ago
|
}
|
||
|
|
||
|
// Username
|
||
13 years ago
|
if (api_get_setting('login_is_email') != 'true') {
|
||
5 years ago
|
$form->addElement('text', 'username', get_lang('Login'), ['maxlength' => USERNAME_MAX_LENGTH]);
|
||
|
$form->addRule('username', get_lang('Required field'), 'required');
|
||
|
$form->addRule('username', sprintf(get_lang('The login needs to be maximum %s characters long'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
|
||
|
$form->addRule('username', get_lang('Only letters and numbers allowed'), 'username');
|
||
|
$form->addRule('username', get_lang('This login is already in use'), 'username_available', $user_data['username']);
|
||
13 years ago
|
}
|
||
18 years ago
|
|
||
9 years ago
|
if (isset($extAuthSource) && !empty($extAuthSource) && count($extAuthSource) > 0) {
|
||
|
$form->addLabel(
|
||
5 years ago
|
get_lang('External authentification'),
|
||
9 years ago
|
$userInfo['auth_source']
|
||
|
);
|
||
|
}
|
||
|
|
||
18 years ago
|
// Password
|
||
5 years ago
|
$form->addElement('radio', 'reset_password', get_lang('Password'), get_lang('Don\'t reset password'), 0);
|
||
13 years ago
|
$nb_ext_auth_source_added = 0;
|
||
10 years ago
|
if (isset($extAuthSource) && !empty($extAuthSource) && count($extAuthSource) > 0) {
|
||
7 years ago
|
$auth_sources = [];
|
||
10 years ago
|
foreach ($extAuthSource as $key => $info) {
|
||
10 years ago
|
// @todo : make uniform external authentication configuration (ex : cas and external_login ldap)
|
||
10 years ago
|
// Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS
|
||
|
// extAuthSource always on for CAS even if not activated
|
||
|
// same action for file user_add.php
|
||
|
if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) {
|
||
|
$auth_sources[$key] = $key;
|
||
|
$nb_ext_auth_source_added++;
|
||
|
}
|
||
|
}
|
||
|
if ($nb_ext_auth_source_added > 0) {
|
||
10 years ago
|
// @todo check the radio button for external authentification and select the external authentication in the menu
|
||
5 years ago
|
$group[] = $form->createElement('radio', 'reset_password', null, get_lang('External authentification').' ', 3);
|
||
10 years ago
|
$group[] = $form->createElement('select', 'auth_source', null, $auth_sources);
|
||
|
$group[] = $form->createElement('static', '', '', '<br />');
|
||
8 years ago
|
$form->addGroup($group, 'password', null, null, false);
|
||
10 years ago
|
}
|
||
18 years ago
|
}
|
||
5 years ago
|
$form->addElement('radio', 'reset_password', null, get_lang('Automatically generate a new password'), 1);
|
||
7 years ago
|
$group = [];
|
||
5 years ago
|
$group[] = $form->createElement('radio', 'reset_password', null, get_lang('Enter password'), 2);
|
||
9 years ago
|
$group[] = $form->createElement(
|
||
|
'password',
|
||
|
'password',
|
||
|
null,
|
||
7 years ago
|
['onkeydown' => 'javascript: password_switch_radio_button();']
|
||
9 years ago
|
);
|
||
8 years ago
|
|
||
8 years ago
|
$form->addGroup($group, 'password', null, null, false);
|
||
8 years ago
|
$form->addPasswordRule('password', 'password');
|
||
18 years ago
|
|
||
15 years ago
|
// Status
|
||
7 years ago
|
$status = [];
|
||
5 years ago
|
$status[COURSEMANAGER] = get_lang('Trainer');
|
||
10 years ago
|
$status[STUDENT] = get_lang('Learner');
|
||
5 years ago
|
$status[DRH] = get_lang('Human Resources Manager');
|
||
|
$status[SESSIONADMIN] = get_lang('Sessions administrator');
|
||
|
$status[STUDENT_BOSS] = get_lang('Student\'s superior');
|
||
10 years ago
|
$status[INVITEE] = get_lang('Invitee');
|
||
|
|
||
|
$form->addElement(
|
||
|
'select',
|
||
|
'status',
|
||
|
get_lang('Profile'),
|
||
|
$status,
|
||
7 years ago
|
[
|
||
10 years ago
|
'id' => 'status_select',
|
||
7 years ago
|
'onchange' => 'javascript: display_drh_list();',
|
||
7 years ago
|
]
|
||
10 years ago
|
);
|
||
17 years ago
|
|
||
12 years ago
|
$display = isset($user_data['status']) && ($user_data['status'] == STUDENT || (isset($_POST['status']) && $_POST['status'] == STUDENT)) ? 'block' : 'none';
|
||
15 years ago
|
|
||
18 years ago
|
// Platform admin
|
||
13 years ago
|
if (api_is_platform_admin()) {
|
||
7 years ago
|
$group = [];
|
||
8 years ago
|
$group[] = $form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1);
|
||
|
$group[] = $form->createElement('radio', 'platform_admin', null, get_lang('No'), 0);
|
||
15 years ago
|
|
||
8 years ago
|
$user_data['status'] == 1 ? $display = 'block' : $display = 'none';
|
||
15 years ago
|
|
||
8 years ago
|
$form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">');
|
||
5 years ago
|
$form->addGroup($group, 'admin', get_lang('Administration'), null, false);
|
||
8 years ago
|
$form->addElement('html', '</div>');
|
||
13 years ago
|
}
|
||
18 years ago
|
|
||
12 years ago
|
//Language
|
||
8 years ago
|
$form->addSelectLanguage('language', get_lang('Language'));
|
||
12 years ago
|
|
||
18 years ago
|
// Send email
|
||
7 years ago
|
$group = [];
|
||
10 years ago
|
$group[] = $form->createElement('radio', 'send_mail', null, get_lang('Yes'), 1);
|
||
|
$group[] = $form->createElement('radio', 'send_mail', null, get_lang('No'), 0);
|
||
5 years ago
|
$form->addGroup($group, 'mail', get_lang('Send mail to new user'), null, false);
|
||
18 years ago
|
|
||
11 years ago
|
// Registration User and Date
|
||
|
$creatorInfo = api_get_user_info($user_data['creator_id']);
|
||
5 years ago
|
$date = sprintf(get_lang('Create by <a href="%s">%s</a> on %s'), 'user_information.php?user_id='.$user_data['creator_id'], $creatorInfo['username'], $user_data['registration_date']);
|
||
|
$form->addElement('label', get_lang('Registration date'), $date);
|
||
11 years ago
|
|
||
15 years ago
|
if (!$user_data['platform_admin']) {
|
||
8 years ago
|
// Expiration Date
|
||
5 years ago
|
$form->addElement('radio', 'radio_expiration_date', get_lang('Expiration date'), get_lang('Never expires'), 0);
|
||
7 years ago
|
$group = [];
|
||
8 years ago
|
$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1);
|
||
7 years ago
|
$group[] = $form->createElement(
|
||
|
'DateTimePicker',
|
||
|
'expiration_date',
|
||
|
null,
|
||
7 years ago
|
['onchange' => 'javascript: enable_expiration_date();']
|
||
7 years ago
|
);
|
||
8 years ago
|
$form->addGroup($group, 'max_member_group', null, null, false);
|
||
|
|
||
5 years ago
|
// active account or inactive account
|
||
|
$form->addElement('radio', 'active', get_lang('Account'), get_lang('active'), 1);
|
||
|
$form->addElement('radio', 'active', '', get_lang('inactive'), 0);
|
||
18 years ago
|
}
|
||
9 years ago
|
$studentBossList = UserManager::getStudentBossList($user_data['user_id']);
|
||
|
|
||
|
$conditions = ['status' => STUDENT_BOSS];
|
||
|
$studentBoss = UserManager::get_user_list($conditions);
|
||
|
$studentBossToSelect = [];
|
||
|
|
||
|
if ($studentBoss) {
|
||
|
foreach ($studentBoss as $bossId => $userData) {
|
||
|
$bossInfo = api_get_user_info($userData['user_id']);
|
||
8 years ago
|
$studentBossToSelect[$bossInfo['user_id']] = $bossInfo['complete_name_with_username'];
|
||
9 years ago
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
if (!empty($studentBossList)) {
|
||
9 years ago
|
$studentBossList = array_column($studentBossList, 'boss_id');
|
||
|
}
|
||
|
|
||
|
$user_data['student_boss'] = array_values($studentBossList);
|
||
5 years ago
|
$form->addElement('advmultiselect', 'student_boss', get_lang('Superior (n+1)'), $studentBossToSelect);
|
||
17 years ago
|
|
||
|
// EXTRA FIELDS
|
||
10 years ago
|
$extraField = new ExtraField('user');
|
||
8 years ago
|
$returnParams = $extraField->addElements(
|
||
|
$form,
|
||
|
$user_data['user_id'],
|
||
|
[],
|
||
|
false,
|
||
|
false,
|
||
|
[],
|
||
|
[],
|
||
6 years ago
|
[],
|
||
|
false,
|
||
8 years ago
|
true
|
||
|
);
|
||
6 years ago
|
$jqueryReadyContent = $returnParams['jquery_ready_content'];
|
||
|
|
||
6 years ago
|
$allowEmailTemplate = api_get_configuration_value('mail_template_system');
|
||
|
if ($allowEmailTemplate) {
|
||
|
$form->addEmailTemplate(['user_edit_content.tpl']);
|
||
|
}
|
||
|
|
||
|
// the $jqueryReadyContent variable collects all functions that will be load in the
|
||
8 years ago
|
$htmlHeadXtra[] = '<script>
|
||
6 years ago
|
$(function () {
|
||
6 years ago
|
'.$jqueryReadyContent.'
|
||
12 years ago
|
});
|
||
|
</script>';
|
||
14 years ago
|
|
||
6 years ago
|
// Freeze user conditions, admin cannot updated them
|
||
|
$extraConditions = api_get_configuration_value('show_conditions_to_user');
|
||
|
|
||
|
if ($extraConditions && isset($extraConditions['conditions'])) {
|
||
|
$extraConditions = $extraConditions['conditions'];
|
||
|
foreach ($extraConditions as $condition) {
|
||
|
/** @var HTML_QuickForm_group $element */
|
||
|
$element = $form->getElement('extra_'.$condition['variable']);
|
||
|
if ($element) {
|
||
|
$element->freeze();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
18 years ago
|
// Submit button
|
||
10 years ago
|
$form->addButtonSave(get_lang('Save'));
|
||
10 years ago
|
|
||
18 years ago
|
// Set default values
|
||
15 years ago
|
$user_data['reset_password'] = 0;
|
||
|
$expiration_date = $user_data['expiration_date'];
|
||
13 years ago
|
|
||
10 years ago
|
if (empty($expiration_date)) {
|
||
8 years ago
|
$user_data['radio_expiration_date'] = 0;
|
||
|
$user_data['expiration_date'] = api_get_local_time();
|
||
15 years ago
|
} else {
|
||
8 years ago
|
$user_data['radio_expiration_date'] = 1;
|
||
|
$user_data['expiration_date'] = api_get_local_time($expiration_date);
|
||
18 years ago
|
}
|
||
|
$form->setDefaults($user_data);
|
||
|
|
||
15 years ago
|
$error_drh = false;
|
||
18 years ago
|
// Validate form
|
||
12 years ago
|
if ($form->validate()) {
|
||
8 years ago
|
$user = $form->getSubmitValues(1);
|
||
9 years ago
|
$reset_password = intval($user['reset_password']);
|
||
|
if ($reset_password == 2 && empty($user['password'])) {
|
||
5 years ago
|
Display::addFlash(Display::return_message(get_lang('The password is too short')));
|
||
9 years ago
|
header('Location: '.api_get_self().'?user_id='.$user_id);
|
||
|
exit();
|
||
|
}
|
||
|
|
||
8 years ago
|
$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
|
||
15 years ago
|
|
||
8 years ago
|
if ($user['status'] == DRH && $is_user_subscribed_in_course) {
|
||
|
$error_drh = true;
|
||
|
} else {
|
||
|
$picture_element = $form->getElement('picture');
|
||
|
$picture = $picture_element->getValue();
|
||
15 years ago
|
|
||
8 years ago
|
$picture_uri = $user_data['picture_uri'];
|
||
|
if (isset($user['delete_picture']) && $user['delete_picture']) {
|
||
6 years ago
|
$picture_uri = UserManager::deleteUserPicture($user_id);
|
||
8 years ago
|
} elseif (!empty($picture['name'])) {
|
||
10 years ago
|
$picture_uri = UserManager::update_user_picture(
|
||
|
$user_id,
|
||
|
$_FILES['picture']['name'],
|
||
9 years ago
|
$_FILES['picture']['tmp_name'],
|
||
8 years ago
|
$user['picture_crop_result']
|
||
10 years ago
|
);
|
||
8 years ago
|
}
|
||
15 years ago
|
|
||
8 years ago
|
$lastname = $user['lastname'];
|
||
|
$firstname = $user['firstname'];
|
||
13 years ago
|
$password = $user['password'];
|
||
10 years ago
|
$auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source'];
|
||
8 years ago
|
$official_code = $user['official_code'];
|
||
|
$email = $user['email'];
|
||
|
$phone = $user['phone'];
|
||
|
$username = isset($user['username']) ? $user['username'] : $userInfo['username'];
|
||
|
$status = intval($user['status']);
|
||
|
$platform_admin = intval($user['platform_admin']);
|
||
|
$send_mail = intval($user['send_mail']);
|
||
|
$reset_password = intval($user['reset_password']);
|
||
|
$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
|
||
|
$language = $user['language'];
|
||
8 years ago
|
$address = isset($user['address']) ? $user['address'] : null;
|
||
10 years ago
|
|
||
7 years ago
|
if (!$user_data['platform_admin'] && $user['radio_expiration_date'] == '1') {
|
||
10 years ago
|
$expiration_date = $user['expiration_date'];
|
||
8 years ago
|
} else {
|
||
|
$expiration_date = null;
|
||
|
}
|
||
12 years ago
|
|
||
8 years ago
|
$active = $user_data['platform_admin'] ? 1 : intval($user['active']);
|
||
13 years ago
|
|
||
|
//If the user is set to admin the status will be overwrite by COURSEMANAGER = 1
|
||
|
if ($platform_admin == 1) {
|
||
|
$status = COURSEMANAGER;
|
||
|
}
|
||
|
|
||
|
if (api_get_setting('login_is_email') == 'true') {
|
||
13 years ago
|
$username = $email;
|
||
|
}
|
||
10 years ago
|
|
||
6 years ago
|
$template = isset($user['email_template_option']) ? $user['email_template_option'] : [];
|
||
|
|
||
10 years ago
|
UserManager::update_user(
|
||
|
$user_id,
|
||
|
$firstname,
|
||
|
$lastname,
|
||
|
$username,
|
||
|
$password,
|
||
|
$auth_source,
|
||
|
$email,
|
||
|
$status,
|
||
|
$official_code,
|
||
|
$phone,
|
||
|
$picture_uri,
|
||
|
$expiration_date,
|
||
|
$active,
|
||
|
null,
|
||
|
$hr_dept_id,
|
||
|
null,
|
||
|
$language,
|
||
|
null,
|
||
|
$send_mail,
|
||
9 years ago
|
$reset_password,
|
||
6 years ago
|
$address,
|
||
|
$template
|
||
10 years ago
|
);
|
||
13 years ago
|
|
||
6 years ago
|
$studentBossListSent = isset($user['student_boss']) ? $user['student_boss'] : [];
|
||
6 years ago
|
UserManager::subscribeUserToBossList(
|
||
|
$user_id,
|
||
|
$studentBossListSent,
|
||
|
true
|
||
|
);
|
||
|
|
||
10 years ago
|
$currentUserId = api_get_user_id();
|
||
6 years ago
|
|
||
9 years ago
|
$userObj = api_get_user_entity($user_id);
|
||
8 years ago
|
|
||
9 years ago
|
UserManager::add_user_as_admin($userObj);
|
||
|
|
||
8 years ago
|
if ($user_id != $currentUserId) {
|
||
|
if ($platform_admin == 1) {
|
||
|
$userObj = api_get_user_entity($user_id);
|
||
9 years ago
|
UserManager::add_user_as_admin($userObj);
|
||
8 years ago
|
} else {
|
||
13 years ago
|
UserManager::remove_user_admin($user_id);
|
||
8 years ago
|
}
|
||
|
}
|
||
12 years ago
|
|
||
10 years ago
|
$extraFieldValue = new ExtraFieldValue('user');
|
||
|
$extraFieldValue->saveFieldValues($user);
|
||
7 years ago
|
$userInfo = api_get_user_info($user_id);
|
||
5 years ago
|
$message = get_lang('User updated').': '.Display::url(
|
||
7 years ago
|
$userInfo['complete_name_with_username'],
|
||
|
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id
|
||
|
);
|
||
10 years ago
|
|
||
5 years ago
|
Session::erase('system_timezone');
|
||
|
|
||
7 years ago
|
Display::addFlash(Display::return_message($message, 'normal', false));
|
||
|
header('Location: user_list.php');
|
||
8 years ago
|
exit();
|
||
|
}
|
||
18 years ago
|
}
|
||
|
|
||
15 years ago
|
if ($error_drh) {
|
||
5 years ago
|
Display::addFlash(Display::return_message(get_lang('The status of this user cannot be changed to human resources manager.'), 'error'));
|
||
15 years ago
|
}
|
||
|
|
||
7 years ago
|
$actions = [
|
||
|
Display::url(
|
||
|
Display::return_icon(
|
||
|
'info.png',
|
||
|
get_lang('Information'),
|
||
7 years ago
|
[],
|
||
7 years ago
|
ICON_SIZE_MEDIUM
|
||
|
),
|
||
|
api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$user_id
|
||
|
),
|
||
|
Display::url(
|
||
|
Display::return_icon(
|
||
|
'login_as.png',
|
||
5 years ago
|
get_lang('Login as'),
|
||
7 years ago
|
[],
|
||
|
ICON_SIZE_MEDIUM
|
||
|
),
|
||
|
api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::getTokenFromSession()
|
||
7 years ago
|
),
|
||
7 years ago
|
];
|
||
|
|
||
6 years ago
|
$content = Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL, $actions)]);
|
||
17 years ago
|
|
||
9 years ago
|
$bigImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG);
|
||
|
$normalImage = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL);
|
||
6 years ago
|
$content .= '<div class="row">';
|
||
9 years ago
|
$content .= '<div class="col-md-10">';
|
||
18 years ago
|
// Display form
|
||
10 years ago
|
$content .= $form->returnForm();
|
||
9 years ago
|
$content .= '</div>';
|
||
|
$content .= '<div class="col-md-2">';
|
||
|
$content .= '<a class="thumbnail expand-image" href="'.$bigImage.'" /><img src="'.$normalImage.'"></a>';
|
||
|
$content .= '</div>';
|
||
13 years ago
|
|
||
|
$tpl = new Template($tool_name);
|
||
|
$tpl->assign('content', $content);
|
||
10 years ago
|
$tpl->display_one_col_template();
|