fork download
  1. <?php
  2.  
  3. /**
  4.  * LoginForm class.
  5.  * LoginForm is the data structure for keeping
  6.  * user login form data. It is used by the 'login' action of 'SiteController'.
  7.  */
  8. class ChangeEmailForm extends CFormModel
  9. {
  10. public $newemail;
  11. public $password;
  12.  
  13. /**
  14. * Declares the validation rules.
  15. * The rules state that username and password are required,
  16. * and password needs to be authenticated.
  17. */
  18. public function rules()
  19. {
  20. return array(
  21. array('newemail, password', 'required'),
  22. array('newemail', 'email'),
  23. array('newemail', 'unique', 'attributeName'=>'User.email'),
  24. array('password', 'authenticate'),
  25. );
  26. }
  27.  
  28. /**
  29. * Declares attribute labels.
  30. */
  31. public function attributeLabels()
  32. {
  33. return array(
  34. 'newemail'=>'Новый Email-адрес',
  35. 'password'=>'Пароль учетной записи',
  36. );
  37. }
  38.  
  39. /**
  40.   * Authenticates the password.
  41.   * This is the 'authenticate' validator as declared in rules().
  42.   */
  43. public function authenticate($attribute,$params)
  44. {
  45. if(!$this->hasErrors())
  46. {
  47. $user = User::model()->findByAttributes(array('password'=>$this->password,'id'=>Yii::app()->user->id));
  48. if ($user===null)
  49. $this->addError('password','Неверный пароль учетной записи.');
  50. }
  51. }
  52.  
  53. }
  54.  
Runtime error #stdin #stdout #stderr 0.01s 20520KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Class 'CFormModel' not found in /home/Hj9AxW/prog.php on line 9