本文整理汇总了PHP中eZUser::updateLastVisit方法的典型用法代码示例。如果您正苦于以下问题:PHP eZUser::updateLastVisit方法的具体用法?PHP eZUser::updateLastVisit怎么用?PHP eZUser::updateLastVisit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZUser
的用法示例。
在下文中一共展示了eZUser::updateLastVisit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instance
/**
* Returns a shared instance of the eZUser class pr $id value.
* If user can not be fetched, then anonymous user is returned and
* a warning trown, if anonymous user can not be fetched, then NoUser
* is returned and another warning is thrown.
*
* @param int|false $id On false: Gets current user id from session
* or from {@link eZUser::anonymousId()} if not set.
* @return eZUser
*/
static function instance($id = false)
{
if (!empty($GLOBALS["eZUserGlobalInstance_{$id}"])) {
return $GLOBALS["eZUserGlobalInstance_{$id}"];
}
$userId = $id;
$currentUser = null;
$http = eZHTTPTool::instance();
$anonymousUserID = self::anonymousId();
$sessionHasStarted = eZSession::hasStarted();
// If not specified get the current user
if ($userId === false) {
if ($sessionHasStarted) {
$userId = $http->sessionVariable('eZUserLoggedInID');
if (!is_numeric($userId)) {
$userId = $anonymousUserID;
eZSession::setUserID($userId);
$http->setSessionVariable('eZUserLoggedInID', $userId);
}
} else {
$userId = $anonymousUserID;
eZSession::setUserID($userId);
}
}
// Check user cache (this effectivly fetches user from cache)
// user not found if !isset( isset( $userCache['info'][$userId] ) )
$userCache = self::getUserCacheByUserId($userId);
if (isset($userCache['info'][$userId])) {
$userArray = $userCache['info'][$userId];
if (is_numeric($userArray['contentobject_id'])) {
$currentUser = new eZUser($userArray);
$currentUser->setUserCache($userCache);
}
}
$ini = eZINI::instance();
// Check if:
// - the user has not logged out,
// - the user is not logged in,
// - and if a automatic single sign on plugin is enabled.
if (!self::$userHasLoggedOut && is_object($currentUser) && !$currentUser->isRegistered()) {
$ssoHandlerArray = $ini->variable('UserSettings', 'SingleSignOnHandlerArray');
if (!empty($ssoHandlerArray)) {
$ssoUser = false;
foreach ($ssoHandlerArray as $ssoHandler) {
$className = 'eZ' . $ssoHandler . 'SSOHandler';
if (class_exists($className)) {
$impl = new $className();
$ssoUser = $impl->handleSSOLogin();
// If a user was found via SSO, then use it
if ($ssoUser !== false) {
$currentUser = $ssoUser;
$userId = $currentUser->attribute('contentobject_id');
$userInfo = array();
$userInfo[$userId] = array('contentobject_id' => $userId, 'login' => $currentUser->attribute('login'), 'email' => $currentUser->attribute('email'), 'password_hash' => $currentUser->attribute('password_hash'), 'password_hash_type' => $currentUser->attribute('password_hash_type'));
eZSession::setUserID($userId);
$http->setSessionVariable('eZUserLoggedInID', $userId);
eZUser::updateLastVisit($userId);
eZUser::setCurrentlyLoggedInUser($currentUser, $userId);
eZHTTPTool::redirect(eZSys::wwwDir() . eZSys::indexFile(false) . eZSys::requestURI() . eZSys::queryString(), array(), 302);
eZExecution::cleanExit();
}
} else {
eZDebug::writeError("Undefined ssoHandler class: {$className}", __METHOD__);
}
}
}
}
if ($userId != $anonymousUserID) {
$sessionInactivityTimeout = $ini->variable('Session', 'ActivityTimeout');
if (!isset($GLOBALS['eZSessionIdleTime'])) {
eZUser::updateLastVisit($userId);
} else {
$sessionIdle = $GLOBALS['eZSessionIdleTime'];
if ($sessionIdle > $sessionInactivityTimeout) {
eZUser::updateLastVisit($userId);
}
}
}
if (!$currentUser) {
$currentUser = eZUser::fetch(self::anonymousId());
eZDebug::writeWarning('User not found, returning anonymous');
}
if (!$currentUser) {
$currentUser = new eZUser(array('id' => -1, 'login' => 'NoUser'));
eZDebug::writeWarning('Anonymous user not found, returning NoUser');
}
$GLOBALS["eZUserGlobalInstance_{$id}"] = $currentUser;
return $currentUser;
}
示例2: loginUser
static function loginUser($login, $password, $authenticationMatch = false)
{
$http = eZHTTPTool::instance();
$db = eZDB::instance();
if ($authenticationMatch === false) {
$authenticationMatch = eZUser::authenticationMatch();
}
$loginEscaped = $db->escapeString($login);
$passwordEscaped = $db->escapeString($password);
$loginArray = array();
if ($authenticationMatch & eZUser::AUTHENTICATE_LOGIN) {
$loginArray[] = "login='{$loginEscaped}'";
}
if ($authenticationMatch & eZUser::AUTHENTICATE_EMAIL) {
$loginArray[] = "email='{$loginEscaped}'";
}
if (count($loginArray) == 0) {
$loginArray[] = "login='{$loginEscaped}'";
}
$loginText = implode(' OR ', $loginArray);
$contentObjectStatus = eZContentObject::STATUS_PUBLISHED;
$ini = eZINI::instance();
$textFileIni = eZINI::instance('textfile.ini');
$databaseName = $db->databaseName();
// if mysql
if ($databaseName === 'mysql') {
$query = "SELECT contentobject_id, password_hash, password_hash_type, email, login\n FROM ezuser, ezcontentobject\n WHERE ( {$loginText} ) AND\n ezcontentobject.status='{$contentObjectStatus}' AND\n ( ezcontentobject.id=contentobject_id OR ( password_hash_type=4 AND ( {$loginText} ) AND password_hash=PASSWORD('{$passwordEscaped}') ) )";
} else {
$query = "SELECT contentobject_id, password_hash, password_hash_type, email, login\n FROM ezuser, ezcontentobject\n WHERE ( {$loginText} ) AND\n ezcontentobject.status='{$contentObjectStatus}' AND\n ezcontentobject.id=contentobject_id";
}
$users = $db->arrayQuery($query);
$exists = false;
if (count($users) >= 1) {
foreach ($users as $userRow) {
$userID = $userRow['contentobject_id'];
$hashType = $userRow['password_hash_type'];
$hash = $userRow['password_hash'];
$exists = eZUser::authenticateHash($userRow['login'], $password, eZUser::site(), $hashType, $hash);
// If hash type is MySql
if ($hashType == eZUser::PASSWORD_HASH_MYSQL and $databaseName === 'mysql') {
$queryMysqlUser = "SELECT contentobject_id, password_hash, password_hash_type, email, login\n FROM ezuser, ezcontentobject\n WHERE ezcontentobject.status='{$contentObjectStatus}' AND\n password_hash_type=4 AND ( {$loginText} ) AND password_hash=PASSWORD('{$passwordEscaped}') ";
$mysqlUsers = $db->arrayQuery($queryMysqlUser);
if (count($mysqlUsers) >= 1) {
$exists = true;
}
}
eZDebugSetting::writeDebug('kernel-user', eZUser::createHash($userRow['login'], $password, eZUser::site(), $hashType), "check hash");
eZDebugSetting::writeDebug('kernel-user', $hash, "stored hash");
// If current user has been disabled after a few failed login attempts.
$canLogin = eZUser::isEnabledAfterFailedLogin($userID);
if ($exists) {
// We should store userID for warning message.
$GLOBALS['eZFailedLoginAttemptUserID'] = $userID;
$userSetting = eZUserSetting::fetch($userID);
$isEnabled = $userSetting->attribute("is_enabled");
if ($hashType != eZUser::hashType() and strtolower($ini->variable('UserSettings', 'UpdateHash')) == 'true') {
$hashType = eZUser::hashType();
$hash = eZUser::createHash($login, $password, eZUser::site(), $hashType);
$db->query("UPDATE ezuser SET password_hash='{$hash}', password_hash_type='{$hashType}' WHERE contentobject_id='{$userID}'");
}
break;
}
}
}
if ($exists and $isEnabled and $canLogin) {
eZDebugSetting::writeDebug('kernel-user', $userRow, 'user row');
$user = new eZUser($userRow);
eZDebugSetting::writeDebug('kernel-user', $user, 'user');
$userID = $user->attribute('contentobject_id');
eZUser::updateLastVisit($userID);
eZUser::setCurrentlyLoggedInUser($user, $userID);
// Reset number of failed login attempts
eZUser::setFailedLoginAttempts($userID, 0);
return $user;
} else {
if ($textFileIni->variable('TextFileSettings', 'TextFileEnabled') == "true") {
$fileName = $textFileIni->variable('TextFileSettings', 'FileName');
$filePath = $textFileIni->variable('TextFileSettings', 'FilePath');
$defaultUserPlacement = $ini->variable("UserSettings", "DefaultUserPlacement");
$separator = $textFileIni->variable("TextFileSettings", "FileFieldSeparator");
$loginColumnNr = $textFileIni->variable("TextFileSettings", "LoginAttribute");
$passwordColumnNr = $textFileIni->variable("TextFileSettings", "PasswordAttribute");
$emailColumnNr = $textFileIni->variable("TextFileSettings", "EmailAttribute");
$lastNameColumnNr = $textFileIni->variable("TextFileSettings", "LastNameAttribute");
$firstNameColumnNr = $textFileIni->variable("TextFileSettings", "FirstNameAttribute");
if ($textFileIni->hasVariable('TextFileSettings', 'DefaultUserGroupType')) {
$UserGroupType = $textFileIni->variable('TextFileSettings', 'DefaultUserGroupType');
$UserGroup = $textFileIni->variable('TextFileSettings', 'DefaultUserGroup');
}
if ($UserGroupType != null) {
if ($UserGroupType == "name") {
$groupName = $UserGroup;
$groupQuery = "SELECT ezcontentobject_tree.node_id\n FROM ezcontentobject, ezcontentobject_tree\n WHERE ezcontentobject.name='{$groupName}'\n AND ezcontentobject.id=ezcontentobject_tree.contentobject_id";
$groupObject = $db->arrayQuery($groupQuery);
if (count($groupObject) > 0) {
$defaultUserPlacement = $groupObject[0]['node_id'];
}
} else {
if ($UserGroupType == "id") {
$groupID = $UserGroup;
//.........这里部分代码省略.........
示例3: array
if (eZOperationHandler::operationIsAvailable('user_activation')) {
$operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => true));
} else {
eZUserOperationCollection::activation($userID, $hash, true);
}
// execute operation to publish the user object
$publishResult = eZOperationHandler::execute('user', 'register', array('user_id' => $userID));
if ($publishResult['status'] === eZModuleOperationInfo::STATUS_HALTED) {
$isPending = true;
} else {
// Log in user
$user = eZUser::fetch($userID);
if ($user === null) {
return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
eZUser::updateLastVisit($userID, true);
$user->loginCurrent();
}
} elseif ($mainNodeID) {
$userContentObject = eZContentObject::fetchByNodeID($mainNodeID);
if ($userContentObject instanceof eZContentObject) {
$userSetting = eZUserSetting::fetch($userContentObject->attribute('id'));
if ($userSetting !== null && $userSetting->attribute('is_enabled')) {
$alreadyActive = true;
}
}
}
// Template handling
$tpl = eZTemplate::factory();
$tpl->setVariable('module', $Module);
$tpl->setVariable('account_activated', $accountActivated);
示例4: publishUpdateUser
//.........这里部分代码省略.........
$lastNameAttribute = $attribute;
}
}
}
}
}
//================= common part 2: start ========================
if ($firstNameAttribute) {
$firstNameAttribute->setAttribute('data_text', $first_name);
$firstNameAttribute->store();
}
if ($lastNameAttribute) {
$lastNameAttribute->setAttribute('data_text', $last_name);
$lastNameAttribute->store();
}
if (!isset($userDataChanged) or $userDataChanged === true) {
$contentClass = $contentObject->attribute('content_class');
$name = $contentClass->contentObjectName($contentObject);
$contentObject->setName($name);
}
if (!isset($emailChanged) or $emailChanged === true) {
$user->setAttribute('email', $email);
}
$user->setAttribute('password_hash', "");
$user->setAttribute('password_hash_type', 0);
$user->store();
$debugArray = array('Updating user data', 'createNewUser' => $createNewUser, 'userDataChanged' => isset($userDataChanged) ? $userDataChanged : null, 'login' => $login, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'firstNameAttribute is_object' => is_object($firstNameAttribute), 'lastNameAttribute is_object' => is_object($lastNameAttribute), 'content object id' => $contentObjectID, 'version id' => $version->attribute('version'));
eZDebug::writeNotice(var_export($debugArray, true), __METHOD__);
//================= common part 2: end ==========================
if ($createNewUser) {
reset($parentNodeIDs);
// prepare node assignments for publishing new user
foreach ($parentNodeIDs as $parentNodeID) {
$newNodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObjectID, 'contentobject_version' => 1, 'parent_node' => $parentNodeID, 'parent_remote_id' => uniqid('LDAP_'), 'is_main' => $defaultUserPlacement == $parentNodeID ? 1 : 0));
$newNodeAssignment->store();
}
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
} else {
if ($userDataChanged) {
// Publish object
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => $version->attribute('version')));
// Refetch object
$contentObject = eZContentObject::fetch($contentObjectID);
$version = $contentObject->attribute('current');
}
$LDAPIni = eZINI::instance('ldap.ini');
$keepGroupAssignment = $LDAPIni->hasVariable('LDAPSettings', 'KeepGroupAssignment') ? $LDAPIni->variable('LDAPSettings', 'KeepGroupAssignment') == "enabled" : false;
if ($keepGroupAssignment == false) {
$objectIsChanged = false;
$db = eZDB::instance();
$db->begin();
// First check existing assignments, remove any that should not exist
$assignedNodesList = $contentObject->assignedNodes();
$existingParentNodeIDs = array();
foreach ($assignedNodesList as $node) {
$parentNodeID = $node->attribute('parent_node_id');
if (!in_array($parentNodeID, $parentNodeIDs)) {
$node->removeThis();
$objectIsChanged = true;
} else {
$existingParentNodeIDs[] = $parentNodeID;
}
}
// Then check assignments that should exist, add them if they are missing
foreach ($parentNodeIDs as $parentNodeID) {
if (!in_array($parentNodeID, $existingParentNodeIDs)) {
$newNode = $contentObject->addLocation($parentNodeID, true);
$newNode->updateSubTreePath();
$newNode->setAttribute('contentobject_is_published', 1);
$newNode->sync();
$existingParentNodeIDs[] = $parentNodeID;
$objectIsChanged = true;
}
}
// Then ensure that the main node is correct
$currentMainParentNodeID = $contentObject->attribute('main_parent_node_id');
if ($currentMainParentNodeID != $defaultUserPlacement) {
$existingNode = eZContentObjectTreeNode::fetchNode($contentObjectID, $defaultUserPlacement);
if (!is_object($existingNode)) {
eZDebug::writeError("Cannot find assigned node as {$defaultUserPlacement}'s child.", __METHOD__);
} else {
$existingNodeID = $existingNode->attribute('node_id');
$versionNum = $version->attribute('version');
eZContentObjectTreeNode::updateMainNodeID($existingNodeID, $contentObjectID, $versionNum, $defaultUserPlacement);
$objectIsChanged = true;
}
}
$db->commit();
// Finally, clear object view cache if something was changed
if ($objectIsChanged) {
eZContentCacheManager::clearObjectViewCache($contentObjectID, true);
}
}
}
eZUser::updateLastVisit($userID);
//eZUser::setCurrentlyLoggedInUser( $user, $userID );
// Reset number of failed login attempts
eZUser::setFailedLoginAttempts($userID, 0);
return $user;
}
示例5: 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;
}