|
|
@@ -30,6 +30,10 @@ class User extends ActiveRecord implements IdentityInterface |
|
|
|
const STATUS_BOULANGER = 11; |
|
|
|
const STATUS_ADMIN = 13; |
|
|
|
|
|
|
|
var $password_old ; |
|
|
|
var $password_new ; |
|
|
|
var $password_new_confirm ; |
|
|
|
|
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
@@ -54,7 +58,7 @@ class User extends ActiveRecord implements IdentityInterface |
|
|
|
public function rules() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
['confiance','default','value'=>0], |
|
|
|
['confiance','default','value'=>1], |
|
|
|
[['no_mail','mail_prod_lundi','mail_prod_mardi','mail_prod_mercredi','mail_prod_jeudi','mail_prod_vendredi','mail_prod_samedi','mail_prod_dimanche'],'boolean'], |
|
|
|
[['nom','prenom','telephone','adresse'], 'string'], |
|
|
|
[['nom','prenom'],'required','message'=> 'Ce champs ne peut être vide'], |
|
|
@@ -62,10 +66,55 @@ class User extends ActiveRecord implements IdentityInterface |
|
|
|
['email','verifyEmail'], |
|
|
|
['status', 'default', 'value' => self::STATUS_ACTIVE], |
|
|
|
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED, self::STATUS_ADMIN,self::STATUS_BOULANGER ]], |
|
|
|
[['date_derniere_connexion'],'safe'], |
|
|
|
['password_old','verifyPasswordOld'], |
|
|
|
['password_new','verifyPasswordNew'], |
|
|
|
['password_new_confirm','verifyPasswordNewConfirm'], |
|
|
|
[['date_derniere_connexion','password_old','password_new','password_new_confirm','password_hash'],'safe'], |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
public function verifyPasswordOld($attribute,$params) |
|
|
|
{ |
|
|
|
if(strlen($this->password_old)) |
|
|
|
{ |
|
|
|
if(!$this->validatePassword($this->password_old)) |
|
|
|
{ |
|
|
|
$this->addError($attribute, 'Mot de passe invalide.') ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!strlen($this->password_old) && (strlen($this->password_new) || strlen($this->password_new_confirm))) |
|
|
|
{ |
|
|
|
$this->addError($attribute, 'Ce champs ne peut être vide') ; |
|
|
|
} |
|
|
|
|
|
|
|
if(!strlen($this->password_new) && (strlen($this->password_old) || strlen($this->password_new_confirm))) |
|
|
|
{ |
|
|
|
$this->addError('password_new', 'Ce champs ne peut être vide') ; |
|
|
|
} |
|
|
|
|
|
|
|
if(!strlen($this->password_new_confirm) && (strlen($this->password_old) || strlen($this->password_new))) |
|
|
|
{ |
|
|
|
$this->addError('password_new_confirm', 'Ce champs ne peut être vide') ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function verifyPasswordNew($attribute,$params) |
|
|
|
{ |
|
|
|
if(strlen($this->password_new) < 6) |
|
|
|
{ |
|
|
|
$this->addError($attribute, 'Votre mot de passe doit comporter au moins 6 caractères.') ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function verifyPasswordNewConfirm($attribute,$params) |
|
|
|
{ |
|
|
|
if($this->password_new != $this->password_new_confirm) |
|
|
|
{ |
|
|
|
$this->addError($attribute, 'Les deux mots de passe doivent être identiques') ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function verifyEmail($attribute,$params) { |
|
|
|
$user = User::find()->where("email LIKE :email AND id != :id")->params(array(':email'=>'%'.$this->email.'%', ':id'=>$this->id))->one() ; |
|
|
|
|
|
|
@@ -253,6 +302,9 @@ class User extends ActiveRecord implements IdentityInterface |
|
|
|
'mail_prod_vendredi' => 'Vendredi', |
|
|
|
'mail_prod_samedi' => 'Samedi', |
|
|
|
'mail_prod_dimanche' => 'Dimanche', |
|
|
|
'password_old' => 'Ancien mot de passe', |
|
|
|
'password_new' => 'Nouveau mot de passe', |
|
|
|
'password_new_confirm' => 'Confirmation du nouveau mot de passe', |
|
|
|
]; |
|
|
|
} |
|
|
|
|