Пример #1
0
 /** 
  * Generates a new random password and creates a new Notification item
  */
 public function actionRetrieve($id, $redirect)
 {
     $model = $this->loadModel($id);
     $new_pass = Users::model()->generatePassword();
     $model->attributes = array('password' => Users::model()->hashPassword($new_pass));
     $model->save();
     //Notification
     Notifications::generate('Users', $model->username, 'users', 'retrieve', $new_pass);
     if ($redirect == 'admin') {
         Yii::app()->user->setFlash('success', Yii::t('user', 'The new password is generated and was sent to user e-mail.'));
     } else {
         Yii::app()->user->setFlash('retrieve', Yii::t('user', 'The new password is generated and was sent to your e-mail.'));
     }
     $this->redirect(array($redirect));
 }
Пример #2
0
 /** 
  * Generates a new random password and creates a new Notification item
  */
 public function actionRetrieve()
 {
     $model = new LoginForm();
     if (isset($_POST['LoginForm'])) {
         $user = Users::model()->findByPk($_POST['LoginForm']['username']);
         if ($user === null) {
             $model->addError('username', Yii::t('user', 'Username not valid'));
         } else {
             $new_pass = Users::model()->generatePassword();
             $user->attributes = array('password' => Users::model()->hashPassword($new_pass));
             $user->save();
             //Notification
             Notifications::generate('Users', $user->username, 'users', 'retrieve', $new_pass);
             // display the login form
             Yii::app()->user->setFlash('retrieve', 'The new password was sent to you via email.');
             $this->redirect(array('login'));
         }
     }
     // display the retrieve form
     $this->render('retrieve', array('model' => $model));
 }
Пример #3
0
 /** 
  * This method is invoked after saving a record.
  * It creates a new Notification item
  */
 public function afterSave()
 {
     //perform this operation only in the first save
     if ($this->isNewRecord && $this->role->name == 'planner') {
         //Notification
         Notifications::generate('Users', $this->username, 'users', 'create');
     }
     return parent::afterSave();
 }