本文整理汇总了PHP中MemberModel::findByActivation方法的典型用法代码示例。如果您正苦于以下问题:PHP MemberModel::findByActivation方法的具体用法?PHP MemberModel::findByActivation怎么用?PHP MemberModel::findByActivation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberModel
的用法示例。
在下文中一共展示了MemberModel::findByActivation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activateAcount
/**
* Activate an account
*/
protected function activateAcount()
{
$hasError = false;
$strReloadUrl = preg_replace('/(&|\\?)token=[^&]*/', '', \Environment::get('request'));
// remove token from url
$objMember = \MemberModel::findByActivation(MEMBER_ACTIVATION_ACTIVATED_FIELD_PREFIX . \Input::get('token'));
// member with this token already activated
if ($objMember !== null) {
$hasError = true;
MemberMessage::addDanger($GLOBALS['TL_LANG']['MSC']['alreadyActivated']);
}
// check for invalid token
if (!$hasError) {
$objMember = \MemberModel::findByActivation(\Input::get('token'));
if ($objMember === null) {
$hasError = true;
MemberMessage::addDanger($GLOBALS['TL_LANG']['MSC']['invalidActivationToken']);
}
}
// if has errors, remove token from url and redirect to current page without token parameter
if ($hasError) {
$this->redirect($strReloadUrl);
}
// Update the account
$objMember->disable = '';
$objMember->activation = MEMBER_ACTIVATION_ACTIVATED_FIELD_PREFIX . $objMember->activation;
$objMember->save();
$this->accountActivatedMessage = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
// HOOK: post activation callback
if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objMember, $this);
}
}
// Log activity
$this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', __METHOD__, TL_ACCESS);
// Redirect to the jumpTo page
if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
$this->redirect($this->generateFrontendUrl($objTarget->row()));
} else {
MemberMessage::addSuccess($this->accountActivatedMessage);
$this->redirect($strReloadUrl);
}
}
示例2: setNewPassword
/**
* Set the new password
*/
protected function setNewPassword()
{
$objMember = \MemberModel::findByActivation(\Input::get('token'));
if ($objMember === null || $objMember->login == '') {
$this->strTemplate = 'mod_message';
$this->Template = new \FrontendTemplate($this->strTemplate);
$this->Template->type = 'error';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
return;
}
// Define the form field
$arrField = $GLOBALS['TL_DCA']['tl_member']['fields']['password'];
$arrField['eval']['tableless'] = $this->tableless;
$strClass = $GLOBALS['TL_FFL']['password'];
// Fallback to default if the class is not defined
if (!class_exists($strClass)) {
$strClass = 'FormPassword';
}
$objWidget = new $strClass($strClass::getAttributesFromDca($arrField, 'password'));
// Set row classes
$objWidget->rowClass = 'row_0 row_first even';
$objWidget->rowClassConfirm = 'row_1 odd';
$this->Template->rowLast = 'row_2 row_last even';
// Validate the field
if (strlen(\Input::post('FORM_SUBMIT')) && \Input::post('FORM_SUBMIT') == $this->Session->get('setPasswordToken')) {
$objWidget->validate();
// Set the new password and redirect
if (!$objWidget->hasErrors()) {
$this->Session->set('setPasswordToken', '');
array_pop($_SESSION['TL_CONFIRM']);
$objMember->activation = '';
$objMember->password = $objWidget->value;
$objMember->save();
// HOOK: set new password callback
if (isset($GLOBALS['TL_HOOKS']['setNewPassword']) && is_array($GLOBALS['TL_HOOKS']['setNewPassword'])) {
foreach ($GLOBALS['TL_HOOKS']['setNewPassword'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objMember, $objWidget->value, $this);
}
}
// Redirect to the jumpTo page
if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
$this->redirect($this->generateFrontendUrl($objTarget->row()));
}
// Confirm
$this->strTemplate = 'mod_message';
$this->Template = new \FrontendTemplate($this->strTemplate);
$this->Template->type = 'confirm';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['newPasswordSet'];
return;
}
}
$strToken = md5(uniqid(mt_rand(), true));
$this->Session->set('setPasswordToken', $strToken);
$this->Template->formId = $strToken;
$this->Template->fields = $objWidget->parse();
$this->Template->action = \Environment::get('indexFreeRequest');
$this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['setNewPassword']);
$this->Template->tableless = $this->tableless;
}
示例3: activateAcount
/**
* Activate an account
*/
protected function activateAcount()
{
$this->strTemplate = 'mod_message';
$this->Template = new \FrontendTemplate($this->strTemplate);
// Check the token
$objMember = \MemberModel::findByActivation(\Input::get('token'));
if ($objMember === null) {
$this->Template->type = 'error';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
return;
}
// Update the account
$objMember->disable = '';
$objMember->activation = '';
$objMember->save();
// HOOK: post activation callback
if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objMember, $this);
}
}
$arrData = array();
// Get the editable fields
foreach ($this->editable as $key) {
$arrData[$key] = $objMember->{$key};
}
// Add the login details
$arrData['login'] = $objMember->login;
$arrData['groups'] = $objMember->groups;
$arrData['disable'] = '';
// Log activity
$this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', 'ModuleRegistration activateAccount()', TL_ACCESS);
// Redirect to the jumpTo page
if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
$this->redirect($this->generateFrontendUrl($objTarget->row()));
}
// Confirm activation
$this->Template->type = 'confirm';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
}
示例4: activateAcount
/**
* Activate an account
*/
protected function activateAcount()
{
$this->strTemplate = 'mod_message';
/** @var \FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate($this->strTemplate);
$this->Template = $objTemplate;
$objMember = \MemberModel::findByActivation(\Input::get('token'));
if ($objMember === null) {
$this->Template->type = 'error';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
return;
}
// Update the account
$objMember->disable = '';
$objMember->activation = '';
$objMember->save();
// HOOK: post activation callback
if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objMember, $this);
}
}
// Log activity
$this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', __METHOD__, TL_ACCESS);
// Redirect to the jumpTo page
if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
$this->redirect($this->generateFrontendUrl($objTarget->row()));
}
// Confirm activation
$this->Template->type = 'confirm';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
}
示例5: activateAcount
/**
* Activate an account
*/
protected function activateAcount()
{
// Check the token
$objMember = \MemberModel::findByActivation(\Input::get('token'));
if ($objMember === null) {
$_SESSION['LOGIN_ERROR'] = $GLOBALS['TL_LANG']['MSC']['accountError'];
return;
}
// Update the account
$objMember->disable = '';
$objMember->activation = '';
$objMember->save();
// Log activity
$this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', __METHOD__, TL_ACCESS);
// Confirm activation
$_SESSION['LOGIN_SUCCESS'] = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
// HOOK: post activation callback
if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objMember, $this);
}
}
// Redirect to the jumpTo page
if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
$this->redirect($this->generateFrontendUrl($objTarget->row()));
}
}