Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/users/users_tag_processor.php
Show All 29 Lines | |||||
function SuggestRegister($params) | function SuggestRegister($params) | ||||
{ | { | ||||
return !$this->Application->LoggedIn() && !$this->Application->ConfigValue('Comm_RequireLoginBeforeCheckout') && $this->RegistrationEnabled($params); | return !$this->Application->LoggedIn() && !$this->Application->ConfigValue('Comm_RequireLoginBeforeCheckout') && $this->RegistrationEnabled($params); | ||||
} | } | ||||
function ConfirmPasswordLink($params) | function ConfirmPasswordLink($params) | ||||
{ | { | ||||
/** @var UsersItem $user */ | |||||
$user = $this->Application->recallObject($this->Prefix . '.email-to'); | $user = $this->Application->recallObject($this->Prefix . '.email-to'); | ||||
/* @var $user UsersItem */ | |||||
$code = $this->getCachedCode(); | $code = $this->getCachedCode(); | ||||
$user->SetDBField('PwResetConfirm', $code); | $user->SetDBField('PwResetConfirm', $code); | ||||
$user->SetDBField('PwRequestTime_date', adodb_mktime()); | $user->SetDBField('PwRequestTime_date', adodb_mktime()); | ||||
$user->SetDBField('PwRequestTime_time', adodb_mktime()); | $user->SetDBField('PwRequestTime_time', adodb_mktime()); | ||||
if ( $user->GetChangedFields() ) { | if ( $user->GetChangedFields() ) { | ||||
// tag is called 2 times within USER.PWDC email event, so don't update user record twice | // tag is called 2 times within USER.PWDC email event, so don't update user record twice | ||||
Show All 22 Lines | |||||
$code = md5(kUtil::generateId()); | $code = md5(kUtil::generateId()); | ||||
} | } | ||||
return $code; | return $code; | ||||
} | } | ||||
function TestCodeIsValid($params) | function TestCodeIsValid($params) | ||||
{ | { | ||||
/** @var UserHelper $user_helper */ | |||||
$user_helper = $this->Application->recallObject('UserHelper'); | $user_helper = $this->Application->recallObject('UserHelper'); | ||||
/* @var $user_helper UserHelper */ | |||||
$code_type = isset($params['code_type']) ? $params['code_type'] : 'forgot_password'; | $code_type = isset($params['code_type']) ? $params['code_type'] : 'forgot_password'; | ||||
$expiration_timeout = isset($params['expiration_timeout']) ? $params['expiration_timeout'] : null; | $expiration_timeout = isset($params['expiration_timeout']) ? $params['expiration_timeout'] : null; | ||||
$user_id = $user_helper->validateUserCode($this->Application->GetVar('user_key'), $code_type, $expiration_timeout); | $user_id = $user_helper->validateUserCode($this->Application->GetVar('user_key'), $code_type, $expiration_timeout); | ||||
if ( !is_numeric($user_id) ) { | if ( !is_numeric($user_id) ) { | ||||
// used for error reporting only -> rewrite code + theme (by Alex) | // used for error reporting only -> rewrite code + theme (by Alex) | ||||
$object = $this->getObject( Array('skip_autoload' => true) ); // TODO: change theme too | $object = $this->getObject( Array('skip_autoload' => true) ); // TODO: change theme too | ||||
/* @var $object UsersItem */ | /** @var UsersItem $object */ | ||||
$object->SetError('PwResetConfirm', $user_id, $this->_getUserCodeErrorMsg($user_id, $code_type, $params)); | $object->SetError('PwResetConfirm', $user_id, $this->_getUserCodeErrorMsg($user_id, $code_type, $params)); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Tries to restore user email | * Tries to restore user email | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function RestoreEmail($params) | protected function RestoreEmail($params) | ||||
{ | { | ||||
/** @var UserHelper $user_helper */ | |||||
$user_helper = $this->Application->recallObject('UserHelper'); | $user_helper = $this->Application->recallObject('UserHelper'); | ||||
/* @var $user_helper UserHelper */ | |||||
$hash = $this->Application->GetVar('hash'); | $hash = $this->Application->GetVar('hash'); | ||||
$error_code = $user_helper->restoreEmail($hash); | $error_code = $user_helper->restoreEmail($hash); | ||||
if ( $error_code ) { | if ( $error_code ) { | ||||
// used for error reporting only -> rewrite code + theme (by Alex) | // used for error reporting only -> rewrite code + theme (by Alex) | ||||
$object = $this->getObject(Array ('skip_autoload' => true)); // TODO: change theme too | $object = $this->getObject(Array ('skip_autoload' => true)); // TODO: change theme too | ||||
/* @var $object UsersItem */ | /** @var UsersItem $object */ | ||||
$object->SetError('PwResetConfirm', 'restore', $params[$error_code]); | $object->SetError('PwResetConfirm', 'restore', $params[$error_code]); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
* Returns login name of user | * Returns login name of user | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function LoginName($params) | protected function LoginName($params) | ||||
{ | { | ||||
/** @var UsersItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object UsersItem */ | |||||
return $object->GetID() != USER_ROOT ? $object->GetDBField('Username') : 'root'; | return $object->GetID() != USER_ROOT ? $object->GetDBField('Username') : 'root'; | ||||
} | } | ||||
function CookieUsername($params) | function CookieUsername($params) | ||||
{ | { | ||||
$items_info = $this->Application->GetVar( $this->getPrefixSpecial(true) ); | $items_info = $this->Application->GetVar( $this->getPrefixSpecial(true) ); | ||||
Show All 13 Lines | |||||
/** | /** | ||||
* Checks if user have one of required permissions | * Checks if user have one of required permissions | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function HasPermission($params) | function HasPermission($params) | ||||
{ | { | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
return $perm_helper->TagPermissionCheck($params); | return $perm_helper->TagPermissionCheck($params); | ||||
} | } | ||||
/** | /** | ||||
* Returns link to user public profile | * Returns link to user public profile | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
Show All 12 Lines | |||||
list ($ret, $tag_processed) = $this->processAggregatedTag('ImageSrc', $params, $this->getPrefixSpecial()); | list ($ret, $tag_processed) = $this->processAggregatedTag('ImageSrc', $params, $this->getPrefixSpecial()); | ||||
return $tag_processed ? $ret : false; | return $tag_processed ? $ret : false; | ||||
} | } | ||||
function LoggedIn($params) | function LoggedIn($params) | ||||
{ | { | ||||
static $loggedin_status = Array (); | static $loggedin_status = Array (); | ||||
/** @var kDBList $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBList */ | |||||
if (!isset($loggedin_status[$this->Special])) { | if (!isset($loggedin_status[$this->Special])) { | ||||
$user_ids = $object->GetCol($object->IDField); | $user_ids = $object->GetCol($object->IDField); | ||||
$sql = 'SELECT LastAccessed, '.$object->IDField.' | $sql = 'SELECT LastAccessed, '.$object->IDField.' | ||||
FROM '.TABLE_PREFIX.'UserSessions | FROM '.TABLE_PREFIX.'UserSessions | ||||
WHERE (PortalUserId IN ('.implode(',', $user_ids).'))'; | WHERE (PortalUserId IN ('.implode(',', $user_ids).'))'; | ||||
$loggedin_status[$this->Special] = $this->Conn->GetCol($sql, $object->IDField); | $loggedin_status[$this->Special] = $this->Conn->GetCol($sql, $object->IDField); | ||||
} | } | ||||
return isset($loggedin_status[$this->Special][$object->GetID()]); | return isset($loggedin_status[$this->Special][$object->GetID()]); | ||||
} | } | ||||
/** | /** | ||||
* Prints user activation link | * Prints user activation link | ||||
* | * | ||||
* @param Array $params | * @param Array $params | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function ActivationLink($params) | function ActivationLink($params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
$code = $this->getCachedCode(); | $code = $this->getCachedCode(); | ||||
$object->SetDBField('PwResetConfirm', $code); | $object->SetDBField('PwResetConfirm', $code); | ||||
$object->SetDBField('PwRequestTime_date', adodb_mktime()); | $object->SetDBField('PwRequestTime_date', adodb_mktime()); | ||||
$object->SetDBField('PwRequestTime_time', adodb_mktime()); | $object->SetDBField('PwRequestTime_time', adodb_mktime()); | ||||
$object->Update(); | $object->Update(); | ||||
$params['user_key'] = $code; | $params['user_key'] = $code; | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
* Activates user using given code | * Activates user using given code | ||||
* | * | ||||
* @param Array $fields_hash | * @param Array $fields_hash | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _updateAndLogin($fields_hash) | protected function _updateAndLogin($fields_hash) | ||||
{ | { | ||||
/** @var UserHelper $user_helper */ | |||||
$user_helper = $this->Application->recallObject('UserHelper'); | $user_helper = $this->Application->recallObject('UserHelper'); | ||||
/* @var $user_helper UserHelper */ | |||||
/** @var UsersItem $user */ | |||||
$user = $this->Application->recallObject($this->Prefix . '.activate', null, Array ('skip_autoload' => true)); | $user = $this->Application->recallObject($this->Prefix . '.activate', null, Array ('skip_autoload' => true)); | ||||
/* @var $user UsersItem */ | |||||
$user->Load(trim($this->Application->GetVar('user_key')), 'PwResetConfirm'); | $user->Load(trim($this->Application->GetVar('user_key')), 'PwResetConfirm'); | ||||
if ( !$user->isLoaded() ) { | if ( !$user->isLoaded() ) { | ||||
return ; | return ; | ||||
} | } | ||||
Show All 15 Lines | |||||
* Returns user title | * Returns user title | ||||
* | * | ||||
* @param array $params Parameters. | * @param array $params Parameters. | ||||
* @return string | * @return string | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function UserTitle(array $params) | protected function UserTitle(array $params) | ||||
{ | { | ||||
/** @var kDBItem $object */ | |||||
$object = $this->getObject($params); | $object = $this->getObject($params); | ||||
/* @var $object kDBItem */ | |||||
return $object->GetDBField('Email') ? $object->GetDBField('Email') : $object->GetDBField('Username'); | return $object->GetDBField('Email') ? $object->GetDBField('Email') : $object->GetDBField('Username'); | ||||
} | } | ||||
} | } |