Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
RecoveryController Class Reference
Inheritance diagram for RecoveryController:
Controller BaseController

Public Member Functions

 actionChange ()
 actionChangeRequest ()

Public Attributes

 $defaultAction = 'recovery'
- Public Attributes inherited from Controller
 $menu = array()
 $breadcrumbs = array()
- Public Attributes inherited from BaseController
 $layout = '//layouts/gportal'
 $mailLayout = '//layouts/mail'

Additional Inherited Members

- Protected Member Functions inherited from BaseController
 beforeAction ($action)

Detailed Description

Definition at line 3 of file RecoveryController.php.

Member Function Documentation

RecoveryController::actionChange ( )

Change password

This action only handle requests and redirect back. No render

Definition at line 12 of file RecoveryController.php.

References User\model(), and UserModule\t().

{
$form = new UserChangePassword;
$form->attributes = @$_POST['UserChangePassword'];
if (isset($_POST['ajax'])) {
echo CActiveForm::validate($form);
Yii::app()->end();
}
if ($form->validate()) {
$user = User::model()->notsafe()->findByAttributes(array('email' => @$_POST['email']));
if (!isset($user) || $user->activkey != @$_POST['activkey']) {
$form->addError('password', 'Active key is expired');
}
}
if (!$form->hasErrors()) {
$user->password = Yii::app()->controller->module->encrypting($form->password);
$user->activkey = Yii::app()->controller->module->encrypting(microtime() . $form->password);
$user->save();
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("New password is saved."));
} else {
Yii::app()->user->setState('UserChangePassword', array('attributes' => $form->attributes, 'errors' => $form->getErrors()));
}
if (isset($_GET['return_url'])) {
$this->redirect($_GET['return_url']);
}
$this->redirect(Yii::app()->getModule('user')->recoveryChangePasswordUrl);
}
RecoveryController::actionChangeRequest ( )

This action only handle requests and redirect back. No render

Definition at line 47 of file RecoveryController.php.

References User\model(), and UserModule\t().

{
$form = new UserRecoveryForm;
if (Yii::app()->user->isGuest) {
if (isset($_POST['UserRecoveryForm'])) {
$form->attributes = $_POST['UserRecoveryForm'];
if ($form->validate()) {
$user = User::model()->with('account')->notsafe()->findbyPk($form->user_id);
if ($user->account) {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("You used TPA for logged in. You can not recovery password"));
} else {
$activation_url = $this->_getChangePasswordUrl(array("activkey" => $user->activkey, "email" => $user->email));
$subject = UserModule::t("You have requested the password recovery site {site_name}",
array(
'{site_name}' => Yii::app()->name,
));
$message = $this->renderMail('/mail_templates/recovery', $subject, array('activation_url' => $activation_url));
$notification = new Notification(
$subject,
$message,
array(new EmailRecipient($user->email, $this->module->passwordForgottenEmail, '', true))
);
Yii::app()->notificationManager->notifyAbout($notification);
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please check your email. An instruction was sent to your email address."));
}
} else {
Yii::app()->user->setState('UserRecoveryForm', array('attributes' => $form->attributes, 'errors' => $form->getErrors()));
}
}
} else {
Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Please log out."));
}
/* if is set returl_url - we heed to redirect user there */
if (isset($_REQUEST['return_url'])) {
$this->redirect($_REQUEST['return_url']);
} else {
$this->render('recovery', array('form' => $form));
}
}

The documentation for this class was generated from the following file: