コード例 #1
0
 public function action()
 {
     $team = new Team();
     $team->initById($this->parameters->teamId);
     $teamInJSON = JSONPrepare::team($team);
     $teamInJSON["footballers"] = JSONPrepare::footballers(FootballerSatellite::initForTeam($team));
     $teamInJSON["sponsors"] = JSONPrepare::sponsors(SponsorSatellite::initForTeam($team));
     $this->result['team'] = $teamInJSON;
 }
コード例 #2
0
ファイル: Team.php プロジェクト: rootree/vk-footboller-server
 public function initById($userId)
 {
     $this->socialUserId = intval($userId);
     if (!$this->socialUserId) {
         return new ErrorPoint(ErrorPoint::CODE_VK, "Не получен номер команды", ErrorPoint::TYPE_USER);
     }
     track_stats();
     // Отслеживаем производительность
     $teamInstance = RAM::getInstance()->getTeamById($this->socialUserId);
     track_stats();
     // Отслеживаем производительность
     if (empty($teamInstance)) {
         //} || GlobalParameters::$IS_FAKE_ENTER || GlobalParameters::MODER_ID == $userId){
         $sql_template = "SELECT *, unix_timestamp(tour_bonus_time) as tour_bonus_time FROM teams WHERE vk_id = %s";
         $sql = sprintf($sql_template, $this->socialUserId);
         $result = SQL::getInstance()->query($sql);
         if ($result instanceof ErrorPoint) {
             return $result;
         }
         track_stats();
         // Отслеживаем производительность
         if ($result->num_rows) {
             $loadedTeam = $result->fetch_object();
             $this->isInstalled = 1;
             $this->initFromDB($loadedTeam);
             track_stats();
             // Отслеживаем производительность
             $this->footballers = FootballerSatellite::initForTeam($this);
             if ($this->footballers instanceof ErrorPoint) {
                 return $this->footballers;
             }
             track_stats();
             // Отслеживаем производительность
             $this->sponsors = SponsorSatellite::initForTeam($this);
             if ($this->sponsors instanceof ErrorPoint) {
                 return $this->sponsors;
             }
             return true;
         } else {
             if (GlobalParameters::getCommand() != COMMAND_PING && GlobalParameters::getCommand() != COMMAND_FRIEND_INFO && GlobalParameters::getCommand() != COMMAND_SYSTEM && GlobalParameters::getCommand() != COMMAND_WELCOME) {
                 // Utils::forDebug("Не найдена команда по ID#" . $this->socialUserId . " " . $sql);
                 return false;
                 return new ErrorPoint(ErrorPoint::CODE_LOGIC, "Не найдена команда по ID#" . $this->socialUserId, ErrorPoint::TYPE_SYSTEM);
             } else {
                 $this->inTeam = 0;
                 return false;
             }
         }
     } else {
         $this->initFromRAM($teamInstance);
         $this->isInstalled = 1;
         track_stats();
         // Отслеживаем производительность
         $this->footballers = FootballerSatellite::initForTeam($this);
         if ($this->footballers instanceof ErrorPoint) {
             return $this->footballers;
         }
         track_stats();
         // Отслеживаем производительность
         $this->sponsors = SponsorSatellite::initForTeam($this);
         if ($this->sponsors instanceof ErrorPoint) {
             return $this->sponsors;
         }
         track_stats();
         // Отслеживаем производительность
         return true;
     }
 }