/** * Add a player to the match. * * @param object Player to add or NULL for a forfeit. * @param integer Position of player in line-up. * @return void */ public function addPlayer($Position, $Player, $Handicap = null, $Paid = null) { parent::addPlayer($Position, $Player, $Handicap, $Paid); if (isset($this->players[0]) && isset($this->players[1]) && $this->players[0]->player !== null && $this->players[1]->player !== null) { $doubles = my5280::$instance->getDoubles($this->players[0]->player, $this->players[1]->player); if (isset($this->players[4])) { $this->players[4]->player_id = $doubles->getId(); $this->players[4]->player = $doubles; } else { $session = $this->getSession(); $info = array('id' => null, 'match_id' => $this->getId(), 'position' => 4, 'team_id' => $this->data->home_team, 'player_id' => $doubles->getId(), 'handicap' => round($doubles->getHandicap($this->getDate(), $session->getMaxHandicapGames()), 0), 'paid' => null, 'player' => $doubles); $this->players[4] = (object) $info; ksort($this->players); } } if (isset($this->players[2]) && isset($this->players[3]) && $this->players[2]->player !== null && $this->players[3]->player !== null) { $doubles = my5280::$instance->getDoubles($this->players[2]->player, $this->players[3]->player); if (isset($this->players[5])) { $this->players[5]->player_id = $doubles->getId(); $this->players[5]->player = $doubles; } else { if (!isset($session)) { $session = $this->getSession(); } $this->players[5] = (object) array('id' => null, 'match_id' => $this->getId(), 'position' => 5, 'team_id' => $this->data->away_team, 'player_id' => $doubles->getId(), 'handicap' => round($doubles->getHandicap($this->getDate(), $session->getMaxHandicapGames()), 0), 'paid' => null, 'player' => $doubles); ksort($this->players); } } }
/** * listMatches: Retrieve an array of matches for the session. * * @param string (Optional) Boolean indicating if only finished matches (those with a home or away score) should * be provided. Default FALSE. * @return array */ public function listMatches($DoneOnly = false) { if (empty($this->matches)) { require_once __DIR__ . '/match.php'; // Include the appropriate match class file $format = $this->getLeagueFormat(); $matches = array(); // Load the teams (for lookup) $this->listTeams(); global $leaguemanager; $filter = array('league_id' => $this->getLeagueId(), 'season' => $this->getName(), 'limit' => false); if ($DoneOnly) { $filter['home_points'] = 'not_null'; $filter['away_points'] = 'not_null'; } foreach ($leaguemanager->getMatches($filter) as $match) { // Add the match and index it $index = $match->id; if ($index == null) { $index = -count($this->matches); } $matches[$index] = my5280_Match::factory($match, $format); } // Store the matches and index arrays if (!$DoneOnly) { $this->matches = $matches; } else { return $matches; } } return $this->matches; }