3333class  User extends  ActiveRecord implements  IdentityInterface
3434{
3535    const  STATUS_DELETED  = 0 ;
36+     const  STATUS_NOT_APPROVED  = 1 ;
3637    const  STATUS_ACTIVE  = 10 ;
3738    const  ROLE_USER  = 10 ;
3839    const  ROLE_ADM  = 5 ;
@@ -65,11 +66,11 @@ public function rules()
6566            [['username ' ], 'unique ' ],
6667            [['email ' ], 'email ' ],
6768
68-             ['status ' , 'default ' , 'value '  => self ::STATUS_ACTIVE ],
69-             ['status ' , 'in ' , 'range '  => array_keys (static ::status ())],
69+             ['status ' , 'default ' , 'value '  => static ::STATUS_ACTIVE ],
70+             ['status ' , 'in ' , 'range '  => array_keys (static ::status_list ())],
7071
71-             ['role ' , 'default ' , 'value '  => self ::ROLE_USER ],
72-             ['role ' , 'in ' , 'range '  => array_keys (static ::roles ())],
72+             ['role ' , 'default ' , 'value '  => static ::ROLE_USER ],
73+             ['role ' , 'in ' , 'range '  => array_keys (static ::roles_list ())],
7374        ];
7475    }
7576
@@ -100,53 +101,54 @@ public function attributeLabels()
100101            'updated_at '  => Yii::t ('modelAdm/user ' , 'Updated ' ),
101102        ];
102103    }
104+ 
103105    /** 
104-      * @param null  $key 
106+      * @param mixed  $key 
105107     * @param null $default 
106108     * @return array|null 
107109     */ 
108-     public  static  function  roles ($ key  = null , $ default  = null )
110+     public  static  function  roles_list ($ key  = false , $ default  = null )
109111    {
110-         $ roles   = [
111-             self ::ROLE_USER  => Yii::t ('adm/user ' , 'User Role ' , ['dot '  => false ]),
112-             self ::ROLE_ADM   => Yii::t ('adm/user ' , 'Adm Role ' , ['dot '  => false ]),
112+         $ list   = [
113+             static ::ROLE_USER  => Yii::t ('adm/user ' , 'User Role ' , ['dot '  => false ]),
114+             static ::ROLE_ADM   => Yii::t ('adm/user ' , 'Adm Role ' , ['dot '  => false ]),
113115        ];
114-         if  ($ key  !== null ) {
115-             if  (isset ($ roles  [$ key ])) {
116-                 return  $ roles  [$ key ];
116+         if  ($ key  !== false ) {
117+             if  (isset ($ list  [$ key ])) {
118+                 return  $ list  [$ key ];
117119            }
118120            return  $ default ;
119121        }
120- 
121-         return  $ roles ;
122+         return  $ list ;
122123    }
123124
124125    /** 
125-      * @param null  $key 
126+      * @param mixed  $key 
126127     * @param null $default 
127128     * @return array|null 
128129     */ 
129-     public  static  function  status ($ key  = null , $ default  = null )
130+     public  static  function  status_list ($ key  = false , $ default  = null )
130131    {
131-         $ status  = [
132-             self ::STATUS_ACTIVE      => Yii::t ('adm/user ' , 'Active Status ' , ['dot '  => false ]),
133-             self ::STATUS_DELETED     => Yii::t ('adm/user ' , 'Deleted Status ' , ['dot '  => false ]),
132+         $ list  = [
133+             static ::STATUS_ACTIVE      => Yii::t ('adm/user ' , 'Active Status ' , ['dot '  => false ]),
134+             static ::STATUS_NOT_APPROVED  => Yii::t ('adm/user ' , 'Not Approved Status ' , ['dot '  => false ]),
135+             static ::STATUS_DELETED     => Yii::t ('adm/user ' , 'Deleted Status ' , ['dot '  => false ]),
134136        ];
135-         if  ($ key  !== null ) {
136-             if  (isset ($ status  [$ key ])) {
137-                 return  $ status  [$ key ];
137+         if  ($ key  !== false ) {
138+             if  (isset ($ list  [$ key ])) {
139+                 return  $ list  [$ key ];
138140            }
139141            return  $ default ;
140142        }
141- 
142-         return  $ status ;
143+         return  $ list ;
143144    }
145+ 
144146    /** 
145147     * @inheritdoc 
146148     */ 
147149    public  static  function  findIdentity ($ id )
148150    {
149-         return  static ::findOne (['id '  => $ id , 'status '  => self ::STATUS_ACTIVE ]);
151+         return  static ::findOne (['id '  => $ id , 'status '  => static ::STATUS_ACTIVE ]);
150152    }
151153
152154    /** 
@@ -165,7 +167,7 @@ public static function findIdentityByAccessToken($token, $type = null)
165167     */ 
166168    public  static  function  findByUsername ($ username )
167169    {
168-         return  static ::findOne (['username '  => $ username , 'status '  => self ::STATUS_ACTIVE ]);
170+         return  static ::findOne (['username '  => $ username , 'status '  => static ::STATUS_ACTIVE ]);
169171    }
170172
171173    /** 
@@ -182,7 +184,7 @@ public static function findByPasswordResetToken($token)
182184
183185        return  static ::findOne ([
184186            'password_reset_token '  => $ token ,
185-             'status '  => self ::STATUS_ACTIVE ,
187+             'status '  => static ::STATUS_ACTIVE ,
186188        ]);
187189    }
188190
0 commit comments