Guest User

Untitled

a guest
Oct 28th, 2017
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. public function beforeSave() {
  2.         var_dump('BeforeSave');
  3.         if(!parent::beforeSave())
  4.             return false;
  5.  
  6.         if ($this->isNewRecord) {
  7.             var_dump('beforeSave If');
  8.             $this->salt = MSHelper::genRandomString(32);
  9.             $this->password = Yii::app()->getModule('user')->encryptString($this->password, $this->salt);
  10.             $this->activation_key = MSHelper::genRandomString(32);
  11.             $this->date_registered = new CDbExpression('NOW()');
  12.  
  13.             if(Yii::app()->getModule('user')->requireEmailValidation)
  14.                 $this->status = self::STATUS_NOACTIVE;
  15.         }
  16.         return true;
  17.     }
  18.  
  19.  
  20. // sample code
  21.                 $model = new User;
  22.                 $model->username = 'test';
  23.                 $model->password = 'test';
  24.                 $model->email = 'test@domain.com';
  25.                 $model->save();
Add Comment
Please, Sign In to add comment