예제 #1
0
 /**
  * Only include matches where a specific team played
  *
  * @param  Team   $team   Team        The team which played the matches
  * @param  string $result string|null The outcome of the matches (win, draw or loss)
  * @return self
  */
 public function with($team, $result = null)
 {
     if (!$team || !$team->isValid()) {
         return $this;
     }
     switch ($result) {
         case "wins":
         case "win":
         case "victory":
         case "victories":
             $query = "(team_a = ? AND team_a_points > team_b_points) OR (team_b = ? AND team_b_points > team_a_points)";
             break;
         case "loss":
         case "lose":
         case "losses":
         case "defeat":
         case "defeats":
             $query = "(team_a = ? AND team_b_points > team_a_points) OR (team_b = ? AND team_a_points > team_b_points)";
             break;
         case "draw":
         case "draws":
         case "tie":
         case "ties":
             $query = "(team_a = ? OR team_b = ?) AND team_a_points = team_b_points";
             break;
         default:
             $query = "team_a = ? OR team_b = ?";
     }
     $this->conditions[] = $query;
     $this->parameters[] = $team->getId();
     $this->parameters[] = $team->getId();
     $this->types .= 'ii';
     return $this;
 }
예제 #2
0
 /**
  * Only include matches where a specific team/player played
  *
  * @param  Team|Player $participant The team/player which played the matches
  * @param  string      $result      The outcome of the matches (win, draw or loss)
  * @return self
  */
 public function with($participant, $result = null)
 {
     if (!$participant || !$participant->isValid()) {
         return $this;
     }
     if ($participant instanceof Team) {
         $team_a_query = "team_a = ?";
         $team_b_query = "team_b = ?";
     } elseif ($participant instanceof Player) {
         $team_a_query = "FIND_IN_SET(?, team_a_players)";
         $team_b_query = "FIND_IN_SET(?, team_b_players)";
     } else {
         throw new InvalidArgumentException("Invalid model provided");
     }
     switch ($result) {
         case "wins":
         case "win":
         case "victory":
         case "victories":
             $query = "({$team_a_query} AND team_a_points > team_b_points) OR ({$team_b_query} AND team_b_points > team_a_points)";
             break;
         case "loss":
         case "lose":
         case "losses":
         case "defeat":
         case "defeats":
             $query = "({$team_a_query} AND team_b_points > team_a_points) OR ({$team_b_query} AND team_a_points > team_b_points)";
             break;
         case "draw":
         case "draws":
         case "tie":
         case "ties":
             $query = "({$team_a_query} OR {$team_b_query}) AND team_a_points = team_b_points";
             break;
         default:
             $query = "{$team_a_query} OR {$team_b_query}";
     }
     $this->conditions[] = $query;
     $this->parameters[] = $participant->getId();
     $this->parameters[] = $participant->getId();
     return $this;
 }
예제 #3
0
 public function load()
 {
     $this->clear();
     // Miami Hurricanes
     $team = new Team('Miami, FL');
     $team->setOfficialName('University of Miami');
     $team->setNickname('Hurricanes');
     $team->setCity('Miami');
     $team->setState('FL');
     $team->setNcaaId(415);
     $level = $this->CI->_level->findOneBySlug('college');
     $team->setLevel($level);
     $league = $this->CI->_league->findOneBySlug('ncaa');
     $team->setLeague($league);
     $division = $this->CI->_division->findOneBySlug('d1');
     $team->setDivision($division);
     $conference = $this->CI->_conference->findOneBySlug('atlantic-coast');
     $team->setConference($conference);
     $team->save();
     print_r(sprintf("Created Team: %s (%s)\n", $team->getName(), $team->getId()));
     // Maryland Terrapins
     $team = new Team('Maryland');
     $team->setOfficialName('University of Maryland');
     $team->setNickname('Terrapins');
     $team->setCity('College Park');
     $team->setState('FL');
     $team->setNcaaId(392);
     $level = $this->CI->_level->findOneBySlug('college');
     $team->setLevel($level);
     $league = $this->CI->_league->findOneBySlug('ncaa');
     $team->setLeague($league);
     $division = $this->CI->_division->findOneBySlug('d1');
     $team->setDivision($division);
     $conference = $this->CI->_conference->findOneBySlug('atlantic-coast');
     $team->setConference($conference);
     $team->save();
     print_r(sprintf("Created Team: %s (%s)\n", $team->getName(), $team->getId()));
 }
예제 #4
0
파일: Group.php 프로젝트: kleitz/bzion
 /**
  * Remove a member from the discussion
  *
  * @todo
  *
  * @param  Player|Team $member The member to remove
  * @return void
  */
 public function removeMember($member)
 {
     if ($member instanceof Player) {
         $this->db->query("DELETE FROM `player_groups` WHERE `group` = ? AND `player` = ?", "ii", array($this->getId(), $member->getId()));
     } else {
         throw new Exception("Not implemented yet");
     }
 }
예제 #5
0
파일: Team.php 프로젝트: CarolinePaixao/SCI
 public static function getTeams()
 {
     $dados = Database::ReadAll("team t", "t.*");
     if (!$dados) {
         return '';
     }
     foreach ($dados as $dado) {
         $team = new Team();
         $team->setId($dado['ID_TEAM']);
         $team->setName($dado['NAME_TEAM']);
         $team->setStatus($dado['STATUS']);
         $calebe = Calebe::getCalebe("AND c.id_person = " . $dado['ID_LEADER']);
         $team->setLeader($calebe);
         $team->setMembers(Team::getMembersTeam($team->getId()));
         $teams[] = $team;
     }
     return $teams;
 }
예제 #6
0
파일: Match.php 프로젝트: allejo/bzion
 /**
  * Get the team's old ELO
  * @param  Team $team The team whose old ELO to return
  * @return int|null   The old ELO, or null if the team provided has not
  *                    participated in the match
  */
 public function getTeamEloOld(Team $team)
 {
     if ($team->getId() == $this->team_a) {
         return $this->getTeamAEloOld();
     } elseif ($team->getId() == $this->team_b) {
         return $this->getTeamBEloOld();
     }
     return null;
 }
예제 #7
0
 public function findAvailable(Team $team)
 {
     $q = $this->createQuery('u')->where('NOT EXISTS (SELECT * FROM UserPerTeam upt WHERE upt.team_id = ? and upt.user_id = u.id)', $team->getId());
     return $q->execute();
 }
예제 #8
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Team $obj A Team object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         TeamPeer::$instances[$key] = $obj;
     }
 }
예제 #9
0
 /**
  * Exclude object from result
  *
  * @param   Team $team Object to remove from the list of results
  *
  * @return TeamQuery The current query, for fluid interface
  */
 public function prune($team = null)
 {
     if ($team) {
         $this->addUsingAlias(TeamPeer::ID, $team->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
예제 #10
0
 /**
  * Checks and repairs the internal consistency of the object.
  *
  * This method is executed after an already-instantiated object is re-hydrated
  * from the database.  It exists to check any foreign keys to make sure that
  * the objects related to the current object are correct based on foreign key.
  *
  * You can override this method in the stub class, but you should always invoke
  * the base method from the overridden method (i.e. parent::ensureConsistency()),
  * in case your model changes.
  *
  * @throws PropelException
  */
 public function ensureConsistency()
 {
     if ($this->aDealer !== null && $this->dealer_id !== $this->aDealer->getId()) {
         $this->aDealer = null;
     }
     if ($this->aTeam !== null && $this->team_id !== $this->aTeam->getId()) {
         $this->aTeam = null;
     }
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function serialize()
 {
     return serialize(array('team' => $this->team->getId(), 'deleter' => $this->deleter->getId()));
 }
예제 #12
0
파일: TeamTest.php 프로젝트: bchhun/bzion
 public function testMiscMethods()
 {
     $this->team = Team::createTeam("Sample Team", $this->player->getId(), "Avatar", "Description");
     $team = Team::get($this->team->getId());
     $this->assertEquals("now", $team->getCreationDate());
 }
예제 #13
0
파일: edit_team.php 프로젝트: fg-ok/codev
 private function getTooltipProjectCandidates(Team $team)
 {
     $projects = $team->getProjects();
     $teamid = $team->getId();
     $candidatesList = array();
     foreach ($projects as $id => $name) {
         $project = ProjectCache::getInstance()->getProject($id);
         // do not display SideTasksProjects & ExternalTaskProject
         if ($project->isExternalTasksProject() || $project->isSideTasksProject(array($teamid))) {
             continue;
         }
         $candidatesList[$id] = $name;
     }
     return $candidatesList;
 }
예제 #14
0
 public function removeTeam(Team $team)
 {
     $this->unlink('Teams', array($team->getId()));
     $this->save();
 }
예제 #15
0
 function lookup($id)
 {
     return $id && is_numeric($id) && ($team = new Team($id)) && $team->getId() == $id ? $team : null;
 }
예제 #16
0
 /**
  * Add a member to the discussion
  *
  * @param  Player|Team $member   The member to add
  * @param  bool        $distinct Whether to add the member as a distinct
  *                               player (ignored for teams)
  * @return void
  */
 public function addMember($member, $distinct = true)
 {
     if ($member instanceof Player) {
         // Mark individual players as distinct by creating or updating the
         // entry on the table
         if ($distinct) {
             $query = "INSERT INTO `player_conversations` (`conversation`, `player`, `distinct`) VALUES (?, ?, 1)\n                  ON DUPLICATE KEY UPDATE `distinct` = 1";
         } else {
             $query = "INSERT IGNORE INTO `player_conversations` (`conversation`, `player`, `distinct`, `read`) VALUES (?, ?, 0, 1)";
         }
         $this->db->execute($query, array($this->getId(), $member->getId()));
     } elseif ($member instanceof Team) {
         // Add the team to the team_conversations table...
         $this->db->execute("INSERT IGNORE INTO `team_conversations` (`conversation`, `team`) VALUES (?, ?)", array($this->getId(), $member->getId()));
         // ...and each of its members in the player_conversations table as
         // non-distinct (unless they were already there)
         foreach ($member->getMembers() as $player) {
             $this->db->execute("INSERT IGNORE INTO `player_conversations` (`conversation`, `player`, `distinct`) VALUES (?, ?, 0)", array($this->getId(), $player->getId()));
         }
     }
 }
예제 #17
0
파일: Match.php 프로젝트: blast007/bzion
 /**
  * Find out whether the match involves a team
  *
  * @param  Team $team The team to check
  * @return bool
  */
 public function involvesTeam($team)
 {
     return $team->getId() == $this->team_a || $team->getId() == $this->team_b;
 }