本文整理汇总了PHP中erLhcoreClassModelUser::userExists方法的典型用法代码示例。如果您正苦于以下问题:PHP erLhcoreClassModelUser::userExists方法的具体用法?PHP erLhcoreClassModelUser::userExists怎么用?PHP erLhcoreClassModelUser::userExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类erLhcoreClassModelUser
的用法示例。
在下文中一共展示了erLhcoreClassModelUser::userExists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginBySSO
public static function loginBySSO($params)
{
$settings = (include 'extension/singlesignon/settings/settings.ini.php');
// Try to find operator by our logins
if (isset($params[$settings['attr_map']['username']][0])) {
$username = $params[$settings['attr_map']['username']][0];
if (erLhcoreClassModelUser::userExists($username)) {
$user = array_shift(erLhcoreClassModelUser::getUserList(array('limit' => 1, 'filter' => array('username'))));
erLhcoreClassUser::instance()->setLoggedUser($user->id);
} else {
$user = new erLhcoreClassModelUser();
foreach ($settings['attr_map'] as $attr => $ssoAttr) {
$user->{$attr} = $params[$settings['attr_map'][$attr]][0];
}
foreach ($settings['default_attributes'] as $attr => $value) {
$user->{$attr} = $value;
}
$user->password = sha1(erLhcoreClassModelForgotPassword::randomPassword() . rand(0, 1000) . microtime());
$user->saveThis();
// Set that users sees all pending chats
erLhcoreClassModelUserSetting::setSetting('show_all_pending', 1, $user->id);
// Set default departments
erLhcoreClassUserDep::addUserDepartaments($settings['default_departments'], $user->id, $user);
// Cleanup if previously existed
erLhcoreClassModelGroupUser::removeUserFromGroups($user->id);
// Assign user to default group
foreach ($settings['default_user_groups'] as $group_id) {
$groupUser = new erLhcoreClassModelGroupUser();
$groupUser->group_id = $group_id;
$groupUser->user_id = $user->id;
$groupUser->saveThis();
}
erLhcoreClassUser::instance()->setLoggedUser($user->id);
}
return true;
} else {
throw new Exception('Username field not found');
}
}
示例2: array
<?php
$tpl = erLhcoreClassTemplate::getInstance('lhuser/edit.tpl.php');
$UserData = erLhcoreClassUser::getSession()->load('erLhcoreClassModelUser', (int) $Params['user_parameters']['user_id']);
if (isset($_POST['Update_account']) || isset($_POST['Save_account'])) {
$definition = array('Password' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Password1' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'), 'Name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Surname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Username' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'JobTitle' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Skype' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'XMPPUsername' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserTimeZone' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserDisabled' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'HideMyStatus' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'UserInvisible' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'DefaultGroup' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'int', null, FILTER_REQUIRE_ARRAY));
if (!isset($_POST['csfr_token']) || !$currentUser->validateCSFRToken($_POST['csfr_token'])) {
erLhcoreClassModule::redirect('user/userlist');
exit;
}
$form = new ezcInputForm(INPUT_POST, $definition);
$Errors = array();
if (!$form->hasValidData('Username')) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'Please enter a username!');
} elseif ($form->hasValidData('Username') && $form->Username != $UserData->username && !erLhcoreClassModelUser::userExists($form->Username)) {
$UserData->username = $form->Username;
} elseif ($form->hasValidData('Username') && $form->Username != $UserData->username) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/account', 'User exists!');
}
if (!$form->hasValidData('Email')) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Wrong email address');
}
if (!$form->hasValidData('Name') || $form->Name == '') {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/edit', 'Please enter a name');
}
if ($form->hasValidData('Surname') && $form->Surname != '') {
$UserData->surname = $form->Surname;
} else {
$UserData->surname = '';
}
if ($form->hasValidData('UserTimeZone') && $form->UserTimeZone != '') {
示例3:
$UserData->time_zone = '';
}
if ($form->hasValidData('Skype') && $form->Skype != '') {
$UserData->skype = $form->Skype;
} else {
$UserData->skype = '';
}
if ($form->hasValidData('XMPPUsername') && $form->XMPPUsername != '') {
$UserData->xmpp_username = $form->XMPPUsername;
} else {
$UserData->xmpp_username = '';
}
if (!$form->hasValidData('Username') || $form->Username == '') {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/new', 'Please enter a username');
}
if ($form->hasValidData('Username') && $form->Username != '' && erLhcoreClassModelUser::userExists($form->Username) === true) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/new', 'User exists');
}
if (!$form->hasValidData('Password') || !$form->hasValidData('Password1') || $form->Password == '' || $form->Password1 == '' || $form->Password != $form->Password1) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/new', 'Passwords mismatch');
}
if ($form->hasValidData('DefaultGroup')) {
$UserData->user_groups_id = $form->DefaultGroup;
} else {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/new', 'Please choose a default user group');
}
if ($form->hasValidData('UserDisabled') && $form->UserDisabled == true) {
$UserData->disabled = 1;
} else {
$UserData->disabled = 0;
}
示例4: validateAccount
public static function validateAccount(&$userData)
{
$definition = array('Password' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Password1' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Email' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'validate_email'), 'Name' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'Surname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::REQUIRED, 'unsafe_raw'), 'Username' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'JobTitle' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'Skype' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'XMPPUsername' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'ChatNickname' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserTimeZone' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'), 'UserInvisible' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'), 'ReceivePermissionRequest' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'boolean'));
$form = new ezcInputForm(INPUT_POST, $definition);
$Errors = array();
if (!$form->hasValidData('Username') || $form->Username == '') {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Please enter a username');
} else {
if ($form->Username != $userData->username) {
$userData->username = $form->Username;
if (erLhcoreClassModelUser::userExists($userData->username) === true) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'User exists');
}
}
}
if ($form->hasValidData('Password') && $form->hasValidData('Password1')) {
$userData->password_temp_1 = $form->Password;
$userData->password_temp_2 = $form->Password1;
}
if ($form->hasInputField('Password') && (!$form->hasInputField('Password1') || $form->Password != $form->Password1)) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Passwords mismatch');
} else {
if ($form->hasInputField('Password') && $form->hasInputField('Password1') && $form->Password != '' && $form->Password1 != '') {
$userData->setPassword($form->Password);
$userData->password_front = $form->Password;
}
}
if ($form->hasValidData('ChatNickname') && $form->ChatNickname != '') {
$userData->chat_nickname = $form->ChatNickname;
} else {
$userData->chat_nickname = '';
}
if (!$form->hasValidData('Email')) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Wrong email address');
} else {
$userData->email = $form->Email;
}
if (!$form->hasValidData('Name') || $form->Name == '') {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('user/validator', 'Please enter a name');
} else {
$userData->name = $form->Name;
}
if ($form->hasValidData('Surname') && $form->Surname != '') {
$userData->surname = $form->Surname;
} else {
$userData->surname = '';
}
if ($form->hasValidData('JobTitle') && $form->JobTitle != '') {
$userData->job_title = $form->JobTitle;
} else {
$userData->job_title = '';
}
if ($form->hasValidData('UserTimeZone') && $form->UserTimeZone != '') {
$userData->time_zone = $form->UserTimeZone;
CSCacheAPC::getMem()->setSession('lhc_user_timezone', $userData->time_zone, true);
} else {
CSCacheAPC::getMem()->setSession('lhc_user_timezone', '', true);
$userData->time_zone = '';
}
if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'changevisibility')) {
if ($form->hasValidData('UserInvisible') && $form->UserInvisible == true) {
$userData->invisible_mode = 1;
} else {
$userData->invisible_mode = 0;
}
}
if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'receivepermissionrequest')) {
if ($form->hasValidData('ReceivePermissionRequest') && $form->ReceivePermissionRequest == true) {
$userData->rec_per_req = 1;
} else {
$userData->rec_per_req = 0;
}
}
if (erLhcoreClassUser::instance()->hasAccessTo('lhuser', 'changeskypenick')) {
if ($form->hasValidData('Skype') && $form->Skype != '') {
$userData->skype = $form->Skype;
} else {
$userData->skype = '';
}
}
if ($form->hasValidData('XMPPUsername') && $form->XMPPUsername != '') {
$userData->xmpp_username = $form->XMPPUsername;
} else {
$userData->xmpp_username = '';
}
return $Errors;
}