Exemplo n.º 1
0
 public static function footballers($footballers)
 {
     $forJSON = array();
     foreach ($footballers as $footballerInstance) {
         $footballer = JSONPrepare::footballer($footballerInstance);
         $forJSON[] = $footballer;
     }
     return $forJSON;
 }
 public function getResult()
 {
     $this->result['isOk'] = 1;
     $this->result['footballer'] = JSONPrepare::footballer($this->result['footballer']);
     return $this->result;
 }
Exemplo n.º 3
0
 public function update()
 {
     if ($this->teamId != UserParameters::getUserId()) {
         return new ErrorPoint(ErrorPoint::CODE_SECURITY, "Техническая ошибка", ErrorPoint::TYPE_SYSTEM);
     }
     if ($this->getIsFriend()) {
         $sql_template = "UPDATE footballers_friends SET\nlevel = %d,\nis_active = %d,\ntype = %d,\nsuper = %d,\nhealth_down = %d,\nlogger = '%s'\nWHERE\nowner_vk_id = %d AND\nvk_id = %d";
         $sql = sprintf($sql_template, $this->getLevel(), $this->getIsActive(), $this->getType(), $this->getIsSuper(), $this->getHealthDown(), get_caller_method() . "\n\n" . json_encode(JSONPrepare::footballer($this)) . $this->teamId . "|" . UserParameters::getUserId() . $this->SQL, UserParameters::getUserId(), $this->getId());
         /*            $footballerInRAM = RAM::getInstance()->getFootballerFriendById($this->getId());
                     if($footballerInRAM === false){
                         $currentIndex = RAM::getInstance()->getMaxObjectIndexForTeam(UserParameters::getUserId(), RAM::RAM_TYPE_FOOTBALLER_FRIEND);
                         RAM::getInstance()->setFootballerFriend($this, UserParameters::getUserId(), $currentIndex); 
                     }else{
                         RAM::getInstance()->setFootballerFriend($this);
                     }*/
     } else {
         $sql_template = "UPDATE footballers SET\nlevel = %d,\nis_active = %d,\nsuper = %d,\nhealth_down = %d,\nlogger = '%s'\nWHERE\nowner_vk_id = %d AND\nfootballer_id = %d";
         $sql = sprintf($sql_template, $this->getLevel(), $this->getIsActive(), $this->getIsSuper(), $this->getHealthDown(), get_caller_method() . "\n\n" . json_encode(JSONPrepare::footballer($this)) . $this->teamId . "|" . UserParameters::getUserId() . $this->SQL, UserParameters::getUserId(), $this->getId());
         /*            $footballerInRAM = RAM::getInstance()->getFootballerById($this->getId(), UserParameters::getUserId());
             
                     if($footballerInRAM === false){ 
                         $currentIndex = RAM::getInstance()->getMaxObjectIndexForTeam(UserParameters::getUserId(), RAM::RAM_TYPE_FOOTBALLER);;
                         RAM::getInstance()->setFootballer($this, UserParameters::getUserId(), $currentIndex);
                     }else{
                         RAM::getInstance()->setFootballer($this, UserParameters::getUserId());
                     }*/
     }
     $result = SQL::getInstance()->query($sql);
     if ($result instanceof ErrorPoint) {
         return $result;
     }
 }