本文整理汇总了PHP中EfrontUser::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontUser::createUser方法的具体用法?PHP EfrontUser::createUser怎么用?PHP EfrontUser::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EfrontUser
的用法示例。
在下文中一共展示了EfrontUser::createUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mktime
$user_data[$field['name']] = mktime($values[$field['name']]['H'], $values[$field['name']]['i'], $values[$field['name']]['s'], $values[$field['name']]['M'], $values[$field['name']]['d'], $values[$field['name']]['Y']);
} else {
if ($field['type'] == 'branchinfo') {
$self_registered_jobs[] = array("branch_ID" => $values[$field['name'] . "_branches"], "job_description" => $_POST[$field['name'] . "_jobs"], "supervisor" => $_POST[$field['name'] . "_supervisors"], "mandatory" => $field['mandatory']);
} else {
if ($field['type'] == 'groupinfo') {
if ($values[$field['name'] . "_groups"]) {
$groupToAdd = new EfrontGroup($values[$field['name'] . "_groups"]);
}
} else {
$user_data[$field['name']] = $values[$field['name']];
}
}
}
}
$newUser = EfrontUser::createUser($user_data);
$encrypted = true;
//needed for autologin
EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_REGISTER, "users_LOGIN" => $user_data['login'], "users_name" => $user_data['name'], "users_surname" => $user_data['surname'], "entity_name" => $user_data['password']));
// send not-visited notifications for the newly registered user
//EfrontEvent::triggerEvent(array("type" => (-1) * EfrontEvent::SYSTEM_VISITED, "users_LOGIN" => $user_data['login'], "users_name" => $user_data['name'], "users_surname" => $user_data['surname']));
if (G_VERSIONTYPE == 'enterprise') {
#cpp#ifdef ENTERPRISE
try {
if (isset($groupToAdd)) {
$groupToAdd->addUsers($values['login']);
}
$new_employees_content['users_login'] = $values['login'];
EfrontHcdUser::createUser($new_employees_content);
foreach ($self_registered_jobs as $job_assigned) {
if ($job_assigned['branch_ID'] != 0 || $job_assigned['mandatory']) {
示例2: importUsers
//.........这里部分代码省略.........
// throw new Exception (_PLEASECHECKYOURCSVFILEFORMAT, EfrontSystemException::ILLEGAL_CSV);
for ($i = 1; $i < sizeof($fileContents); $i++) {
//$csvUser = explode($separator, $fileContents[$i]);
$csvUser = str_getcsv($fileContents[$i], $separator);
unset($csvUser[$unused]);
if (sizeof($csvUser) != sizeof($fields)) {
throw new Exception(_PLEASECHECKYOURCSVFILEFORMAT . ': ' . _NUMBEROFFIELDSMUSTBE . ' ' . sizeof($fields) . ' ' . _BUTFOUND . ' ' . sizeof($csvUser), EfrontSystemException::ILLEGAL_CSV);
}
$csvUser = array_combine($fields, $csvUser);
array_walk($csvUser, create_function('&$v, $k', '$v=trim($v);'));
if (in_array($csvUser['login'], $existingUsers['login']) && $replaceUsers) {
$existingUser = EfrontUserFactory::factory($csvUser['login']);
$existingUser->delete();
}
if (!in_array($csvUser['login'], $existingUsers['login']) || $replaceUsers) {
if (!isset($csvUser['password']) || !$csvUser['password']) {
$csvUser['password'] = $csvUser['login'];
}
// Check the user-type existence by name
if ($csvUser['user_type_name'] != "" && isset($userTypesTable[$csvUser['user_type_name']])) {
// If there is a mismatch between the imported custom type basic type and the current basic type
// then set no custom type
if ($userTypesTable[$csvUser['user_type_name']]['basic_user_type'] != $csvUser['user_type']) {
$csvUser['user_types_ID'] = 0;
} else {
$csvUser['user_types_ID'] = $userTypesTable[$csvUser['user_type_name']]['id'];
}
} else {
$csvUser['user_types_ID'] = 0;
}
unset($csvUser['user_type_name']);
if (!$csvUser['user_type']) {
$csvUser['user_type'] = 'student';
}
//If user type is not valid, don't insert that user
if ($csvUser['user_type'] != "administrator" && $csvUser['user_type'] != "professor" && $csvUser['user_type'] != "student") {
$messages[] = '"' . $csvUser['login'] . '": ' . _INVALIDUSERTYPE;
unset($csvUser);
continue;
}
// If we are not in enterprise version then $csvEmployeeProperties is used as a buffer
// This is done to enable enterprise <-> Enteprise, educational <-> educational, enterprise <-> educational imports/exports
$csvEmployeeProperties = $csvUser;
if (G_VERSIONTYPE == 'enterprise') {
#cpp#ifdef ENTERPRISE
// Copy all fields and remove the user ones -> leaving only employee related fields
$csvEmployeeProperties['users_login'] = $csvUser['login'];
}
#cpp#endif
// Delete and recreate $csvUser to keep only the fields in userFields
unset($csvUser);
foreach ($userFields as $field) {
if (isset($csvEmployeeProperties[$field])) {
$csvUser[$field] = $csvEmployeeProperties[$field];
if (G_VERSIONTYPE == 'enterprise') {
#cpp#ifdef ENTERPRISE
unset($csvEmployeeProperties[$field]);
}
#cpp#endif
}
}
try {
if (G_VERSIONTYPE == 'enterprise') {
#cpp#ifdef ENTERPRISE
$user = EfrontUser::createUser($csvUser);
if (isset($csvEmployeeProperties['branch_name'])) {
$result = eF_getTableData("module_hcd_branch", "branch_ID", "name='" . $csvEmployeeProperties['branch_name'] . "'");
if ($result[0]['branch_ID']) {
$branchId = $result[0]['branch_ID'];
}
unset($csvEmployeeProperties['branch_name']);
}
if (isset($csvEmployeeProperties['job_name'])) {
$result = eF_getTableData("module_hcd_job_description", "job_description_ID", "description='" . $csvEmployeeProperties['job_name'] . "'");
if ($result[0]['job_description_ID']) {
$jobId = $result[0]['job_description_ID'];
}
unset($csvEmployeeProperties['job_name']);
}
if (isset($csvEmployeeProperties['job_role'])) {
$csvEmployeeProperties['job_role'] ? $jobRole = 1 : ($jobRole = 0);
unset($csvEmployeeProperties['job_role']);
}
$user->aspects['hcd'] = EfrontHcdUser::createUser($csvEmployeeProperties);
if (isset($branchId) && isset($jobId) && isset($jobRole)) {
$user->aspects['hcd']->addJob($user, $jobId, $branchId, $jobRole);
}
$newUsers[] = $user;
} else {
#cpp#else
$newUsers[] = EfrontUser::createUser($csvUser);
}
#cpp#endif
} catch (Exception $e) {
$messages[] = '"' . $csvUser['login'] . '": ' . $e->getMessage() . ' (' . $e->getCode() . ')';
}
}
}
return array($newUsers, $messages);
}
示例3: importData
protected function importData($line, $type, $data)
{
//pr($line);exit;
try {
switch ($type) {
case "users":
$newUser = EfrontUser::createUser($data);
$this->log["success"][] = _LINE . " {$line}: " . _IMPORTEDUSER . " " . $newUser->login;
break;
case "users_to_courses":
//Check if a user exists and whether it has the same case
$userFound = false;
if (!in_array($data['users_login'], $this->allUserLogins)) {
//For case-insensitive matches
foreach ($this->allUserLogins as $login) {
if (mb_strtolower($data['users_login']) == mb_strtolower($login)) {
$data['users_login'] = $login;
$userFound = true;
}
}
} else {
$userFound = true;
}
if ($userFound) {
$courses_name = trim($data['course_name']);
$courses_ID = $this->getCourseByName($courses_name);
unset($data['course_name']);
if ($courses_ID) {
foreach ($courses_ID as $course_ID) {
$data['courses_ID'] = $course_ID;
$course = new EfrontCourse($course_ID);
if (is_null($this->course_users[$course_ID])) {
$result = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID={$course_ID} AND archive=0");
$this->course_users[$course_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
}
if (isset($this->course_users[$course_ID][$data['users_login']])) {
throw new Exception("User is already assigned to the course", self::USER_TO_COURSE_EXISTS);
}
//$course -> addUsers($data['users_login'], (isset($data['user_type']) && $data['user_type']?$data['user_type']:"student"));
$course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
$where = "users_login = '" . $data['users_login'] . "' AND courses_ID = " . $data['courses_ID'];
$data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0);
EfrontCourse::persistCourseUsers($data, $where, $data['courses_ID'], $data['users_login']);
if ($data['active']) {
$course->confirm($data['users_login']);
} else {
$course->unconfirm($data['users_login']);
}
$this->course_users[$course_ID][$data['users_login']] = $data['users_login'];
$this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login'];
}
} else {
if ($courses_name != "") {
$course = EfrontCourse::createCourse(array("name" => $courses_name));
$this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSE . " " . $courses_name;
$course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student");
$courses_ID = $course->course['id'];
$this->courseNamesToIds[$courses_name] = array($courses_ID);
$where = "users_login = '" . $data['users_login'] . "' AND courses_ID = " . $courses_ID;
EfrontCourse::persistCourseUsers($data, $where, $courses_ID, $data['users_login']);
if ($data['active']) {
$course->confirm($data['users_login']);
} else {
$course->unconfirm($data['users_login']);
}
$this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login'];
} else {
$this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDCOURSE . " " . $courses_name;
}
}
} else {
$this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login'];
}
break;
case "users_to_lessons":
//Check if a user exists and whether it has the same case
$userFound = false;
if (!in_array($data['users_login'], $this->allUserLogins)) {
//For case-insensitive matches
foreach ($this->allUserLogins as $login) {
if (mb_strtolower($data['users_login']) == mb_strtolower($login)) {
$data['users_login'] = $login;
$userFound = true;
}
}
} else {
$userFound = true;
}
if ($userFound) {
$lessons_name = trim($data['lesson_name']);
$lessons_ID = $this->getLessonByName($lessons_name);
unset($data['lesson_name']);
if ($lessons_ID) {
foreach ($lessons_ID as $lesson_ID) {
$data['lessons_ID'] = $lesson_ID;
$lesson = new EfrontLesson($lesson_ID);
if (is_null($this->lesson_users[$lesson_ID])) {
$result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0");
$this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']);
}
//.........这里部分代码省略.........
示例4: array
}
if ($form->isSubmitted() && $form->validate()) {
try {
$values = $form->exportValues();
$roles = EfrontUser::getRoles();
$userProperties = array('login' => $values['login'], 'name' => $values['name'], 'surname' => $values['surname'], 'active' => $values['active'], 'email' => $values['email'], 'user_type' => $roles[$values['user_type']], 'languages_NAME' => $values['languages_NAME'], 'timezone' => $values['timezone'], 'timestamp' => time(), 'password' => $values['password_'], 'user_types_ID' => is_numeric($values['user_type']) ? $values['user_type'] : 0, 'short_description' => $values['short_description'], 'comments' => $values['comments']);
foreach ($userProfile as $field) {
//Get the custom fields values
if ($field['type'] == "date") {
$timestampValues = $values[$field['name']];
$values[$field['name']] = mktime($timestampValues['H'], $timestampValues['i'], 0, $timestampValues['M'], $timestampValues['d'], $timestampValues['Y']);
}
$userProperties[$field['name']] = $values[$field['name']];
}
if (isset($_GET['add_user'])) {
$editedUser = EfrontUser::createUser($userProperties);
//EfrontEvent::triggerEvent(array("type" => (-1) * EfrontEvent::SYSTEM_VISITED, "users_LOGIN" => $userProperties['login'], "users_name" => $userProperties['name'], "users_surname" => $userProperties['surname']));
} else {
unset($userProperties['timestamp']);
//!$editedUser->user['pending'] OR $editedUser->user['pending'] = !$userProperties['active']; //If the user was pending, then set his status as the opposite of
if ($editedUser->user['pending']) {
$editedUser->user['pending'] = !$userProperties['active'];
EfrontEvent::triggerEvent(array("type" => EfrontEvent::SYSTEM_ON_ADMIN_ACTIVATION, "users_LOGIN" => $editedUser->user['login'], "users_name" => $editedUser->user['name'], "users_surname" => $editedUser->user['surname'], "timestamp" => time(), "entity_name" => time()));
}
foreach ($constrainAccess as $value) {
unset($userProperties[$value]);
}
if ($values['ldap_user'] && !$editedUser->isLdapUser) {
$userProperties['password'] = 'ldap';
} else {
if (!$values['password_']) {
示例5: _login
/**
* Process the variables sent by the Idp and perform the login with SAML
* @param $sso array the value defined in domain's Configuration table
* @param $values array sent by IdP
*/
protected function _login($attributes)
{
if (!empty($attributes[$this->_sso_settings['saml_targeted_id']])) {
// user comes authenticated in index page
$login = $attributes[$this->_sso_settings['saml_targeted_id']][0];
try {
$user = EfrontUserFactory::factory($login);
} catch (\Exception $e) {
$login = null;
}
if (is_null($login)) {
// User doesn't exist. Create user
if (0 && reachedPlanLimit()) {
//@todo
// TemplateController::setMessage(("You have reached the maximum active users allowed by the selected plan."), 'warning');
} else {
$fields = array('login' => $attributes[$this->_sso_settings['saml_targeted_id']][0], 'password' => sha1($attributes[$this->_sso_settings['saml_targeted_id']][0]), 'name' => $attributes[$this->_sso_settings['saml_first_name']][0], 'surname' => $attributes[$this->_sso_settings['saml_last_name']][0], 'active' => 1, 'email' => $attributes[$this->_sso_settings['saml_email']][0]);
$user = EfrontUser::createUser($fields);
$user->login($user->user['password'], true);
eF_redirect($user->user['user_type'] . '.php');
}
} else {
// User exists
$fields = array('name' => $attributes[$this->_sso_settings['saml_first_name']][0], 'surname' => $attributes[$this->_sso_settings['saml_last_name']][0], 'email' => $attributes[$this->_sso_settings['saml_email']][0]);
$user = EfrontUserFactory::factory($login);
//$user->setFields($fields)->save(); //update whatever changed
$user->login($user->user['password'], true);
eF_redirect($user->user['user_type'] . '.php');
}
}
/*
else{//User is not authenticates, set SAML session to be ready for authentication
$session = \SimpleSAML_Session::getInstance();
$sso['domain']=$this->_domain;
$session->setData("Array", "sso", $this->_sso_settings);
}
*/
}
示例6: catch
echo "</xml>";
exit;
}
$insert[$value['name']] = $_GET[$value['name']];
}
}
$languages = EfrontSystem::getLanguages(true, true);
if ($_GET['languages'] != "" && in_array($_GET['languages'], array_keys($languages)) === false) {
echo "<xml>";
echo "<status>error</status>";
echo "<message>Invalid language</message>";
echo "</xml>";
exit;
}
try {
$user = EfrontUser::createUser($insert);
echo "<xml>";
echo "<status>ok</status>";
echo "</xml>";
} catch (Exception $e) {
if ($e->getCode() == EfrontUserException::INVALID_LOGIN) {
echo "<xml>";
echo "<status>error</status>";
echo "<message>Invalid login format</message>";
echo "</xml>";
exit;
} elseif ($e->getCode() == EfrontUserException::MAXIMUM_REACHED) {
echo "<xml>";
echo "<status>error</status>";
echo "<message>Maximum number of users reached</message>";
echo "</xml>";