示例#1
0
 /**
  * Get the rating, percentage out of 100%
  * @return int
  */
 public static function getMax()
 {
     switch (isset(static::$maxVotes)) {
         case false:
             $ret_val = 100000000000000.0;
             switch (static::$allowMultiple) {
                 case false:
                     $ret_val = User::find()->where(['disabled' => 0])->count();
                     break;
             }
             static::$maxVotes = $ret_val;
             break;
         default:
             $ret_val = static::$maxVotes;
             break;
     }
     return $ret_val;
 }
示例#2
0
 private function getTokens($active = true, $revoked = false)
 {
     $ret_val = null;
     //First of all does this user exist?
     $user = $this->hasOne(User::className(), ['user_id' => 'user_id']);
     switch ($user instanceof User) {
         case true:
             $cond = ['active' => 1, 'revoked' => 0];
             switch ($active) {
                 case false:
                     $cond['active'] = 0;
                     break;
             }
             switch ($revoked) {
                 case true:
                     $cond['revoked'] = 1;
                     break;
             }
             //Ok let's get their tokens
             $ret_val = $this->hasMany(Tokens::className(), ['user_id' => 'user_id'])->where($cond)->asArray()->all();
             break;
     }
     return $ret_val;
 }