/** * Used by confirm, unconfirm, and ban to change the status of this eam * @param int $status * @param string $svc * @return boolean */ private function set_status($status, $svc) { //Orphaned team if ($this->orphan_error()) { return false; } //No change if ($this->data['status'] == $status) { return true; } //Tournament already started if (BBHelper::tournament_is_active($this->tournament)) { return $this->set_error('Cannot change team status after tournament has already started!'); } //Not a real team yet, just change the status to 1 if (is_null($this->id)) { $this->set_new_data('status', $status); return true; } //Let the API handle the rest $result = $this->call($svc, array('tourney_team_id' => $this->id)); if ($result->result != BinaryBeast::RESULT_SUCCESS) { return $this->set_error('Unable to set team ' . $this->id . ' status to ' . BBHelper::translate_team_status($status)); } //Success! $this->set_current_data('status', $svc); return true; }
/** * Returns an array of matches that still need to be reported * * Each item in the array will be an instance of BBMatch, which you can use * to submit the results * * @param boolean $force_reload * False by default * Enable this to force querying for a fresh list from the API * Warning: this does NOT mean that cached results will be cleared, that must be done separately * * @return BBMatch[]|null|boolean */ public function &open_matches($force_reload = false) { //Already cached if (!is_null($this->open_matches) && !$force_reload) { return $this->open_matches; } //Inactive tournament if (!BBHelper::tournament_is_active($this)) { $this->set_error('cannot load open matches of an inactive tournament, start() it first'); return $this->bb->ref(null); } //Ask the api $result = $this->call(self::SERVICE_LIST_OPEN_MATCHES, array('tourney_id' => $this->id), self::CACHE_TTL_LIST_OPEN_MATCHES, self::CACHE_OBJECT_TYPE, $this->id); if (!$result) { return $this->bb->ref(false); } //Cast each match into BBMatch, and call init() so it knows which tournament it belongs to foreach ($result->matches as $match_data) { //Instantiate and initialize $match = $this->bb->match($match_data); $match->init($this); //queue it up! $this->open_matches[] = $match; } //Success! return $this->open_matches; }