Beispiel #1
0
 public function ranking($vip = null)
 {
     if (!$vip) {
         $users = $this->user()->getAll() ?: [];
     } else {
         $users = $this->user()->find_by__vip($vip) ?: [];
     }
     $ratemodel = new rateModel();
     $res = [];
     foreach ($users as &$user) {
         $rec = ['id' => $user['id'], 'lastname' => $user['lastname'], 'firstname' => $user['firstname'], 'email' => $user['email'], 'url' => $user['url'], 'photo' => $user['photo'], 'title' => $user['title'], 'cover' => $user['cover'], 'vip' => $user['vip']];
         $rec['host'] = $this->points($user['id'], true, true);
         $rec['guest'] = $this->points($user['id'], false, true);
         $rec['total'] = $rec['host'] + $rec['guest'];
         $rec['ref_user'] = $user['ref_user'] ? $this->user($user['ref_user'])->url : '';
         $rec['ref_site'] = $user['ref_site'];
         $rec['ref_login'] = $user['ref_login'];
         $rec['since'] = '';
         if ($user['host_agreement']) {
             $rec['since'] = $user['host_agreement'];
         }
         if ($user['guest_agreement'] && !$rec['since']) {
             $rec['since'] = $user['guest_agreement'];
         }
         if ($user['guest_agreement'] && $rec['since']) {
             $rec['since'] = min($rec['since'], $user['guest_agreement']);
         }
         $rec['rate'] = $ratemodel->user($user['id']);
         $rec['reviews'] = $ratemodel->user_count($user['id']);
         $res[sprintf("%09d", 1000 * $rec['total']) . sprintf("%09d", 1000000 - $user['id']) . $user['url']] = $rec;
     }
     krsort($res);
     $result = [];
     foreach ($res as $r) {
         $result[] = $r;
     }
     return $result;
 }
Beispiel #2
0
 protected function _get_user($user_id)
 {
     $token = 'user:'******'firstname', 'lastname', 'url', 'photo', 'about', 'gender', 'title', 'vip', 'lang'] as $k) {
         $ret[$k] = $user->{$k};
     }
     $ratemodel = new rateModel();
     $rate = $ratemodel->user($user_id);
     $ret['rate'] = ['rate' => 0 + $rate, 'prc' => round(20 * $rate), 'count' => 0 + $ratemodel->user_count($user_id)];
     return Tools::memcache($token, $ret);
 }