本文整理汇总了PHP中ilObjUser::setFirstname方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjUser::setFirstname方法的具体用法?PHP ilObjUser::setFirstname怎么用?PHP ilObjUser::setFirstname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjUser
的用法示例。
在下文中一共展示了ilObjUser::setFirstname方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preloadUserObjects
/**
* @static
* @param array $usr_ids
*/
public static function preloadUserObjects(array $usr_ids)
{
/**
* @var $ilDB ilDB
*/
global $ilDB;
$usr_ids_to_request = array_diff($usr_ids, self::$requested_usr_ids);
self::$requested_usr_ids = array_merge(self::$requested_usr_ids, $usr_ids_to_request);
self::$requested_usr_ids_key_map = array_flip(self::$requested_usr_ids);
if ($usr_ids_to_request) {
$in = $ilDB->in('ud.usr_id', $usr_ids_to_request, false, 'integer');
$query = "\n\t\t\t\tSELECT ud.usr_id, login, firstname, lastname, title, gender, pprof.value public_profile,pup.value public_upload, pupgen.value public_gender\n\t\t\t\tFROM usr_data ud\n\t\t\t\tLEFT JOIN usr_pref pprof ON pprof.usr_id = ud.usr_id AND pprof.keyword = %s\n\t\t\t\tLEFT JOIN usr_pref pupgen ON pupgen.usr_id = ud.usr_id AND pupgen.keyword = %s\n\t\t\t\tLEFT JOIN usr_pref pup ON pup.usr_id = ud.usr_id AND pup.keyword = %s\n\t\t\t\tWHERE {$in}\n\t\t\t";
$res = $ilDB->queryF($query, array('text', 'text', 'text'), array('public_profile', 'public_gender', 'public_upload'));
while ($row = $ilDB->fetchAssoc($res)) {
$user = new ilObjUser();
$user->setId($row['usr_id']);
$user->setLogin($row['login']);
$user->setGender($row['gender']);
$user->setTitle($row['title']);
$user->setFirstname($row['firstname']);
$user->setLastname($row['lastname']);
$user->setPref('public_profile', $row['public_profile']);
$user->setPref('public_upload', $row['public_upload']);
$user->setPref('public_gender', $row['public_gender']);
self::$user_instances[$row['usr_id']] = $user;
}
}
}
示例2: generateUsers
/**
* Generate Users
*
* @param
* @return
*/
function generateUsers($a_login_base = "learner", $a_start = 1, $a_end = 1000, $a_firstname = "John", $a_lastname_base = "Learner", $a_pw = "learnerpw", $a_email = "de@de.de", $a_gender = "m", $a_lang = "en")
{
global $rbacadmin;
// new users
$this->log("Creating Users");
for ($i = $a_start; $i <= $a_end; $i++) {
$this->log($a_login_base . $i);
$user = new ilObjUser();
$user->setLogin($a_login_base . $i);
$user->setFirstname($a_firstname);
$user->setLastname($a_lastname_base . " " . $i);
$user->setGender($a_gender);
$user->setEmail($a_email);
$user->setAgreeDate(ilUtil::now());
$user->setPasswd($a_pw, IL_PASSWD_PLAIN);
$user->setTitle($user->getFullname());
$user->setDescription($user->getEmail());
$user->setLastPasswordChangeTS(time());
$user->setActive(true);
$user->setTimeLimitUnlimited(true);
$user->create();
$user->setLanguage($a_lang);
$user->saveAsNew(false);
$user->writePrefs();
$rbacadmin->assignUser(4, $user->getId(), true);
}
}
示例3: _createRandomUserAccount
public static function _createRandomUserAccount($keyarray)
{
global $ilDB, $ilUser, $ilSetting, $rbacadmin;
if ($_SESSION['create_user_account'] != NULL) {
$obj_user = new ilObjUser($_SESSION['create_user_account']);
return $obj_user;
} else {
$userLogin = array();
$res = $ilDB->query('SELECT sequence FROM object_data_seq');
$row = $ilDB->fetchAssoc($res);
$temp_user_id = (int) $row['sequence'] + 1;
$userLogin['login'] = 'shop_user_' . $temp_user_id;
$userLogin['passwd'] = ilUtil::generatePasswords(1);
require_once 'Services/User/classes/class.ilObjUser.php';
include_once "Services/Mail/classes/class.ilAccountMail.php";
$obj_user = new ilObjUser();
$obj_user->setId($temp_user_id);
$obj_user->setLogin($userLogin['login']);
$obj_user->setPasswd((string) $userLogin['passwd'][0], IL_PASSWD_PLAIN);
$_SESSION['tmp_user_account']['login'] = $userLogin['login'];
$_SESSION['tmp_user_account']['passwd'] = $userLogin['passwd'];
$obj_user->setFirstname($keyarray['first_name']);
$obj_user->setLastname($keyarray['last_name']);
$obj_user->setEmail($keyarray['payer_email']);
# $obj_user->setEmail('nkrzywon@databay.de');
$obj_user->setGender('f');
$obj_user->setLanguage($ilSetting->get("language"));
$obj_user->setActive(true);
$obj_user->setTimeLimitUnlimited(true);
$obj_user->setTitle($obj_user->getFullname());
$obj_user->setDescription($obj_user->getEmail());
$obj_user->setTimeLimitOwner(7);
$obj_user->setTimeLimitUnlimited(1);
$obj_user->setTimeLimitMessage(0);
$obj_user->setApproveDate(date("Y-m-d H:i:s"));
// Set default prefs
$obj_user->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
$obj_user->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
$obj_user->writePrefs();
// at the first login the user must complete profile
$obj_user->setProfileIncomplete(true);
$obj_user->create();
$obj_user->saveAsNew();
$user_role = ilObject::_exists(4, false);
if (!$user_role) {
include_once "./Services/AccessControl/classes/class.ilObjRole.php";
$reg_allowed = ilObjRole::_lookupRegisterAllowed();
$user_role = $reg_allowed[0]['id'];
} else {
$user_role = 4;
}
$rbacadmin->assignUser((int) $user_role, $obj_user->getId(), true);
include_once "Services/Mail/classes/class.ilMimeMail.php";
global $ilias, $lng;
$settings = $ilias->getAllSettings();
$mmail = new ilMimeMail();
$mmail->autoCheck(false);
$mmail->From($settings["admin_email"]);
$mmail->To($obj_user->getEmail());
// mail subject
$subject = $lng->txt("reg_mail_subject");
// mail body
$body = $lng->txt("reg_mail_body_salutation") . " " . $obj_user->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . $ilias->client_id . "\n";
$body .= $lng->txt("login") . ": " . $obj_user->getLogin() . "\n";
$body .= $lng->txt("passwd") . ": " . $userLogin['passwd'][0] . "\n";
$body .= "\n";
$body .= $lng->txt("reg_mail_body_text3") . "\n\r";
$body .= $obj_user->getProfileAsString($lng);
$mmail->Subject($subject);
$mmail->Body($body);
$mmail->Send();
$_SESSION['create_user_account'] = $obj_user->getId();
return $obj_user;
}
}
示例4: testCreateSetLookupDelete
/**
* Creates a user, sets preferences, lookups data, delete user
* @group IL_Init
*/
public function testCreateSetLookupDelete()
{
include_once "./Services/User/classes/class.ilObjUser.php";
// delete all aatestuser from previous runs
while (($i = ilObjUser::_lookupId("aatestuser")) > 0) {
$user = new ilObjUser($i);
$user->delete();
}
$user = new ilObjUser();
// creation
$d = array("login" => "aatestuser", "passwd_type" => IL_PASSWD_PLAIN, "passwd" => "password", "gender" => "m", "firstname" => "Max", "lastname" => "Mutzke", "email" => "de@de.de", "client_ip" => "1.2.3.4", "ext_account" => "ext_mutzke");
$user->assignData($d);
$user->create();
$user->saveAsNew();
$user->setLanguage("no");
$user->writePrefs();
$id = $user->getId();
$value .= $user->getFirstname() . "-";
// update
$user->setFirstname("Maxi");
$user->update();
$value .= $user->getFirstname() . "-";
// other update methods
$user->refreshLogin();
// lookups
$value .= ilObjUser::_lookupEmail($id) . "-";
$value .= ilObjUser::_lookupGender($id) . "-";
$value .= ilObjUser::_lookupClientIP($id) . "-";
$n = ilObjUser::_lookupName($id);
$value .= $n["lastname"] . "-";
ilObjUser::_lookupFields($id);
$value .= ilObjUser::_lookupLogin($id) . "-";
$value .= ilObjUser::_lookupExternalAccount($id) . "-";
$value .= ilObjUser::_lookupId("aatestuser") . "-";
ilObjUser::_lookupLastLogin($id);
$value .= ilObjUser::_lookupLanguage($id) . "-";
ilObjUser::_readUsersProfileData(array($id));
if (ilObjUser::_loginExists("aatestuser")) {
$value .= "le-";
}
// preferences...
$user->writePref("testpref", "pref1");
$value .= ilObjUser::_lookupPref($id, "testpref") . "-";
$user->deletePref("testpref");
if (ilObjUser::_lookupPref($id, "testpref") == "") {
$value .= "pref2" . "-";
}
// activation
$user->setActive(false);
if (!ilObjUser::getStoredActive($id)) {
}
$value .= "act1-";
$user->setActive(true);
if (ilObjUser::getStoredActive($id)) {
}
$value .= "act2-";
ilObjUser::_toggleActiveStatusOfUsers(array($id), false);
if (!ilObjUser::getStoredActive($id)) {
}
$value .= "act3-";
// deletion
$user->delete();
$this->assertEquals("Max-Maxi-de@de.de-m-1.2.3.4-Mutzke-aatestuser-ext_mutzke-{$id}-no-le-" . "pref1-pref2-act1-act2-act3-", $value);
}
示例5: buildUserRelatedData
protected function buildUserRelatedData($row)
{
global $lng;
if ($row['pos_usr_id'] && $row['pos_pk']) {
require_once 'Services/User/classes/class.ilObjUser.php';
$tmp_user = new ilObjUser();
$tmp_user->setFirstname($row['firstname']);
$tmp_user->setLastname($row['lastname']);
$tmp_user->setUTitle($row['title']);
$tmp_user->setLogin($row['login']);
$this->fullname = $tmp_user->getFullname();
$this->loginname = $tmp_user->getLogin();
$this->fullname = $this->fullname ? $this->fullname : ($this->import_name ? $this->import_name : $lng->txt('unknown'));
return true;
}
}
示例6: verifyEndTag
/**
* handler for end of element when in verify mode.
*/
function verifyEndTag($a_xml_parser, $a_name)
{
global $lng, $ilAccess, $ilSetting, $ilObjDataCache;
switch ($a_name) {
case "Role":
$this->roles[$this->current_role_id]["name"] = $this->cdata;
$this->roles[$this->current_role_id]["type"] = $this->current_role_type;
$this->roles[$this->current_role_id]["action"] = $this->current_role_action;
break;
case "User":
$this->userObj->setFullname();
if ($this->user_id != -1 && $this->action == "Update") {
$user_exists = !is_null(ilObjUser::_lookupLogin($this->user_id));
} else {
$user_exists = ilObjUser::getUserIdByLogin($this->userObj->getLogin()) != 0;
}
if (is_null($this->userObj->getLogin())) {
$this->logFailure("---", sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Login", "Insert"));
}
switch ($this->action) {
case "Insert":
if ($user_exists and $this->conflict_rule == IL_FAIL_ON_CONFLICT) {
$this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_insert"));
}
if (is_null($this->userObj->getGender()) && $this->isFieldRequired("gender")) {
$this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Gender", "Insert"));
}
if (is_null($this->userObj->getFirstname())) {
$this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Firstname", "Insert"));
}
if (is_null($this->userObj->getLastname())) {
$this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Lastname", "Insert"));
}
if (count($this->roles) == 0) {
$this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_element_for_action_required"), "Role", "Insert"));
} else {
$has_global_role = false;
foreach ($this->roles as $role) {
if ($role['type'] == 'Global') {
$has_global_role = true;
break;
}
}
if (!$has_global_role) {
$this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_global_role_for_action_required"), "Insert"));
}
}
break;
case "Update":
if (!$user_exists) {
$this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_update"));
} elseif ($this->user_id != -1 && !is_null($this->userObj->getLogin())) {
$someonesId = ilObjUser::_lookupId($this->userObj->getLogin());
if (is_numeric($someonesId) && $someonesId != $this->user_id) {
$this->logFailure($this->userObj->getLogin(), $lng->txt("usrimport_login_is_not_unique"));
}
}
break;
case "Delete":
if (!$user_exists) {
$this->logWarning($this->userObj->getLogin(), $lng->txt("usrimport_cant_delete"));
}
break;
}
// init role array for next user
$this->roles = array();
break;
case "Login":
if (array_key_exists($this->cdata, $this->logins)) {
$this->logWarning($this->cdata, $lng->txt("usrimport_login_is_not_unique"));
} else {
$this->logins[$this->cdata] = $this->cdata;
}
$this->userObj->setLogin($this->cdata);
break;
case "Password":
switch ($this->currPasswordType) {
case "ILIAS2":
$this->userObj->setPasswd($this->cdata, IL_PASSWD_CRYPT);
break;
case "ILIAS3":
$this->userObj->setPasswd($this->cdata, IL_PASSWD_MD5);
break;
case "PLAIN":
$this->userObj->setPasswd($this->cdata, IL_PASSWD_PLAIN);
$this->acc_mail->setUserPassword($this->currPassword);
break;
default:
$this->logFailure($this->userObj->getLogin(), sprintf($lng->txt("usrimport_xml_attribute_value_illegal"), "Type", "Password", $this->currPasswordType));
break;
}
break;
case "Firstname":
$this->userObj->setFirstname($this->cdata);
break;
case "Lastname":
$this->userObj->setLastname($this->cdata);
//.........这里部分代码省略.........
示例7: fetchUserInformation
private function fetchUserInformation($usr_ids)
{
global $ilDB;
$usr_id__IN__usrIds = $ilDB->in('usr_id', $usr_ids, false, 'integer');
$query = "\n\t\t\tSELECT usr_id, title, firstname, lastname FROM usr_data WHERE {$usr_id__IN__usrIds}\n\t\t";
$res = $ilDB->query($query);
$users = array();
while ($row = $ilDB->fetchAssoc($res)) {
$user = new ilObjUser();
$user->setId($row['usr_id']);
$user->setUTitle($row['title']);
$user->setFirstname($row['firstname']);
$user->setLastname($row['lastname']);
$user->setFullname();
if (!empty($this->filter['flt_participant_name'])) {
$name = strtolower($user->getFullName());
$filter = strtolower($this->filter['flt_participant_name']);
/* Simulate MySQL LIKE operator */
if (false === strstr($name, $filter)) {
/* User should be skipped. (Does not match filter) */
continue;
}
}
$users[$row['usr_id']] = $user;
}
return $users;
}
示例8: login
/**
* Login function
*
* @access private
* @return void
*/
function login()
{
global $ilias, $rbacadmin, $ilSetting;
if (!empty($_SERVER[$ilias->getSetting('shib_login')])) {
// Store user's Shibboleth sessionID for logout
$this->session['shibboleth_session_id'] = $_SERVER['Shib-Session-ID'];
// Get loginname of user, new login name is generated if user is new
$username = $this->generateLogin();
// Authorize this user
$this->setAuth($username);
$userObj = new ilObjUser();
// Check wether this account exists already, if not create it
if (!ilObjUser::getUserIdByLogin($username)) {
$newUser["firstname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]);
$newUser["lastname"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]);
$newUser["login"] = $username;
// Password must be random to prevent users from manually log in using the login data from Shibboleth users
$newUser["passwd"] = md5(end(ilUtil::generatePasswords(1)));
$newUser["passwd_type"] = IL_PASSWD_MD5;
if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
$newUser["gender"] = $_SERVER[$ilias->getSetting('shib_gender')];
}
// Save mapping between ILIAS user and Shibboleth uniqueID
$newUser["ext_account"] = $_SERVER[$ilias->getSetting('shib_login')];
// other data
$newUser["title"] = $_SERVER[$ilias->getSetting('shib_title')];
$newUser["institution"] = $_SERVER[$ilias->getSetting('shib_institution')];
$newUser["department"] = $_SERVER[$ilias->getSetting('shib_department')];
$newUser["street"] = $_SERVER[$ilias->getSetting('shib_street')];
$newUser["city"] = $_SERVER[$ilias->getSetting('shib_city')];
$newUser["zipcode"] = $_SERVER[$ilias->getSetting('shib_zipcode')];
$newUser["country"] = $_SERVER[$ilias->getSetting('shib_country')];
$newUser["phone_office"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_office')]);
$newUser["phone_home"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_home')]);
$newUser["phone_mobile"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_phone_mobile')]);
$newUser["fax"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_fax')]);
$newUser["matriculation"] = $_SERVER[$ilias->getSetting('shib_matriculation')];
$newUser["email"] = $this->getFirstString($_SERVER[$ilias->getSetting('shib_email')]);
$newUser["hobby"] = $_SERVER[$ilias->getSetting('shib_hobby')];
$newUser["auth_mode"] = "shibboleth";
// system data
$userObj->assignData($newUser);
$userObj->setTitle($userObj->getFullname());
$userObj->setDescription($userObj->getEmail());
$userObj->setLanguage($this->getFirstString($_SERVER[$ilias->getSetting('shib_language')]));
// Time limit
$userObj->setTimeLimitOwner(7);
$userObj->setTimeLimitUnlimited(1);
$userObj->setTimeLimitFrom(time());
$userObj->setTimeLimitUntil(time());
// Modify user data before creating the user
// Include custom code that can be used to further modify
// certain Shibboleth user attributes
if ($ilias->getSetting('shib_data_conv') && $ilias->getSetting('shib_data_conv') != '' && is_readable($ilias->getSetting('shib_data_conv'))) {
include $ilias->getSetting('shib_data_conv');
}
// Create use in DB
$userObj->create();
$userObj->setActive(1);
$userObj->updateOwner();
//insert user data in table user_data
$userObj->saveAsNew();
// store acceptance of user agreement
//$userObj->writeAccepted();
// Default prefs
$userObj->setPref('hits_per_page', $ilSetting->get('hits_per_page', 30));
$userObj->setPref('show_users_online', $ilSetting->get('show_users_online', 'y'));
// setup user preferences
$userObj->writePrefs();
//set role entries
#$rbacadmin->assignUser($ilias->getSetting('shib_user_default_role'), $userObj->getId(),true);
// New role assignment
include_once './Services/AuthShibboleth/classes/class.ilShibbolethRoleAssignmentRules.php';
ilShibbolethRoleAssignmentRules::doAssignments($userObj->getId(), $_SERVER);
// Authorize this user
$this->setAuth($userObj->getLogin());
} else {
// Update user account
$uid = $userObj->checkUserId();
$userObj->setId($uid);
$userObj->read($uid);
if ($ilias->getSetting('shib_update_gender') && ($_SERVER[$ilias->getSetting('shib_gender')] == 'm' || $_SERVER[$ilias->getSetting('shib_gender')] == 'f')) {
$userObj->setGender($_SERVER[$ilias->getSetting('shib_gender')]);
}
if ($ilias->getSetting('shib_update_title')) {
$userObj->setTitle($_SERVER[$ilias->getSetting('shib_title')]);
}
$userObj->setFirstname($this->getFirstString($_SERVER[$ilias->getSetting('shib_firstname')]));
$userObj->setLastname($this->getFirstString($_SERVER[$ilias->getSetting('shib_lastname')]));
$userObj->setFullname();
if ($ilias->getSetting('shib_update_institution')) {
$userObj->setInstitution($_SERVER[$ilias->getSetting('shib_institution')]);
}
if ($ilias->getSetting('shib_update_department')) {
//.........这里部分代码省略.........
示例9: updateUser
/**
* update existing user
*
* @access protected
*/
protected function updateUser(ilECSUser $user, $a_local_user_id)
{
global $ilClientIniFile, $ilLog, $rbacadmin;
$user_obj = new ilObjUser($a_local_user_id);
$user_obj->setFirstname($user->getFirstname());
$user_obj->setLastname($user->getLastname());
$user_obj->setEmail($user->getEmail());
$user_obj->setInstitution($user->getInstitution());
$user_obj->setActive(true);
$until = $user_obj->getTimeLimitUntil();
$user_obj->setTimeLimitFrom(time() - 5);
if ($until < time() + $ilClientIniFile->readVariable('session', 'expire')) {
$user_obj->setTimeLimitUntil(time() + $ilClientIniFile->readVariable("session", "expire"));
}
$user_obj->update();
$user_obj->refreshLogin();
if ($global_role = $this->getCurrentServer()->getGlobalRole()) {
$rbacadmin->assignUser($this->getCurrentServer()->getGlobalRole(), $user_obj->getId(), true);
}
$ilLog->write(__METHOD__ . ': Finished update of remote user with usr_id: ' . $user->getImportId());
return $user_obj->getLogin();
}