本文整理汇总了PHP中CFormModel::getNewCode方法的典型用法代码示例。如果您正苦于以下问题:PHP CFormModel::getNewCode方法的具体用法?PHP CFormModel::getNewCode怎么用?PHP CFormModel::getNewCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFormModel
的用法示例。
在下文中一共展示了CFormModel::getNewCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendEmail
/**
* Sends out an email containing instructions and link to the email verification
* or password recovery page, containing an activation key.
* @param CFormModel $model it must have a getIdentity() method
* @param strign $mode 'recovery', 'verify' or 'oneTimePassword'
* @return boolean if sending the email succeeded
*/
public function sendEmail(CFormModel $model, $mode)
{
$mail = $this->module->mailer;
$mail->AddAddress($model->getIdentity()->getEmail(), $model->getIdentity()->getName());
$params = array('siteUrl' => $this->createAbsoluteUrl('/'));
switch ($mode) {
default:
return false;
case 'recovery':
case 'verify':
$mail->Subject = $mode == 'recovery' ? Yii::t('UsrModule.usr', 'Password recovery') : Yii::t('UsrModule.usr', 'Email address verification');
$params['actionUrl'] = $this->createAbsoluteUrl('default/' . $mode, array('activationKey' => $model->getIdentity()->getActivationKey(), 'username' => $model->getIdentity()->getName()));
break;
case 'oneTimePassword':
$mail->Subject = Yii::t('UsrModule.usr', 'One Time Password');
$params['code'] = $model->getNewCode();
break;
}
$body = $this->renderPartial($mail->getPathViews() . '.' . $mode, $params, true);
$full = $this->renderPartial($mail->getPathLayouts() . '.email', array('content' => $body), true);
$mail->MsgHTML($full);
if ($mail->Send()) {
return true;
} else {
Yii::log($mail->ErrorInfo, 'error');
return false;
}
}