/** * Overload {@link BBModel::__set()} so we can handle setting team ids, and draw manually * * Supports setting the following properties: * - tourney_team_id (calls @link set_winner()) * - winner (calls @link set_winner()) * - o_tourney_team_id (calls @link set_loser()) * - loser (calls @link set_loser()) * - draw (calls @link set_draw()) * * @ignore * {@inheritdoc} */ public function __set($name, $value) { //set_winner() if ($name == 'tourney_team_id' || $name == 'winner') { return $this->set_winner($value); } //set_loser() if ($name == 'o_tourney_team_id' || $name == 'loser') { return $this->set_loser($value); } //set_draw() if ($name == 'draw') { //Can only used to ENABLE draw, can't be used to disable it if ($value != false) { return $this->set_draw(); } return; } parent::__set($name, $value); }
/** * Overloaded so that we can validate the value of best_of, * and re-calculate the wins_needed when it changes * * @ignore * {@inheritdoc} */ public function __set($name, $value) { //Make sure that when setting best_of, that it's a valid value if ($name == 'best_of') { $value = BBHelper::get_best_of($value); //Store directly into $data - if we reset, it'll be overwritten automatically $this->data['wins_needed'] = BBHelper::get_wins_needed($value); } //setting map_id - change map instead if ($name == 'map_id') { $name = 'map'; } //Let the default method handle the rest parent::__set($name, $value); }
/** * Overloaded to update map when trying to set map_id, and so we can treat * attempts to change team ids by calling set_winner|loser * * @ignore * {@inheritdoc} */ public function __set($name, $value) { //If setting team ids, run it through set_winner / set_loser if ($name == 'tourney_team_id') { return $this->set_winner($value); } if ($name == 'o_tourney_team_id') { return $this->set_loser($value); } if ($name == 'map_id') { $name = 'map'; } parent::__set($name, $value); }
/** * Overloaded to allow setting the status value - so we can intercept with the appropriate * status method (confirm() unconfirm() ban()) * * @ignore * {@inheritdoc} */ public function __set($name, $value) { if ($name == 'status') { if ($value == -1) { return $this->ban(); } if ($value == 0) { return $this->unconfirm(); } if ($value == 1) { return $this->confirm(); } } //Don't allow changing wins during active-groups, only during brackets if ($name == 'wins') { if (BBHelper::tournament_in_group_rounds($this->tournament())) { return; } } //Special handling for setting race value - he could be changing it by ID or by Name if ($name == 'race') { //Don't bother if we've already saved a value in new_data if (!isset($this->new_data['race'])) { //Treat it as an attempt to define by race id integer if (is_numeric($value)) { //The value is not new, don't save if ($value == $this->race_id) { return; } } else { if ($value == $this->race) { return; } } } } parent::__set($name, $value); }
/** * Overloads {@link BBModel::__set()} so we can prevent setting the type_id of an active tournament * * @ignore * {@inheritdoc} */ public function __set($name, $value) { if (strtolower($name) == 'type_id') { if (BBHelper::tournament_is_active($this)) { return; } } parent::__set($name, $value); }