HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
UserChangePassword.php
Go to the documentation of this file.
1 <?php
7 class UserChangePassword extends CFormModel
8 {
9  public $oldPassword;
10  public $password;
12 
13  public function rules()
14  {
15  return Yii::app()->controller->id == 'recovery' ? array(
16  array('password, verifyPassword', 'required'),
17  array('password, verifyPassword', 'length', 'max' => 128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
18  array('verifyPassword', 'compare', 'compareAttribute' => 'password', 'message' => UserModule::t("Retype Password is incorrect.")),
19  ) : array(
20  array('oldPassword, password, verifyPassword', 'required'),
21  array('oldPassword, password, verifyPassword', 'length', 'max' => 128, 'min' => 4,'message' => UserModule::t("Incorrect password (minimal length 4 symbols).")),
22  array('verifyPassword', 'compare', 'compareAttribute' => 'password', 'message' => UserModule::t("Retype Password is incorrect.")),
23  array('oldPassword', 'verifyOldPassword'),
24  );
25  }
26 
30  public function attributeLabels()
31  {
32  return array(
33  'oldPassword' => UserModule::t("Old Password"),
34  'password' => UserModule::t("password"),
35  'verifyPassword' => UserModule::t("Retype Password"),
36  );
37  }
38 
42  public function verifyOldPassword($attribute, $params)
43  {
44  if (User::model()->notsafe()->findByPk(Yii::app()->user->id)->password != Yii::app()->getModule('user')->encrypting($this->$attribute)) {
45  $this->addError($attribute, UserModule::t("Old Password is incorrect."));
46  }
47  }
48 }