|
|
|
@ -419,136 +419,128 @@ if ($form->validate()) { |
|
|
|
|
|
|
|
|
|
$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
|
|
|
|
|
|
|
|
if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
|
|
|
$error_drh = true; |
|
|
|
|
} else { |
|
|
|
|
$picture_element = $form->getElement('picture'); |
|
|
|
|
$picture = $picture_element->getValue(); |
|
|
|
|
|
|
|
|
|
$picture_uri = $user_data['picture_uri']; |
|
|
|
|
if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
|
|
|
$picture_uri = UserManager::deleteUserPicture($user_id); |
|
|
|
|
} elseif (!empty($picture['name'])) { |
|
|
|
|
$picture_uri = UserManager::update_user_picture( |
|
|
|
|
$user_id, |
|
|
|
|
$_FILES['picture']['name'], |
|
|
|
|
$_FILES['picture']['tmp_name'], |
|
|
|
|
$user['picture_crop_result'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lastname = $user['lastname']; |
|
|
|
|
$firstname = $user['firstname']; |
|
|
|
|
$password = $user['password']; |
|
|
|
|
$auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source']; |
|
|
|
|
$official_code = $user['official_code']; |
|
|
|
|
$email = $user['email']; |
|
|
|
|
$phone = $user['phone']; |
|
|
|
|
$username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
|
|
|
$status = (int) $user['status']; |
|
|
|
|
$platform_admin = 0; |
|
|
|
|
// Only platform admin can change user status to admin. |
|
|
|
|
if (api_is_platform_admin()) { |
|
|
|
|
$platform_admin = (int) $user['platform_admin']; |
|
|
|
|
} |
|
|
|
|
$picture_element = $form->getElement('picture'); |
|
|
|
|
$picture = $picture_element->getValue(); |
|
|
|
|
|
|
|
|
|
$picture_uri = $user_data['picture_uri']; |
|
|
|
|
if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
|
|
|
$picture_uri = UserManager::deleteUserPicture($user_id); |
|
|
|
|
} elseif (!empty($picture['name'])) { |
|
|
|
|
$picture_uri = UserManager::update_user_picture( |
|
|
|
|
$user_id, |
|
|
|
|
$_FILES['picture']['name'], |
|
|
|
|
$_FILES['picture']['tmp_name'], |
|
|
|
|
$user['picture_crop_result'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$send_mail = (int) $user['send_mail']; |
|
|
|
|
$reset_password = (int) $user['reset_password']; |
|
|
|
|
$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
|
|
|
$language = $user['language']; |
|
|
|
|
$address = isset($user['address']) ? $user['address'] : null; |
|
|
|
|
$lastname = $user['lastname']; |
|
|
|
|
$firstname = $user['firstname']; |
|
|
|
|
$password = $user['password']; |
|
|
|
|
$auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source']; |
|
|
|
|
$official_code = $user['official_code']; |
|
|
|
|
$email = $user['email']; |
|
|
|
|
$phone = $user['phone']; |
|
|
|
|
$username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
|
|
|
$status = (int) $user['status']; |
|
|
|
|
$platform_admin = 0; |
|
|
|
|
// Only platform admin can change user status to admin. |
|
|
|
|
if (api_is_platform_admin()) { |
|
|
|
|
$platform_admin = (int) $user['platform_admin']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$expiration_date = null; |
|
|
|
|
if (!$user_data['platform_admin'] && $user['radio_expiration_date'] == '1') { |
|
|
|
|
$expiration_date = $user['expiration_date']; |
|
|
|
|
} |
|
|
|
|
$send_mail = (int) $user['send_mail']; |
|
|
|
|
$reset_password = (int) $user['reset_password']; |
|
|
|
|
$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
|
|
|
$language = $user['language']; |
|
|
|
|
$address = isset($user['address']) ? $user['address'] : null; |
|
|
|
|
|
|
|
|
|
$active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
|
|
|
$expiration_date = null; |
|
|
|
|
if (!$user_data['platform_admin'] && $user['radio_expiration_date'] == '1') { |
|
|
|
|
$expiration_date = $user['expiration_date']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 |
|
|
|
|
if ($platform_admin == 1) { |
|
|
|
|
$status = COURSEMANAGER; |
|
|
|
|
} |
|
|
|
|
$active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
|
|
|
|
|
|
|
|
if (api_get_setting('login_is_email') === 'true') { |
|
|
|
|
$username = $email; |
|
|
|
|
} |
|
|
|
|
//If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 |
|
|
|
|
if ($platform_admin == 1) { |
|
|
|
|
$status = COURSEMANAGER; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$template = isset($user['email_template_option']) ? $user['email_template_option'] : []; |
|
|
|
|
if (api_get_setting('login_is_email') === 'true') { |
|
|
|
|
$username = $email; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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, |
|
|
|
|
$reset_password, |
|
|
|
|
$address, |
|
|
|
|
$template |
|
|
|
|
); |
|
|
|
|
$template = isset($user['email_template_option']) ? $user['email_template_option'] : []; |
|
|
|
|
|
|
|
|
|
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, |
|
|
|
|
$reset_password, |
|
|
|
|
$address, |
|
|
|
|
$template |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$studentBossListSent = isset($user['student_boss']) ? $user['student_boss'] : []; |
|
|
|
|
UserManager::subscribeUserToBossList( |
|
|
|
|
$user_id, |
|
|
|
|
$studentBossListSent, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
$studentBossListSent = isset($user['student_boss']) ? $user['student_boss'] : []; |
|
|
|
|
UserManager::subscribeUserToBossList( |
|
|
|
|
$user_id, |
|
|
|
|
$studentBossListSent, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (api_get_setting('openid_authentication') === 'true' && !empty($user['openid'])) { |
|
|
|
|
$up = UserManager::update_openid($user_id, $user['openid']); |
|
|
|
|
} |
|
|
|
|
if (api_get_setting('openid_authentication') === 'true' && !empty($user['openid'])) { |
|
|
|
|
$up = UserManager::update_openid($user_id, $user['openid']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$currentUserId = api_get_user_id(); |
|
|
|
|
if ($user_id != $currentUserId) { |
|
|
|
|
$userObj = api_get_user_entity($user_id); |
|
|
|
|
if ($platform_admin == 1) { |
|
|
|
|
UserManager::addUserAsAdmin($userObj); |
|
|
|
|
} else { |
|
|
|
|
UserManager::removeUserAdmin($userObj); |
|
|
|
|
} |
|
|
|
|
$currentUserId = api_get_user_id(); |
|
|
|
|
if ($user_id != $currentUserId) { |
|
|
|
|
$userObj = api_get_user_entity($user_id); |
|
|
|
|
if ($platform_admin == 1) { |
|
|
|
|
UserManager::addUserAsAdmin($userObj); |
|
|
|
|
} else { |
|
|
|
|
UserManager::removeUserAdmin($userObj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// It updates course relation type as EX-LEARNER if project name (extra field from user_edition_extra_field_to_check) is changed |
|
|
|
|
if (false !== api_get_configuration_value('user_edition_extra_field_to_check')) { |
|
|
|
|
$extraToCheck = api_get_configuration_value('user_edition_extra_field_to_check'); |
|
|
|
|
if (isset($user['extra_'.$extraToCheck])) { |
|
|
|
|
$extraValueToCheck = $user['extra_'.$extraToCheck]; |
|
|
|
|
UserManager::updateCourseRelationTypeExLearner($user_id, $extraValueToCheck); |
|
|
|
|
} |
|
|
|
|
// It updates course relation type as EX-LEARNER if project name (extra field from user_edition_extra_field_to_check) is changed |
|
|
|
|
if (false !== api_get_configuration_value('user_edition_extra_field_to_check')) { |
|
|
|
|
$extraToCheck = api_get_configuration_value('user_edition_extra_field_to_check'); |
|
|
|
|
if (isset($user['extra_'.$extraToCheck])) { |
|
|
|
|
$extraValueToCheck = $user['extra_'.$extraToCheck]; |
|
|
|
|
UserManager::updateCourseRelationTypeExLearner($user_id, $extraValueToCheck); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('user'); |
|
|
|
|
$extraFieldValue->saveFieldValues($user); |
|
|
|
|
$userInfo = api_get_user_info($user_id); |
|
|
|
|
$message = get_lang('UserUpdated').': '.Display::url( |
|
|
|
|
$userInfo['complete_name_with_username'], |
|
|
|
|
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id |
|
|
|
|
); |
|
|
|
|
$extraFieldValue = new ExtraFieldValue('user'); |
|
|
|
|
$extraFieldValue->saveFieldValues($user); |
|
|
|
|
$userInfo = api_get_user_info($user_id); |
|
|
|
|
$message = get_lang('UserUpdated').': '.Display::url( |
|
|
|
|
$userInfo['complete_name_with_username'], |
|
|
|
|
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$user_id |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
Session::erase('system_timezone'); |
|
|
|
|
Session::erase('system_timezone'); |
|
|
|
|
|
|
|
|
|
Display::addFlash(Display::return_message($message, 'normal', false)); |
|
|
|
|
header('Location: user_list.php'); |
|
|
|
|
exit(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($error_drh) { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('StatusCanNotBeChangedToHumanResourcesManager'), 'error')); |
|
|
|
|
Display::addFlash(Display::return_message($message, 'normal', false)); |
|
|
|
|
header('Location: user_list.php'); |
|
|
|
|
exit(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$actions = [ |
|
|
|
|