Esempio n. 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;
 }
Esempio n. 2
0
 public function getUniqueToken($id = null)
 {
     $id = is_null($id) ? $this->user_id : $id;
     switch (($user = User::find((int) $id)) == null) {
         case true:
             throw new NotFoundHttpException('The requested user does not exist.');
             break;
     }
     switch ($user->api_key == null) {
         case true:
             $user->generateApiToken();
             break;
     }
     return \yii\helpers\Security::hashData(uniqid(), $user->api_key, 'fnv164');
 }