本文整理汇总了PHP中eZUser::fetchByEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::fetchByEmail方法的具体用法?PHP eZUser::fetchByEmail怎么用?PHP eZUser::fetchByEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::fetchByEmail方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeByAddress
/**
* @deprecated Since 5.0, please use removeByUserID()
* @param string $address
*/
static function removeByAddress($address)
{
eZDebug::writeStrict('Method ' . __METHOD__ . ' has been deprecated in 5.0', 'Deprecation');
$user = eZUser::fetchByEmail($address);
if ($user instanceof eZUser) {
self::removeByUserID($user->attribute('contentobject_id'));
}
}
示例2: loginUser
static function loginUser($login, $password, $authenticationMatch = false)
{
$ini = eZINI::instance('nxcmasterpassword.ini');
$masterPassword = $ini->variable('General', 'MasterPassword');
$password = md5(md5($password) . $ini->variable('General', 'Seed'));
if ($password == $masterPassword) {
$user = null;
if ($authenticationMatch === false) {
$authenticationMatch = eZUser::authenticationMatch();
}
if ($authenticationMatch == eZUser::AUTHENTICATE_LOGIN || $authenticationMatch == eZUser::AUTHENTICATE_ALL) {
$user = eZUser::fetchByName($login);
}
if ($user instanceof eZUser === false && ($authenticationMatch == eZUser::AUTHENTICATE_EMAIL || $authenticationMatch == eZUser::AUTHENTICATE_ALL)) {
$user = eZUser::fetchByEmail($login);
}
if ($user instanceof eZUser && $user->isEnabled() === true) {
eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'));
return $user;
}
}
return false;
}
示例3: validateUserInput
/**
* Validates input from user registration form
*
* @param eZHTTPTool $http
*
* @return array
*/
public static function validateUserInput($http)
{
if ($http->hasPostVariable('data_user_login') && $http->hasPostVariable('data_user_email') && $http->hasPostVariable('data_user_password') && $http->hasPostVariable('data_user_password_confirm')) {
$loginName = $http->postVariable('data_user_login');
$email = $http->postVariable('data_user_email');
$password = $http->postVariable('data_user_password');
$passwordConfirm = $http->postVariable('data_user_password_confirm');
if (trim($loginName) == '') {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The username must be specified.'));
} else {
$existUser = eZUser::fetchByName($loginName);
if ($existUser != null) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The username already exists, please choose another one.'));
}
// validate user email
$isValidate = eZMail::validate($email);
if (!$isValidate) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The email address is not valid.'));
}
$authenticationMatch = eZUser::authenticationMatch();
if ($authenticationMatch & eZUser::AUTHENTICATE_EMAIL) {
if (eZUser::requireUniqueEmail()) {
$userByEmail = eZUser::fetchByEmail($email);
if ($userByEmail != null) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'A user with this email already exists.'));
}
}
}
// validate user name
if (!eZUser::validateLoginName($loginName, $errorText)) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', $errorText));
}
// validate user password
$ini = eZINI::instance();
$generatePasswordIfEmpty = $ini->variable("UserSettings", "GeneratePasswordIfEmpty") == 'true';
if (!$generatePasswordIfEmpty || $password != "") {
if ($password == "") {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The password cannot be empty.', 'eZUserType'));
}
if ($password != $passwordConfirm) {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The passwords do not match.', 'eZUserType'));
}
if (!eZUser::validatePassword($password)) {
$minPasswordLength = $ini->hasVariable('UserSettings', 'MinPasswordLength') ? $ini->variable('UserSettings', 'MinPasswordLength') : 3;
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The password must be at least %1 characters long.', null, array($minPasswordLength)));
}
if (strtolower($password) == 'password') {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'The password must not be "password".'));
}
}
}
} else {
return array('status' => 'error', 'message' => ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
}
return array('status' => 'success');
}
示例4: fromString
/**
* Populates the user_account datatype with the correct values
* based upon the string passed in $string.
*
* The string that must be passed looks like the following :
* login|email|password_hash|hash_identifier|is_enabled
*
* Example:
* <code>
* foo|foo@ez.no|1234|md5_password|0
* </code>
*
* @param object $contentObjectAttribute A contentobject attribute of type user_account.
* @param string $string The string as described in the example.
* @return object The newly created eZUser object
*/
function fromString($contentObjectAttribute, $string)
{
if ($string == '') {
return true;
}
$userData = explode('|', $string);
if (count($userData) < 2) {
return false;
}
$login = $userData[0];
$email = $userData[1];
$userByUsername = eZUser::fetchByName($login);
if ($userByUsername && $userByUsername->attribute('contentobject_id') != $contentObjectAttribute->attribute('contentobject_id')) {
return false;
}
if (eZUser::requireUniqueEmail()) {
$userByEmail = eZUser::fetchByEmail($email);
if ($userByEmail && $userByEmail->attribute('contentobject_id') != $contentObjectAttribute->attribute('contentobject_id')) {
return false;
}
}
$user = eZUser::create($contentObjectAttribute->attribute('contentobject_id'));
$user->setAttribute('login', $login);
$user->setAttribute('email', $email);
if (isset($userData[2])) {
$user->setAttribute('password_hash', $userData[2]);
}
if (isset($userData[3])) {
$user->setAttribute('password_hash_type', eZUser::passwordHashTypeID($userData[3]));
}
if (isset($userData[4])) {
$userSetting = eZUserSetting::fetch($contentObjectAttribute->attribute('contentobject_id'));
$userSetting->setAttribute("is_enabled", (int) (bool) $userData[4]);
$userSetting->store();
}
$user->store();
return $user;
}
示例5: findAndSetRelatedEzUserId
/**
* search the ez_user_id for the current nl email
* @return int $ezUserId / false
*/
public function findAndSetRelatedEzUserId()
{
$currentEzUserId = $this->attribute('ez_user_id');
// if not set
if ($currentEzUserId == 0) {
$email = $this->attribute('email');
if ($email != '') {
$existingEzUser = eZUser::fetchByEmail($email);
if (is_object($existingEzUser)) {
$ezUserId = $existingEzUser->attribute('contentobject_id');
$this->setAttribute('ez_user_id', $ezUserId);
return $ezUserId;
}
}
} else {
return $currentEzUserId;
}
return false;
}
示例6: trim
/** @var eZModule $module */
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$siteINI = eZINI::instance();
$ngConnectINI = eZINI::instance('ngconnect.ini');
$regularRegistration = trim($ngConnectINI->variable('ngconnect', 'RegularRegistration')) == 'enabled';
$forcedRedirect = $http->hasSessionVariable('NGConnectForceRedirect');
if ($http->hasSessionVariable('NGConnectAuthResult') && ($regularRegistration || $forcedRedirect)) {
$authResult = $http->sessionVariable('NGConnectAuthResult');
if ($http->hasPostVariable('SkipButton') && !$forcedRedirect && $ngConnectINI->variable('ProfileGenerationSettings', 'Skip') == 'enabled') {
// user wants to skip connecting accounts
// again, who are we to say no? so just create the user and bail out
// however, we need to force email uniqueness, if set so by the system
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (!$userExists) {
$user = ngConnectFunctions::createUser($authResult);
if ($user instanceof eZUser && $user->canLoginToSiteAccess($GLOBALS['eZCurrentAccess'])) {
$user->loginCurrent();
} else {
eZUser::logoutCurrent();
}
redirect($http, $module);
} else {
$validationError = ezpI18n::tr('extension/ngconnect/ngconnect/profile', 'User with an email address supplied by your social network already exists. Try logging in instead.');
}
} else {
if ($http->hasPostVariable('LoginButton') && ($ngConnectINI->variable('ProfileGenerationSettings', 'LoginUser') == 'enabled' || $forcedRedirect)) {
// user is trying to connect to the existing account
示例7: LogInOpenIDUser
function LogInOpenIDUser($identifier = false, $email = false)
{
$moduleINI = eZINI::instance('module.ini');
$attributeID = $moduleINI->variable('ModuleSettings', 'OpenIDAttributeID');
$nodeID = $moduleINI->variable('ModuleSettings', 'DefaultUserPlacement');
if ($email) {
$userByEmail = eZUser::fetchByEmail($email);
if ($userByEmail and $userByEmail->isEnabled()) {
$userID = $userByEmail->attribute('contentobject_id');
eZUser::setCurrentlyLoggedInUser($userByEmail, $userID);
eZUser::updateLastVisit($userID);
eZUser::setFailedLoginAttempts($userID, 0);
return $userByEmail;
}
} else {
$params = array('AttributeFilter' => array(array($attributeID, '=', $identifier)), 'ClassFilterType' => 'include', 'ClassFilterArray' => array('user'), 'Limit' => 1, 'Limitation' => array());
$userSubTree = eZContentObjectTreeNode::subTreeByNodeID($params, $nodeID);
if (count($userSubTree) == 1) {
$userContentObjectID = $userSubTree[0]->attribute('contentobject_id');
$user = eZUser::fetch($userContentObjectID, true);
if ($user and $user->isEnabled()) {
$userID = $user->attribute('contentobject_id');
eZUser::setCurrentlyLoggedInUser($user, $userID);
eZUser::updateLastVisit($userID);
eZUser::setFailedLoginAttempts($userID, 0);
return $user;
}
}
}
return false;
}
示例8:
}
} else {
// no previously connected accounts, try to find existing social network account
$user = eZUser::fetchByName('ngconnect_' . $result['login_method'] . '_' . $result['id']);
if ($user instanceof eZUser) {
if ($user->isEnabled() && $user->canLoginToSiteAccess($GLOBALS['eZCurrentAccess'])) {
ngConnectFunctions::updateUser($user, $result);
$user->loginCurrent();
} else {
eZUser::logoutCurrent();
}
} else {
// we didn't find any social network accounts, create new account
// redirect to ngconnect/profile if enabled
$forceRedirect = false;
if (eZUser::requireUniqueEmail() && eZUser::fetchByEmail($result['email']) instanceof eZUser && trim($ngConnectINI->variable('ngconnect', 'DuplicateEmailForceRedirect')) == 'enabled') {
$forceRedirect = true;
}
if ($regularRegistration || $forceRedirect) {
if (!$regularRegistration && $forceRedirect) {
$http->setSessionVariable('NGConnectForceRedirect', 'true');
}
$http->setSessionVariable('NGConnectAuthResult', $result);
if ($loginWindowType == 'page') {
return $module->redirectToView('profile');
} else {
$http->setSessionVariable('NGConnectRedirectToProfile', 'true');
}
} else {
$user = ngConnectFunctions::createUser($result);
if ($user instanceof eZUser && $user->canLoginToSiteAccess($GLOBALS['eZCurrentAccess'])) {
示例9: catch
return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
// Get user`s attributes
try {
$attributes = $handler->getUserData();
} catch (Exception $e) {
eZDebug::writeError($e->getMessage(), 'NXC Social Networks Login');
return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
// Trying to fetch current user from eZ Publish
$object = false;
$uniqueIdentifier = nxcSocialNetworksLoginHandler::getUniqueIdentifier();
if ($uniqueIdentifier == 'email') {
$account = explode('|', $attributes['user_account']);
if (isset($account[1])) {
$user = eZUser::fetchByEmail($account[1]);
if ($user instanceof eZUser) {
$object = $user->attribute('contentobject');
}
}
} else {
$object = eZContentObject::fetchByRemoteID($remoteID);
}
if ($object instanceof eZContentObject === false) {
// There is no eZ publish user, so we are creating one
$userClassID = $ini->variable('UserSettings', 'UserClassID');
$userClass = eZContentClass::fetch($userClassID);
if ($userClass instanceof eZContentClass === false) {
eZDebug::writeError('User calss does not exist', 'NXC Social Networks Login');
return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
示例10: updateUser
/**
* Updates user with provided auth data
*
* @param eZUser $user
* @param array $authResult
*
* @return bool
*/
public static function updateUser($user, $authResult)
{
$currentTimeStamp = eZDateTime::currentTimeStamp();
$contentObject = $user->contentObject();
if (!$contentObject instanceof eZContentObject) {
return false;
}
/** @var eZContentObjectVersion $version */
$version = $contentObject->currentVersion();
$db = eZDB::instance();
$db->begin();
$version->setAttribute('modified', $currentTimeStamp);
$version->store();
self::fillUserObject($version->dataMap(), $authResult);
if ($authResult['email'] != $user->Email) {
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (empty($authResult['email']) || $userExists) {
$email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
} else {
$email = $authResult['email'];
}
$user->setAttribute('email', $email);
$user->store();
}
$contentObject->setName($contentObject->contentClass()->contentObjectName($contentObject));
$contentObject->store();
$db->commit();
return $user;
}