本文整理汇总了PHP中UserManager::update_extra_field_value方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::update_extra_field_value方法的具体用法?PHP UserManager::update_extra_field_value怎么用?PHP UserManager::update_extra_field_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::update_extra_field_value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookCreateUser
/**
* Create a Drupal user when the Chamilo user is registered
* @param HookCreateUserEventInterface $hook The hook
*/
public function hookCreateUser(HookCreateUserEventInterface $hook)
{
$data = $hook->getEventData();
$drupalDomain = CreateDrupalUser::create()->get('drupal_domain');
$drupalDomain = rtrim($drupalDomain, '/') . '/';
if ($data['type'] === HOOK_EVENT_TYPE_POST) {
$return = $data['return'];
$originalPassword = $data['originalPassword'];
$userInfo = api_get_user_info($return);
$fields = array('name' => $userInfo['username'], 'pass' => $originalPassword, 'mail' => $userInfo['email'], 'status' => 1, 'init' => $userInfo['email']);
$extraFields = array('first_name' => $userInfo['firstname'], 'last_name' => $userInfo['lastname']);
$options = array('location' => $drupalDomain . 'sites/all/modules/chamilo/soap.php?wsdl', 'uri' => $drupalDomain);
$client = new SoapClient(null, $options);
$drupalUserId = false;
if (isset($_SESSION['ws_drupal_user_id'])) {
$drupalUserId = $_SESSION['ws_drupal_user_id'];
return true;
}
if ($drupalUserId === false) {
$drupalUserId = $client->addUser($fields, $extraFields);
}
if ($drupalUserId !== false) {
UserManager::update_extra_field_value($return, 'drupal_user_id', $drupalUserId);
}
}
}
示例2: setUserStatus
/**
* Set user chat status
* @param int 0 if disconnected, 1 if connected
*
* @return void
*/
public function setUserStatus($status)
{
UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status);
}
示例3: importStudents
/**
* @param string $file
* @param bool $moveFile
*/
private function importStudents($file, $moveFile = true)
{
$data = Import::csv_to_array($file);
/*
* Another users import.
Unique identifier: official code and username . ok
Password should never get updated. ok
If an update should need to occur (because it changed in the .csv),
we’ll want that logged. We will handle this manually in that case.
All other fields should be updateable, though passwords should of course not get updated. ok
If a user gets deleted (not there anymore),
He should be set inactive one year after the current date.
So I presume you’ll just update the expiration date.
We want to grant access to courses up to a year after deletion.
*/
if (!empty($data)) {
$language = $this->defaultLanguage;
$this->logger->addInfo(count($data) . " records found.");
foreach ($data as $row) {
$row = $this->cleanUserRow($row);
$user_id = UserManager::get_user_id_from_original_id($row['extra_' . $this->extraFieldIdNameList['user']], $this->extraFieldIdNameList['user']);
$userInfo = array();
$userInfoByOfficialCode = null;
if (!empty($user_id)) {
$userInfo = api_get_user_info($user_id);
$userInfoByOfficialCode = api_get_user_info_from_official_code($row['official_code']);
}
$expirationDate = api_get_utc_datetime(strtotime("+" . intval($this->expirationDateInUserCreation) . "years"));
if (empty($userInfo) && empty($userInfoByOfficialCode)) {
// Create user
$result = UserManager::create_user($row['firstname'], $row['lastname'], STUDENT, $row['email'], $row['username'], $row['password'], $row['official_code'], $language, $row['phone'], null, $row['auth_source'], $expirationDate, 1, 0, null, null, false);
if ($result) {
foreach ($row as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
UserManager::update_extra_field_value($result, substr($key, 6), $value);
}
}
$this->logger->addInfo("Students - User created: " . $row['username']);
} else {
$this->logger->addError("Students - User NOT created: " . $row['username'] . " " . $row['firstname'] . " " . $row['lastname']);
}
} else {
if (empty($userInfo)) {
$this->logger->addError("Students - Can't update user :" . $row['username']);
continue;
}
if ($row['action'] == 'delete') {
// Inactive one year later
$userInfo['expiration_date'] = api_get_utc_datetime(api_strtotime(time() + 365 * 24 * 60 * 60));
}
$password = $row['password'];
// change password
$email = $row['email'];
// change email
$resetPassword = 2;
// allow password change
// Conditions that disables the update of password and email:
if (isset($this->conditions['importStudents'])) {
if (isset($this->conditions['importStudents']['update']) && isset($this->conditions['importStudents']['update']['avoid'])) {
// Blocking email update -
// 1. Condition
$avoidUsersWithEmail = $this->conditions['importStudents']['update']['avoid']['email'];
if ($userInfo['email'] != $row['email'] && in_array($row['email'], $avoidUsersWithEmail)) {
$this->logger->addInfo("Students - User email is not updated : " . $row['username'] . " because the avoid conditions (email).");
// Do not change email keep the old email.
$email = $userInfo['email'];
}
// 2. Condition
if (!in_array($userInfo['email'], $avoidUsersWithEmail) && !in_array($row['email'], $avoidUsersWithEmail)) {
$email = $userInfo['email'];
}
// 3. Condition
if (in_array($userInfo['email'], $avoidUsersWithEmail) && !in_array($row['email'], $avoidUsersWithEmail)) {
$email = $row['email'];
}
// Blocking password update
$avoidUsersWithPassword = $this->conditions['importStudents']['update']['avoid']['password'];
if ($userInfo['password'] != api_get_encrypted_password($row['password']) && in_array($row['password'], $avoidUsersWithPassword)) {
$this->logger->addInfo("Students - User password is not updated: " . $row['username'] . " because the avoid conditions (password).");
$password = null;
$resetPassword = 0;
// disallow password change
}
}
}
$expirationDate = api_get_utc_datetime(strtotime("+" . intval($this->expirationDateInUserUpdate) . "years"));
// Update user
$result = UserManager::update_user($userInfo['user_id'], $row['firstname'], $row['lastname'], $row['username'], $password, $row['auth_source'], $email, STUDENT, $userInfo['official_code'], $userInfo['phone'], $userInfo['picture_uri'], $expirationDate, $userInfo['active'], null, 0, null, null, null, false, $resetPassword);
if ($result) {
if ($row['username'] != $userInfo['username']) {
$this->logger->addInfo("Students - Username was changes from '" . $userInfo['username'] . "' to '" . $row['username'] . "' ");
}
foreach ($row as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
//.........这里部分代码省略.........
示例4: foreach
$sql = "UPDATE $table_user SET";
foreach ($user_data as $key => $value) {
if (substr($key, 0, 6) == 'extra_') { //an extra field
$extras[substr($key, 6)] = $value;
} else {
$sql .= " $key = '".Database :: escape_string($value)."',";
}
}
// Remove trailing , from the query we have so far
$sql = rtrim($sql, ',');
$sql .= " WHERE user_id = '".$user_id."'";
Database::query($sql);
// Update the extra fields
if (is_array($extras)) {
foreach ($extras as $key => $value) {
$myres = UserManager :: update_extra_field_value($user_id, $key, $value);
}
}
echo '<div id="survey_content" class="survey_content">'.get_lang('InformationUpdated').' '.get_lang('PleaseFillSurvey').'</div>';
}
}
$_GET['show'] = 0;
$show = 0;
// We unset the sessions
unset($_SESSION['paged_questions']);
unset($_SESSION['page_questions_sec']);
$paged_questions_sec = array();
} else {
echo '<div id="survey_content" class="survey_content">'.get_lang('UpdateInformation').'</div>';
// We unset the sessions
unset($_SESSION['paged_questions']);
示例5: init_user
/**
*
* @global bool $is_platformAdmin
* @global bool $is_allowedCreateCourse
* @global object $_user
*/
public static function init_user($user_id, $reset)
{
global $is_platformAdmin;
global $is_allowedCreateCourse;
global $_user;
if (isset($reset) && $reset) {
// session data refresh requested
unset($_SESSION['_user']['uidReset']);
$is_platformAdmin = false;
$is_allowedCreateCourse = false;
$_user['user_id'] = $user_id;
if (isset($_user['user_id']) && $_user['user_id'] && !api_is_anonymous()) {
// a uid is given (log in succeeded)
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$track_e_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date\n FROM {$user_table}\n LEFT JOIN {$admin_table} a\n ON user.user_id = a.user_id\n LEFT JOIN {$track_e_login} login\n ON user.user_id = login.login_user_id\n WHERE user.user_id = '" . $_user['user_id'] . "'\n ORDER BY login.login_date DESC LIMIT 1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
// Extracting the user data
$uData = Database::fetch_array($result);
$_user['firstName'] = $uData['firstname'];
$_user['lastName'] = $uData['lastname'];
$_user['mail'] = $uData['email'];
$_user['lastLogin'] = $uData['login_date'];
$_user['official_code'] = $uData['official_code'];
$_user['picture_uri'] = $uData['picture_uri'];
$_user['user_id'] = $uData['user_id'];
$_user['language'] = $uData['language'];
$_user['auth_source'] = $uData['auth_source'];
$_user['theme'] = $uData['theme'];
$_user['status'] = $uData['status'];
$is_platformAdmin = (bool) (!is_null($uData['is_admin']));
$is_allowedCreateCourse = (bool) ($uData['status'] == 1 or api_get_setting('drhCourseManagerRights') and $uData['status'] == 4);
ConditionalLogin::check_conditions($uData);
Session::write('_user', $_user);
UserManager::update_extra_field_value($_user['user_id'], 'already_logged_in', 'true');
Session::write('is_platformAdmin', $is_platformAdmin);
Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
} else {
header('location:' . api_get_path(WEB_PATH));
//exit("WARNING UNDEFINED UID !! ");
}
} else {
// no uid => logout or Anonymous
Session::erase('_user');
Session::erase('_uid');
}
Session::write('is_platformAdmin', $is_platformAdmin);
Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
} else {
// continue with the previous values
$_user = $_SESSION['_user'];
$is_platformAdmin = $_SESSION['is_platformAdmin'];
$is_allowedCreateCourse = $_SESSION['is_allowedCreateCourse'];
}
}
示例6: substr
} else {
if (array_key_exists('tmp_name', $value)) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']);
}
if (array_key_exists('name', $value)) {
$value['name'] = Security::filter_filename($value['name']);
}
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} else {
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} elseif (strpos($key, 'remove_extra') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value($user_id, substr($key, 13), $extra_value);
}
}
$tok = Security::get_token();
header('Location: user_list.php?action=show_message&message=' . urlencode(get_lang('UserUpdated')) . '&sec_token=' . $tok);
exit;
}
}
$message = null;
if ($error_drh) {
$err_msg = get_lang('StatusCanNotBeChangedToHumanResourcesManager');
$message = Display::return_message($err_msg, 'error');
}
// USER PICTURE
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web');
$image_dir = $image_path['dir'];
示例7: explode
echo Display::page_header($tool_name);
echo $content;
Display::display_footer();
exit;
}
}
}
// Terms & Conditions
if (api_get_setting('registration.allow_terms_conditions') == 'true') {
// Update the terms & conditions.
if (isset($values['legal_accept_type'])) {
$cond_array = explode(':', $values['legal_accept_type']);
if (!empty($cond_array[0]) && !empty($cond_array[1])) {
$time = time();
$condition_to_save = intval($cond_array[0]) . ':' . intval($cond_array[1]) . ':' . $time;
UserManager::update_extra_field_value($user_id, 'legal_accept', $condition_to_save);
}
}
$values = api_get_user_info($user_id);
}
/* SESSION REGISTERING */
/* @todo move this in a function */
$_user['firstName'] = stripslashes($values['firstname']);
$_user['lastName'] = stripslashes($values['lastname']);
$_user['mail'] = $values['email'];
$_user['language'] = $values['language'];
$_user['user_id'] = $user_id;
$is_allowedCreateCourse = isset($values['status']) && $values['status'] == 1;
$usersCanCreateCourse = api_get_setting('course.allow_users_to_create_courses') == 'true';
Session::write('_user', $_user);
Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
示例8: VALUES
Database::query("INSERT INTO $tbl_session_rel_user(id_session, id_user) VALUES('$id_session','$user_id')");
$sql = "SELECT COUNT(nbr_users) as nbUsers FROM $tbl_session WHERE id='$id_session' ";
$rs = Database::query($sql);
list($nbr_users) = Database::fetch_array($rs);
Database::query("UPDATE $tbl_session SET nbr_users= $nbr_users WHERE id='$id_session' ");
}
}
$extras = array();
foreach ($user as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
$myres = UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
}
if ($platform_admin) {
$sql = "INSERT INTO $table_admin SET user_id = '".$user_id."'";
Database::query($sql);
}
if (!empty ($email) && $send_mail) {
//$emailto = '"'.api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS).'" <'.$email.'>';
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
示例9: save_data
/**
* Save the imported data
* @param array $users List of users
* @return void
* @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
*/
function save_data($users)
{
global $inserted_in_course;
// Not all scripts declare the $inserted_in_course array (although they should).
if (!isset($inserted_in_course)) {
$inserted_in_course = array();
}
$usergroup = new UserGroup();
$send_mail = $_POST['sendMail'] ? true : false;
if (is_array($users)) {
foreach ($users as $user) {
$user = complete_missing_data($user);
$user['Status'] = api_status_key($user['Status']);
$user_id = UserManager::create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], $user['language'], $user['PhoneNumber'], '', $user['AuthSource'], $user['ExpiryDate'], 1, 0, null, null, $send_mail);
if (!is_array($user['Courses']) && !empty($user['Courses'])) {
$user['Courses'] = array($user['Courses']);
}
if (is_array($user['Courses'])) {
foreach ($user['Courses'] as $course) {
if (CourseManager::course_exists($course)) {
CourseManager::subscribe_user($user_id, $course, $user['Status']);
$course_info = CourseManager::get_course_information($course);
$inserted_in_course[$course] = $course_info['title'];
}
}
}
if (!empty($user['ClassId'])) {
$classId = explode('|', trim($user['ClassId']));
foreach ($classId as $id) {
$usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
}
}
// Saving extra fields.
global $extra_fields;
// We are sure that the extra field exists.
foreach ($extra_fields as $extras) {
if (isset($user[$extras[1]])) {
$key = $extras[1];
$value = $user[$extras[1]];
UserManager::update_extra_field_value($user_id, $key, $value);
}
}
}
}
}
示例10: store_user_blocks
/**
* This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
* @param int User id
* @param array selected blocks
* @param array columns position
* @return bool
*/
public static function store_user_blocks($user_id, $enabled_blocks, $columns)
{
$selected_blocks_id = array();
if (is_array($enabled_blocks) && count($enabled_blocks) > 0) {
$selected_blocks_id = array_keys($enabled_blocks);
}
// build data for storing inside extra user field
$fname = 'dashboard';
$fvalue = array();
foreach ($selected_blocks_id as $block_id) {
$fvalue[] = $block_id . ':' . $columns[$block_id];
}
$upd_extra_field = UserManager::update_extra_field_value($user_id, $fname, $fvalue);
return $upd_extra_field;
}
示例11: api_clean_account_captcha
/**
* @param string $username
*/
function api_clean_account_captcha($username)
{
$userInfo = api_get_user_info_from_username($username);
if (empty($userInfo)) {
return false;
}
Session::erase('loginFailedCount');
UserManager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', null);
}
示例12: create_user
//.........这里部分代码省略.........
error_log('User does not have a uidIdPersona');
error_log(print_r($data, 1));
return false;
//exit;
}
$data['uidIdPersona'] = strtoupper($data['uidIdPersona']);
$data['status'] = STUDENT;
if (isset($data['uidIdEmpleado'])) {
$data['status'] = COURSEMANAGER;
}
if (!isset($data['username']) || empty($data['username'])) {
$data['firstname'] = (string) trim($data['firstname']);
$data['lastname'] = (string) trim($data['lastname']);
if (empty($data['firstname']) && empty($data['lastname'])) {
$wanted_user_name = UserManager::purify_username($data['uidIdPersona']);
//$wanted_user_name = UserManager::create_unique_username(null, null);
} else {
$wanted_user_name = UserManager::create_username($data['firstname'], $data['lastname']);
}
$extra_data = UserManager::get_extra_user_data_by_value('uidIdPersona', $data['uidIdPersona']);
if ($extra_data) {
$user_info = api_get_user_info($extra_data[0]);
//print_r($extra_data);
//error_log("User_already_added - {$user_info['user_id']} - {$user_info['username']} - {$user_info['firstname']} - {$user_info['lastname']}");
return $user_info;
}
if (UserManager::is_username_available($wanted_user_name)) {
$data['username'] = $wanted_user_name;
error_log("username available {$wanted_user_name}");
} else {
//the user already exists?
$user_info = UserManager::get_user_info_simple($wanted_user_name);
$user_persona = UserManager::get_extra_user_data_by_field($user_info['user_id'], 'uidIdPersona');
if (isset($user_persona['uidIdPersona']) && $data['uidIdPersona'] == $user_persona['uidIdPersona']) {
error_log("Skip user already added: {$user_info['username']}");
return $user_info;
} else {
error_log("Homonym - wanted_username: {$wanted_user_name} - uidIdPersona: {$user_persona['uidIdPersona']} - username: {$user_info['username']}");
//print_r($data);
//The user has the same firstname and lastname but it has another uiIdPersona could by an homonym
$data['username'] = UserManager::create_unique_username($data['firstname'], $data['lastname']);
error_log("homonym username created " . $data['username']);
}
}
if (empty($data['username'])) {
//Last chance to have a nice username
if (empty($data['firstname']) && empty($data['lastname'])) {
$data['username'] = UserManager::create_unique_username(uniqid());
error_log("username empty 1" . $data['username']);
} else {
$data['username'] = UserManager::create_unique_username($data['firstname'], $data['lastname']);
error_log("username empty 2" . $data['username']);
}
}
} else {
if (UserManager::is_username_available($data['username'])) {
//error_log("username available {$data['username']} ");
} else {
//the user already exists?
$user_info = UserManager::get_user_info_simple($data['username']);
$user_persona = UserManager::get_extra_user_data_by_field($user_info['user_id'], 'uidIdPersona');
if (isset($user_persona['uidIdPersona']) && (string) $data['uidIdPersona'] == (string) $user_persona['uidIdPersona']) {
//error_log("2 Skip user already added: {$user_info['username']}");
return $user_info;
} else {
//print_r($user_persona);
//error_log("2 homonym - wanted_username: {$data['username']} - uidIdPersona: {$user_persona['uidIdPersona']} - username: {$user_info['username']}");
//print_r($data);
//The user has the same firstname and lastname but it has another uiIdPersona could by an homonym
$data['username'] = UserManager::create_unique_username($data['firstname'], $data['lastname']);
//error_log("2 homonym username created ". $data['username']);
}
}
}
if (empty($data['username'])) {
error_log('No Username provided');
error_log(print_r($data, 1));
return false;
//exit;
}
$id_persona = $data['uidIdPersona'];
unset($data['uidIdPersona']);
unset($data['uidIdAlumno']);
unset($data['uidIdEmpleado']);
$data['encrypt_method'] = 'sha1';
global $api_failureList;
$api_failureList = array();
//error_log(print_r($data, 1));
$user_info = UserManager::add($data);
if (!$user_info) {
error_log('User ' . $id_persona . ' could not be inserted (maybe duplicate?)');
} else {
//error_log('User '.$id_persona.' was created as user '.$user_info['user_id']);
}
if (is_array($omigrate) && isset($omigrate) && $omigrate['boost_users']) {
$omigrate['users'][$id_persona] = $user_info['user_id'];
}
UserManager::update_extra_field_value($user_info['user_id'], 'uidIdPersona', $id_persona);
return $user_info;
}
示例13: save_data
/**
* Save the imported data
*/
function save_data($users)
{
$user_table = Database::get_main_table(TABLE_MAIN_USER);
if (is_array($users)) {
foreach ($users as $index => $user) {
$user = complete_missing_data($user);
$user['Status'] = api_status_key($user['Status']);
$user_id = UserManager::create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']);
foreach ($user['Courses'] as $index => $course) {
if (CourseManager::course_exists($course)) {
CourseManager::subscribe_user($user_id, $course, $user['Status']);
}
}
if (strlen($user['ClassName']) > 0) {
$class_id = ClassManager::get_class_id($user['ClassName']);
ClassManager::add_user($user_id, $class_id);
}
// TODO: Hard-coded French texts.
// Qualite
if (!empty($user['Qualite'])) {
UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']);
}
// Categorie
if (!empty($user['Categorie'])) {
UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']);
}
// Etat
if (!empty($user['Etat'])) {
UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']);
}
// Niveau
if (!empty($user['Niveau'])) {
UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']);
}
}
}
}
示例14: api_get_user_id
}
$sql .= " WHERE user_id = '" . api_get_user_id() . "'";
Database::query($sql);
// User tag process
//1. Deleting all user tags
$list_extra_field_type_tag = UserManager::get_all_extra_field_by_type(ExtraField::FIELD_TYPE_TAG);
if (is_array($list_extra_field_type_tag) && count($list_extra_field_type_tag) > 0) {
foreach ($list_extra_field_type_tag as $id) {
UserManager::delete_user_tags(api_get_user_id(), $id);
}
}
//2. Update the extra fields and user tags if available
if (is_array($extras) && count($extras) > 0) {
foreach ($extras as $key => $value) {
//3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function
UserManager::update_extra_field_value(api_get_user_id(), $key, $value);
}
}
// re-init the system to take new settings into account
$_SESSION['_user']['uidReset'] = true;
$_SESSION['noredirection'] = true;
$_SESSION['profile_update'] = 'success';
$url = api_get_self() . "?{$_SERVER['QUERY_STRING']}" . ($filtered_extension && strpos($_SERVER['QUERY_STRING'], '&fe=1') === false ? '&fe=1' : '');
header("Location: " . $url);
exit;
}
/* MAIN DISPLAY SECTION */
// the header
Display::display_header(get_lang('ModifyProfile'));
if (api_get_setting('allow_social_tool') != 'true') {
if (api_get_setting('extended_profile') == 'true') {
示例15: updateUsers
/**
* Update users from the imported data
* @param array $users List of users
* @return void
* @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
*/
function updateUsers($users)
{
global $insertedIn_course;
// Not all scripts declare the $inserted_in_course array (although they should).
if (!isset($inserted_in_course)) {
$inserted_in_course = array();
}
$usergroup = new UserGroup();
$send_mail = $_POST['sendMail'] ? true : false;
if (is_array($users)) {
foreach ($users as $user) {
$user = complete_missing_data($user);
$user['Status'] = api_status_key($user['Status']);
$userName = $user['UserName'];
$userInfo = api_get_user_info_from_username($userName);
$user_id = $userInfo['user_id'];
if ($user_id == 0) {
return false;
}
$firstName = isset($user['FirstName']) ? $user['FirstName'] : $userInfo['firstname'];
$lastName = isset($user['LastName']) ? $user['LastName'] : $userInfo['lastname'];
$userName = isset($user['NewUserName']) ? $user['NewUserName'] : $userInfo['username'];
$password = isset($user['Password']) ? $user['Password'] : $userInfo['password'];
$authSource = isset($user['AuthSource']) ? $user['AuthSource'] : $userInfo['auth_source'];
$email = isset($user['Email']) ? $user['Email'] : $userInfo['email'];
$status = isset($user['Status']) ? $user['Status'] : $userInfo['status'];
$officialCode = isset($user['OfficialCode']) ? $user['OfficialCode'] : $userInfo['official_code'];
$phone = isset($user['PhoneNumber']) ? $user['PhoneNumber'] : $userInfo['phone'];
$pictureUrl = isset($user['PictureUri']) ? $user['PictureUri'] : $userInfo['picture_uri'];
$expirationDate = isset($user['ExpiryDate']) ? $user['ExpiryDate'] : $userInfo['expiration_date'];
$active = isset($user['Active']) ? $user['Active'] : $userInfo['active'];
$creatorId = $userInfo['creator_id'];
$hrDeptId = $userInfo['hr_dept_id'];
$language = isset($user['Language']) ? $user['Language'] : $userInfo['language'];
$sendEmail = isset($user['SendEmail']) ? $user['SendEmail'] : $userInfo['language'];
$userUpdated = UserManager::update_user($user_id, $firstName, $lastName, $userName, $password, $authSource, $email, $status, $officialCode, $phone, $pictureUrl, $expirationDate, $active, $creatorId, $hrDeptId, null, $language, '', '', '');
if (!is_array($user['Courses']) && !empty($user['Courses'])) {
$user['Courses'] = array($user['Courses']);
}
if (is_array($user['Courses'])) {
foreach ($user['Courses'] as $course) {
if (CourseManager::course_exists($course)) {
CourseManager::subscribe_user($user_id, $course, $user['Status']);
$course_info = CourseManager::get_course_information($course);
$inserted_in_course[$course] = $course_info['title'];
}
}
}
if (!empty($user['ClassId'])) {
$classId = explode('|', trim($user['ClassId']));
foreach ($classId as $id) {
$usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
}
}
// Saving extra fields.
global $extra_fields;
// We are sure that the extra field exists.
foreach ($extra_fields as $extras) {
if (isset($user[$extras[1]])) {
$key = $extras[1];
$value = $user[$extras[1]];
UserManager::update_extra_field_value($user_id, $key, $value);
}
}
}
}
}