当前位置: 首页>>代码示例>>PHP>>正文


PHP UserManager::update_user方法代码示例

本文整理汇总了PHP中UserManager::update_user方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::update_user方法的具体用法?PHP UserManager::update_user怎么用?PHP UserManager::update_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserManager的用法示例。


在下文中一共展示了UserManager::update_user方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
                }
            }
        }
    }
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:73,代码来源:user_update_import.php

示例2: api_get_path

$url = api_get_path(WEB_PATH) . 'main/auth/conditional_login/complete_phone_number.php';
if (!isset($_SESSION['conditional_login']['uid'])) {
    die("Not Authorised");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body>
  <form id="data_completion" name="data_completion" method="post" action="<?php 
echo $url;
?>
">
        Téléphone : <input type="text" name="phone_number" />
        <input type="submit" name="submit" value="Submit" />
    </form>
  </body>
</html>
<?php 
if (isset($_POST['submit'])) {
    $u = api_get_user_info($_SESSION['conditional_login']['uid']);
    $u['phone'] = $_POST['phone_number'];
    $password = null;
    // we don't want to change the password
    $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], $password, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'], '');
    if ($updated) {
        ConditionalLogin::login();
    }
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:complete_phone_number.php

示例3: cas_is_authenticated

/**
* checks if the user already get a session
* @return the user login if the user already has a session ,false otherwise
**/
function cas_is_authenticated()
{
    global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
    global $PHPCAS_CLIENT;
    global $logout;
    if (!cas_configured()) {
        return;
    }
    if (!is_object($PHPCAS_CLIENT)) {
        phpCAS::client($cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri);
        phpCAS::setNoCasServerValidation();
    }
    $auth = phpCAS::checkAuthentication();
    if ($auth) {
        $login = trim(phpCAS::getUser());
        /*
          Get user  attributes. Here are the attributes for crdp platform
          sn => name
          ENTPersonMailInterne => mail
          ENTPersonAlias => login
          ENTPersonProfils => profil
          givenName => first name
        */
        /*$user=phpCAS::getAttributes();
        		$firstName = trim($user['givenName']);
        		$lastName = trim($user['sn']);
        		$login = trim($user['ENTPersonAlias']);
        		$profil = trim($user['ENTPersonProfils']);
        		$email = trim($user['ENTPersonMailInterne']);
        		$satus=5;
        		switch ($profil){
        			case 'admin_etab':
        				$status=3; //Session admin
        				break;
        			case 'admin_sie':
        				$status=3; //Session admin
        				break;
        			case 'National_3':
        				$status=1; // Teacher
        				break;
        			case 'National_1':
        				$status=5; // Student
        				break;
        			default:
        				$status=5; // Student
        		}*/
        if (!$logout) {
            // get user info from username
            $tab_user_info = UserManager::get_user_info($login);
            // user found in the chamilo database
            if (is_array($tab_user_info)) {
                // if option is on we update user automatically from ldap server
                if (api_get_setting("update_user_info_cas_with_ldap") == "true") {
                    $ldapuser = extldap_authenticate($login, 'nopass', true);
                    if ($ldap_user !== false) {
                        $chamilo_user = extldap_get_chamilo_user($ldapuser);
                        $chamilo_user['user_id'] = $tab_user_info['user_id'];
                        $chamilo_user['status'] = $tab_user_info['status'];
                        UserManager::update_user($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null, '');
                    }
                }
                return $login;
            } else {
                // if option is on we can ADD user automatically from ldap server or by modify own profil
                $user_added = false;
                switch (api_get_setting("cas_add_user_activate")) {
                    case PLATFORM_AUTH_SOURCE:
                        // user will have to modify firstname, lastname, email in chamilo profil edit
                        $userdata = get_lang("EditInProfil");
                        UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '', '', '', '', CAS_AUTH_SOURCE);
                        $user_added = $login;
                        break;
                    case LDAP_AUTH_SOURCE:
                        // user info are read from ldap connexion
                        // get user info from ldap server
                        // user has already been authenticated by CAS
                        // If user not found in LDAP, user not created
                        $ldapuser = extldap_authenticate($login, 'nopass', true);
                        if ($ldap_user !== false) {
                            $chamilo_user = extldap_get_chamilo_user($ldapuser);
                            $chamilo_user['username'] = $login;
                            $chamilo_user['auth_source'] = CAS_AUTH_SOURCE;
                            $chamilo_uid = external_add_user($chamilo_user);
                            $user_added = $login;
                        }
                        break;
                    default:
                        break;
                }
                return $user_added;
            }
        }
        //		//If the user is in the dokeos database and we are ,not in a logout request, we upgrade his infomration by ldap
        //		if (! $logout){
        //			$user_table = Database::get_main_table(TABLE_MAIN_USER);
        //			$sql = "SELECT user_id, username, password, auth_source, active, expiration_date ".
//.........这里部分代码省略.........
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:authcas.php

示例4: 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
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:import_csv.php

示例5: ldap_add_user

/**
 * Adds a user to the Dokeos database or updates its data
 * @param	string	username (and uid inside LDAP)
 * @author	Mustapha Alouani
 */
function ldap_add_user($login)
{
    global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass;
    $ds = ldap_connect($ldap_host, $ldap_port);
    ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
    if ($ds) {
        $str_query = "(uid=" . $login . ")";
        $r = false;
        $res = ldap_handle_bind($ds, $r);
        $sr = ldap_search($ds, $ldap_basedn, $str_query);
        //echo "Le nombre de resultats est : ".ldap_count_entries($ds,$sr)."<p>";
        $info = ldap_get_entries($ds, $sr);
        for ($key = 0; $key < $info['count']; $key++) {
            $lastname = api_convert_encoding($info[$key]['sn'][0], api_get_system_encoding(), 'UTF-8');
            $firstname = api_convert_encoding($info[$key]['givenname'][0], api_get_system_encoding(), 'UTF-8');
            $email = $info[$key]['mail'][0];
            // Get uid from dn
            $dn_array = ldap_explode_dn($info[$key]['dn'], 1);
            $username = $dn_array[0];
            // uid is first key
            $outab[] = $info[$key]['edupersonprimaryaffiliation'][0];
            // Ici "student"
            //$val = ldap_get_values_len($ds, $entry, "userPassword");
            //$val = ldap_get_values_len($ds, $info[$key], "userPassword");
            //$password = $val[0];
            // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
            $password = $info[$key]['userPassword'][0];
            $structure = $info[$key]['edupersonprimaryorgunitdn'][0];
            $array_structure = explode(",", $structure);
            $array_val = explode("=", $array_structure[0]);
            $etape = $array_val[1];
            $array_val = explode("=", $array_structure[1]);
            $annee = $array_val[1];
            // Pour faciliter la gestion on ajoute le code "etape-annee"
            $official_code = $etape . "-" . $annee;
            $auth_source = 'ldap';
            // Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP)
            $expiration_date = '0000-00-00 00:00:00';
            $active = 1;
            if (empty($status)) {
                $status = 5;
            }
            if (empty($phone)) {
                $phone = '';
            }
            if (empty($picture_uri)) {
                $picture_uri = '';
            }
            // Ajout de l'utilisateur
            if (UserManager::is_username_available($username)) {
                $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
            } else {
                $user = UserManager::get_user_info($username);
                $user_id = $user['user_id'];
                UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
            }
        }
    } else {
        Display::display_error_message(get_lang('LDAPConnectionError'));
    }
    return $user_id;
}
开发者ID:marcyves,项目名称:cool,代码行数:68,代码来源:authldap.php

示例6: isset

 $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
 $language = $user['language'];
 if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
     $expiration_date = return_datetime_from_array($user['expiration_date']);
 } else {
     $expiration_date = '0000-00-00 00:00:00';
 }
 $active = $user_data['platform_admin'] ? 1 : intval($user['active']);
 //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') {
     $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);
 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) {
     if ($platform_admin == 1) {
         UserManager::add_user_as_admin($user_id);
     } else {
         UserManager::remove_user_admin($user_id);
     }
 }
 foreach ($user as $key => $value) {
     if (substr($key, 0, 6) == 'extra_') {
         //an extra field
         //@todo remove this as well as in the profile.php ad put it in a function
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:user_edit.php

示例7: intval

 $user = $form->exportValues();
 $email = $userInfo['email'];
 $username = $userInfo['username'];
 $send_mail = intval($user['mail']['send_mail']);
 $auth_source = PLATFORM_AUTH_SOURCE;
 $resetPassword = $user['password']['password_auto'] == '1' ? 0 : 2;
 if (count($extAuthSource) > 0 && $user['password']['password_auto'] == '2') {
     //$auth_source = $user['password']['auth_source'];
     //$password = 'PLACEHOLDER';
 } else {
     //$auth_source = PLATFORM_AUTH_SOURCE;
     //$password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password'];
 }
 $auth_source = $userInfo['auth_source'];
 $password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password'];
 UserManager::update_user($userId, $userInfo['firstname'], $userInfo['lastname'], $userInfo['username'], $password, $auth_source, $userInfo['email'], $userInfo['status'], $userInfo['official_code'], $userInfo['phone'], $userInfo['picture_uri'], $userInfo['expiration_date'], $userInfo['active'], $userInfo['creator_id'], $userInfo['hr_dept_id'], null, $userInfo['language'], null, false, $resetPassword);
 if (!empty($email) && $send_mail) {
     $emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name');
     $portal_url = api_get_path(WEB_PATH);
     if (api_is_multiple_url_enabled()) {
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $url = api_get_access_url($access_url_id);
             $portal_url = $url['url'];
         }
     }
     $emailbody = get_lang('Dear') . " " . stripslashes(api_get_person_name($userInfo['firstname'], $userInfo['lastname'])) . ",\n\n" . get_lang('YouAreReg') . " " . api_get_setting('platform.site_name') . " " . get_lang('WithTheFollowingSettings') . "\n\n" . get_lang('Username') . " : " . $username . "\n" . get_lang('Pass') . " : " . stripslashes($password) . "\n\n" . get_lang('Address') . " " . api_get_setting('platform.site_name') . " " . get_lang('Is') . " : " . $portal_url . "\n\n" . get_lang('Problem') . "\n\n" . get_lang('SignatureFormula') . ",\n\n" . api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname')) . "\n" . get_lang('Manager') . " " . api_get_setting('platform.site_name') . "\nT. " . api_get_setting('admin.administrator_phone') . "\n" . get_lang('Email') . " : " . api_get_setting('admin.administrator_email');
     $emailbody = nl2br($emailbody);
     api_mail_html(api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $email, $emailsubject, $emailbody);
 }
 Security::clear_token();
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:user_edit.php

示例8: ldap_add_user_by_array

function ldap_add_user_by_array($data, $update_if_exists = true)
{
    $lastname = api_convert_encoding($data['sn'][0], api_get_system_encoding(), 'UTF-8');
    $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8');
    $email = $data['mail'][0];
    // Get uid from dn
    $dn_array = ldap_explode_dn($data['dn'], 1);
    $username = $dn_array[0];
    // uid is first key
    $outab[] = $data['edupersonprimaryaffiliation'][0];
    // Here, "student"
    //$val = ldap_get_values_len($ds, $entry, "userPassword");
    //$val = ldap_get_values_len($ds, $data, "userPassword");
    //$password = $val[0];
    // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
    $password = $data['userPassword'][0];
    $structure = $data['edupersonprimaryorgunitdn'][0];
    $array_structure = explode(",", $structure);
    $array_val = explode("=", $array_structure[0]);
    $etape = $array_val[1];
    $array_val = explode("=", $array_structure[1]);
    $annee = $array_val[1];
    // To ease management, we add the step-year (etape-annee) code
    $official_code = $etape . "-" . $annee;
    $auth_source = 'ldap';
    // No expiration date for students (recover from LDAP's shadow expiry)
    $expiration_date = '0000-00-00 00:00:00';
    $active = 1;
    if (empty($status)) {
        $status = 5;
    }
    if (empty($phone)) {
        $phone = '';
    }
    if (empty($picture_uri)) {
        $picture_uri = '';
    }
    // Adding user
    $user_id = 0;
    if (UserManager::is_username_available($username)) {
        $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
    } else {
        if ($update_if_exists) {
            $user = UserManager::get_user_info($username);
            $user_id = $user['user_id'];
            UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
        }
    }
    return $user_id;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:50,代码来源:authldap.php

示例9: trim

             $phone = trim(api_utf8_decode($node_user->Phone));
             $status = trim(api_utf8_decode($node_user->Status));
             switch ($status) {
                 case 'student':
                     $status = 5;
                     break;
                 case 'teacher':
                     $status = 1;
                     break;
                 default:
                     $status = 5;
                     $error_message .= get_lang('StudentStatusWasGivenTo') . ' : ' . $username . '<br />';
             }
             $userId = UserManager::get_user_id_from_username($username);
             if (!empty($userId)) {
                 UserManager::update_user($userId, $firstname, $lastname, $username, $password, null, $email, $status, $official_code, $phone, null, null, null, null, 0, null, null, null, false, 0);
             }
         }
     }
 }
 // Creating  courses from <Sessions> <Courses> base node.
 if (count($root->Courses->Course) > 0) {
     foreach ($root->Courses->Course as $courseNode) {
         $params = array();
         if (empty($courseNode->CourseTitle)) {
             $params['title'] = api_utf8_decode($courseNode->CourseCode);
         } else {
             $params['title'] = api_utf8_decode($courseNode->CourseTitle);
         }
         $params['wanted_code'] = api_utf8_decode($courseNode->CourseCode);
         $params['tutor_name'] = null;
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:session_import.php

示例10: ldap_get_values_len

         $val = ldap_get_values_len($ds, $sr, "userPassword");
         $password = $val[0];
         // Pour faciliter la gestion on ajoute le code "etape-annee"
         $official_code = $etape . "-" . $annee;
         $auth_source = "ldap";
         // Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP)
         $expiration_date = '0000-00-00 00:00:00';
         $active = 1;
         // Ajout de l'utilisateur
         if (UserManager::is_username_available($username)) {
             $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('language.platform_language'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
             $UserAdd[] = $user_id;
         } else {
             $user = api_get_user_info_from_username($username);
             $user_id = $user['user_id'];
             UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
             $UserUpdate[] = $user_id;
         }
         $UserList[] = $user_id;
     }
     //}
 }
 if (isset($included) && $included) {
     $message .= "> {$name_session}: " . count($UserAdd) . " " . get_lang('Added') . ' ' . get_lang('And') . ' ' . count($UserUpdate) . ' ' . get_lang('Modified') . '<br/>';
 } else {
     print "> {$name_session}: " . count($UserAdd) . get_lang('Added') . ' ' . get_lang('And') . ' ' . count($UserUpdate) . ' ' . get_lang('Modified') . "\n";
 }
 // Une fois les utilisateurs importer dans la base des utilisateurs, on peux les affecter la session
 $result = Database::query("SELECT c_id FROM {$tbl_session_rel_course} WHERE session_id='{$id_session}'");
 $CourseList = array();
 while ($row = Database::fetch_array($result)) {
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:ldap_synchro.php

示例11: extldap_add_user_by_array

/**
 * Insert users from an array of user fields
 */
function extldap_add_user_by_array($data, $update_if_exists = true)
{
    global $extldap_user_correspondance;
    $lastname = api_convert_encoding($data[$extldap_user_correspondance['lastname']][0], api_get_system_encoding(), 'UTF-8');
    $firstname = api_convert_encoding($data[$extldap_user_correspondance['firstname']][0], api_get_system_encoding(), 'UTF-8');
    $email = $data[$extldap_user_correspondance['email']][0];
    $username = $data[$extldap_user_correspondance['username']][0];
    // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
    $passwordKey = isset($extldap_user_correspondance['password']) ? $extldap_user_correspondance['password'] : 'userPassword';
    $password = $data[$passwordKey][0];
    // To ease management, we add the step-year (etape-annee) code
    //$official_code = $etape."-".$annee;
    $official_code = api_convert_encoding($data[$extldap_user_correspondance['official_code']][0], api_get_system_encoding(), 'UTF-8');
    $auth_source = 'ldap';
    // No expiration date for students (recover from LDAP's shadow expiry)
    $expiration_date = '0000-00-00 00:00:00';
    $active = 1;
    if (empty($status)) {
        $status = 5;
    }
    if (empty($phone)) {
        $phone = '';
    }
    if (empty($picture_uri)) {
        $picture_uri = '';
    }
    // Adding user
    $user_id = 0;
    if (UserManager::is_username_available($username)) {
        //echo "$username\n";
        $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
    } else {
        if ($update_if_exists) {
            $user = UserManager::get_user_info($username);
            $user_id = $user['user_id'];
            //echo "$username\n";
            UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
        }
    }
    return $user_id;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:44,代码来源:ldap.inc.php

示例12: external_update_user

/**
 * Update the user in chamilo database. It upgrade only info that is present in the
 * new_user array
 *
 * @param $new_user associative array with the value to upgrade
 *    WARNING user_id key is MANDATORY
 *    Possible keys are :
 *      - firstname
 *      - lastname
 *      - username
 *      - auth_source
 *      - email
 *      - status
 *      - official_code
 *      - phone
 *      - picture_uri
 *      - expiration_date
 *      - active
 *      - creator_id
 *      - hr_dept_id
 *      - extra : array of custom fields
 *      - language
 *      - courses : string of all courses code separated by '|'
 *      - admin : boolean
 * @return boolean
 * @author ndiechburg <noel@cblue.be>
 * */
function external_update_user($new_user)
{
    $old_user = api_get_user_info($new_user['user_id']);
    $u = array_merge($old_user, $new_user);
    $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], null, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'], '');
    if (isset($u['courses']) && !empty($u['courses'])) {
        $autoSubscribe = explode('|', $u['courses']);
        foreach ($autoSubscribe as $code) {
            if (CourseManager::course_exists($code)) {
                CourseManager::subscribe_user($u['user_id'], $code);
            }
        }
    }
    // Is User Admin ?
    //TODO decomments and check that user_is is not already in admin table
    /*
          if (isset($u['admin']) && $u['admin']){
    
          $table = Database::get_main_table(TABLE_MAIN_ADMIN);
          $res = Database::query("SELECT * from $table WHERE user_id = ".$u['user_id']);
          } */
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:49,代码来源:functions.inc.php

示例13: editUserHelper

 /**
  * Edits user info (helper method)
  *
  * @param string User id field name. Use "chamilo_user_id" in order to use internal system id
  * @param string User id value
  * @param string First name
  * @param string Last name
  * @param int User status
  * @param string Login name
  * @param string Password. Leave blank if you don't want to update it
  * @param string Encrypt method
  * @param string User email
  * @param string Language. Set by default to english
  * @param string Phone. Set by default to an empty string
  * @param string Expiration date. Set to null by default
  * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
  * @return mixed True if user was successfully updated, WSError otherwise
  */
 protected function editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras)
 {
     global $api_failureList;
     $user_id = $this->getUserId($user_id_field_name, $user_id_value);
     if ($user_id instanceof WSError) {
         return $user_id;
     } else {
         if ($password == '') {
             $password = null;
         }
         $user_info = api_get_user_info($user_id);
         if (count($extras) == 0) {
             $extras = null;
         }
         $result = UserManager::update_user($user_id, $firstname, $lastname, $loginname, $password, PLATFORM_AUTH_SOURCE, $email, $status, '', $phone, $user_info['picture_uri'], $expiration_date, $user_info['active'], null, $user_info['hr_dept_id'], $extras, $encrypt_method);
         if (!$result) {
             $failure = $api_failureList[0];
             if ($failure == 'encrypt_method invalid') {
                 return new WSError(103, 'The encryption of the password is invalid');
             } else {
                 return new WSError(105, 'There was an error updating the user');
             }
         } else {
             return $result;
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:45,代码来源:webservice_user.php

示例14: testUpdate_user

 /**
  * Generated from @assert (false, false, false, false, false, false, false, false, false, false, false, false, false) === false.
  *
  * @covers UserManager::update_user
  */
 public function testUpdate_user()
 {
     var_dump($this->app);
     exit;
     $this->assertSame(false, UserManager::update_user(false, false, false, false, false, false, false, false, false, false, false, false, false));
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:11,代码来源:UserManagerTest.lib.php


注:本文中的UserManager::update_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。