function OnSiteInit()
 {
     parent::OnSiteInit();
     # check parameter
     if (isset($_GET['season']) and is_numeric($_GET['season'])) {
         $this->season = new Season($this->GetSettings());
         $this->season->SetId((int) $_GET['season']);
     }
     if (isset($_GET['team']) and is_numeric($_GET['team'])) {
         $this->team = new Team($this->GetSettings());
         $this->team->SetId($_GET['team']);
     }
 }
 function OnPostback()
 {
     $this->season = $this->edit->GetDataObject();
     if (!$this->season->GetId()) {
         $existing_season_id = $this->season_manager->CheckIfSeasonExists($this->season->GetCompetition()->GetId(), $this->season->GetStartYear(), $this->season->GetEndYear());
         if ($existing_season_id) {
             require_once 'data/validation/required-field-validator.class.php';
             $season = new Season($this->GetSettings());
             $season->SetId($existing_season_id);
             $validator = new RequiredFieldValidator('This_Validator_Will_Fail', "The season you're adding already exists &#8211; <a href=\"" . $season->GetNavigateUrl() . "\">edit season</a>");
             $validator->SetValidIfNotFound(false);
             $this->edit->AddValidator($validator);
         }
     }
     # Get the competition. This is used to build the page title and, when saving, the short URL.
     # It is also re-indexed in search below.
     $this->competition_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection());
     $this->competition_manager->ReadById(array($this->season->GetCompetition()->GetId()));
     $this->season->SetCompetition($this->competition_manager->GetFirst());
     unset($this->competition_manager);
     # save data if valid
     if ($this->IsValid()) {
         $b_saved_new = !(bool) $this->season->GetId();
         $id = $this->season_manager->SaveSeason($this->season);
         $this->season->SetId($id);
         # Add the competition to the search  engine. Re-request so we have team names as well as IDs.
         require_once "search/competition-search-adapter.class.php";
         $this->SearchIndexer()->DeleteFromIndexById("competition" . $this->season->GetCompetition()->GetId());
         $adapter = new CompetitionSearchAdapter($this->season->GetCompetition());
         $this->SearchIndexer()->Index($adapter->GetSearchableItem());
         $this->SearchIndexer()->CommitChanges();
         # If just saved a new season, redirect to load this page from scratch
         # (When just loading data on this page, didn't load correctly into aggregated editors)
         if ($b_saved_new) {
             $this->Redirect($this->season->GetEditSeasonUrl());
         }
         $this->Redirect($this->season->GetNavigateUrl());
     }
 }
 /**
  * Builds a match object containing the result information posted by the control
  *
  */
 public function BuildPostedDataObject()
 {
     $match = new Match($this->GetSettings());
     $match->SetMatchType(MatchType::TOURNAMENT);
     # Get match id
     $s_key = $this->GetNamingPrefix() . 'item';
     if (isset($_POST[$s_key])) {
         $s_id = $_POST[$s_key];
         if (strlen($s_id)) {
             $match->SetId($s_id);
         }
     }
     # Get the title
     $s_key = $this->GetNamingPrefix() . 'Title';
     if (isset($_POST[$s_key])) {
         $match->SetTitle(strip_tags($_POST[$s_key]));
     }
     $s_key = $this->GetNamingPrefix() . 'Seasons';
     if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) {
         $possibly_posted = explode(';', $_POST[$s_key]);
         foreach ($possibly_posted as $season_id) {
             $s_key = $this->GetNamingPrefix() . 'Season' . $season_id;
             if (isset($_POST[$s_key]) and $_POST[$s_key] == $season_id) {
                 $season = new Season($this->GetSettings());
                 $season->SetId($_POST[$s_key]);
                 $match->Seasons()->Add($season);
             }
         }
     }
     $this->SetDataObject($match);
 }
 /**
  * @return void
  * @desc Re-build from data posted by this control the data object this control is editing
  */
 function BuildPostedDataObject()
 {
     /* @var $o_season Season */
     $o_season = new Season($this->GetSettings());
     if (isset($_POST['start']) and is_numeric($_POST['start'])) {
         $o_season->SetStartYear($_POST['start']);
     }
     $i_year_span = isset($_POST['when']) ? (int) $_POST['when'] : 0;
     $o_season->SetEndYear($o_season->GetStartYear() + $i_year_span);
     $o_season->SetName($o_season->GetYears());
     if (isset($_POST['item'])) {
         $o_season->SetId($_POST['item']);
     } else {
         $this->b_saving_new = true;
         $this->match_types_editor->SetMinimumItems(0);
         # because will be populated from previous season (if there is one)
     }
     $o_season->SetIntro(ucfirst(trim($_POST['intro'])));
     $o_season->SetShortUrl($_POST[$this->GetNamingPrefix() . 'ShortUrl']);
     # Get the competition short URL and generate a season URL, rather than providing
     # a direct interface for season URLs.
     $o_comp = new Competition($this->GetSettings());
     $o_comp->SetId($_POST['competition']);
     $o_season->SetCompetition($o_comp);
     # Match types - get from aggregated editor
     $selected_match_types = $this->match_types_editor->DataObjects()->GetItems();
     foreach ($selected_match_types as $id_value) {
         $o_season->MatchTypes()->Add($id_value->GetId());
     }
     # Results and rules
     if (isset($_POST['results'])) {
         $o_season->SetResults($_POST['results']);
     }
     foreach ($this->result_types as $o_result) {
         /*@var $o_result MatchResult */
         $s_key = $this->GetNamingPrefix() . 'Result' . $o_result->GetResultType() . 'Home';
         if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
             $o_result->SetHomePoints($_POST[$s_key]);
         }
         $s_key = $this->GetNamingPrefix() . 'Result' . $o_result->GetResultType() . 'Away';
         if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
             $o_result->SetAwayPoints($_POST[$s_key]);
         }
         if (!is_null($o_result->GetHomePoints()) or !is_null($o_result->GetAwayPoints())) {
             $o_season->PossibleResults()->Add($o_result);
         }
     }
     # Points adjustments - get from aggregated editor
     $o_season->PointsAdjustments()->SetItems($this->adjustments_editor->DataObjects()->GetItems());
     # Show league table?
     $o_season->SetShowTable(isset($_POST['showTable']));
     $o_season->SetShowTableRunsScored(isset($_POST['runsScored']));
     $o_season->SetShowTableRunsConceded(isset($_POST['runsConceded']));
     # Teams - get from aggregated editor
     $a_teams_in_season = $this->teams_editor->DataObjects()->GetItems();
     foreach ($a_teams_in_season as $team_in_season) {
         /* @var $team_in_season TeamInSeason */
         $o_season->AddTeam($team_in_season->GetTeam());
         if ($team_in_season->GetWithdrawnFromLeague()) {
             $o_season->TeamsWithdrawnFromLeague()->Add($team_in_season->GetTeam());
         }
     }
     $this->SetDataObject($o_season);
 }
 /**
  * Helper to build season and competition for a match from raw data
  *
  * @param Match $o_match
  * @param DataRow $o_row
  * @param CollectionBuilder $season_builder
  */
 private function BuildSeason(Match $o_match, $o_row, $season_builder = null)
 {
     if (isset($o_row->season_id) and (is_null($season_builder) or !$season_builder->IsDone($o_row->season_id))) {
         $o_season = $o_match->Seasons()->GetItemByProperty('GetId', (int) $o_row->season_id);
         $b_existing_season = is_object($o_season);
         if (!$b_existing_season) {
             $o_season = new Season($this->GetSettings());
         }
         $o_season->SetId($o_row->season_id);
         if (isset($o_row->season_name)) {
             $o_season->SetName($o_row->season_name);
         }
         if (isset($o_row->season_short_url)) {
             $o_season->SetShortUrl($o_row->season_short_url);
         }
         if (isset($o_row->start_year)) {
             $o_season->SetStartYear($o_row->start_year);
         }
         if (isset($o_row->end_year)) {
             $o_season->SetEndYear($o_row->end_year);
         }
         $o_comp = new Competition($this->GetSettings());
         if (isset($o_row->competition_id)) {
             $o_comp->SetId($o_row->competition_id);
         }
         if (isset($o_row->competition_name)) {
             $o_comp->SetName($o_row->competition_name);
         }
         if (isset($o_row->notification_email)) {
             $o_comp->SetNotificationEmail($o_row->notification_email);
         }
         $o_comp->Add($o_season);
         if (!$b_existing_season) {
             $o_match->Seasons()->Add($o_season);
         }
     }
 }
 /**
  * Builds a match object containing the result information posted by the control
  *
  */
 public function BuildPostedDataObject()
 {
     $o_match = new Match($this->GetSettings());
     # Get match id
     $s_key = $this->GetNamingPrefix() . 'item';
     if (isset($_POST[$s_key])) {
         $s_id = $_POST[$s_key];
         if (strlen($s_id)) {
             $o_match->SetId($s_id);
         }
     }
     # Get the short URL
     $s_key = $this->GetNamingPrefix() . 'ShortUrl';
     if (isset($_POST[$s_key])) {
         $o_match->SetShortUrl($_POST[$s_key]);
     }
     # Get the start date
     $s_key = $this->GetNamingPrefix() . 'Start';
     $o_match->SetStartTime(DateControl::GetPostedTimestampUtc($s_key));
     $o_match->SetIsStartTimeKnown(DateControl::GetIsTimePosted($s_key));
     # Get the home team
     # Test for (int)$_POST[$s_key] deliberately excludes "Not known" value, which is 0
     $o_home = new Team($this->GetSettings());
     $s_key = $this->GetNamingPrefix() . 'Home';
     if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and (int) $_POST[$s_key]) {
         $o_home->SetId($_POST[$s_key]);
         $o_match->SetHomeTeam($o_home);
     }
     # Get the away team
     # Test for (int)$_POST[$s_key] deliberately excludes "Not known" value, which is 0
     $o_away = new Team($this->GetSettings());
     $s_key = $this->GetNamingPrefix() . 'Away';
     if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and (int) $_POST[$s_key]) {
         $o_away->SetId($_POST[$s_key]);
         $o_match->SetAwayTeam($o_away);
     }
     # Get the ground
     $s_key = $this->GetNamingPrefix() . 'Ground';
     if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) {
         $o_ground = new Ground($this->GetSettings());
         $o_ground->SetId($_POST[$s_key]);
         $o_match->SetGround($o_ground);
     }
     # Get the notes
     $s_key = $this->GetNamingPrefix() . 'Notes';
     if (isset($_POST[$s_key])) {
         $o_match->SetNotes($_POST[$s_key]);
     }
     # Get the match type
     $s_key = $this->GetNamingPrefix() . 'MatchType';
     if (isset($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
         $o_match->SetMatchType($_POST[$s_key]);
     }
     # Get the tournament
     if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
         $s_key = $this->GetNamingPrefix() . 'Tournament';
         if (isset($_POST[$s_key]) and is_numeric($_POST[$s_key])) {
             $tournament = new Match($this->GetSettings());
             $tournament->SetMatchType(MatchType::TOURNAMENT);
             $tournament->SetId($_POST[$s_key]);
             $o_match->SetTournament($tournament);
         }
     }
     # Get the season
     $s_key = $this->GetNamingPrefix() . 'Season';
     if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) {
         $o_season = new Season($this->GetSettings());
         $o_season->SetId($_POST[$s_key]);
         $o_match->Seasons()->Add($o_season);
     }
     $this->SetDataObject($o_match);
 }
 /**
  * Populates the collection of business objects from raw data
  *
  * @return bool
  * @param MySqlRawData $o_result
  */
 protected function BuildItems(MySqlRawData $o_result)
 {
     $this->Clear();
     /* @var $o_team Team */
     # use CollectionBuilder to handle duplicates
     $o_team_builder = new CollectionBuilder();
     $o_season_builder = new CollectionBuilder();
     $o_team = null;
     while ($row = $o_result->fetch()) {
         # check whether this is a new team
         if (!$o_team_builder->IsDone($row->team_id)) {
             # store any exisiting team
             if ($o_team != null) {
                 $this->Add($o_team);
                 $o_season_builder->Reset();
             }
             # create the new team
             $o_team = new Team($this->o_settings);
             $o_team->SetId($row->team_id);
             $o_team->SetName($row->team_name);
             if (isset($row->website)) {
                 $o_team->SetWebsiteUrl($row->website);
             }
             if (isset($row->active)) {
                 $o_team->SetIsActive($row->active);
             }
             if (isset($row->team_type)) {
                 $o_team->SetTeamType($row->team_type);
             }
             if (isset($row->intro)) {
                 $o_team->SetIntro($row->intro);
             }
             if (isset($row->playing_times)) {
                 $o_team->SetPlayingTimes($row->playing_times);
             }
             if (isset($row->cost)) {
                 $o_team->SetCost($row->cost);
             }
             if (isset($row->contact)) {
                 $o_team->SetContact($row->contact);
             }
             if (isset($row->contact_nsa)) {
                 $o_team->SetPrivateContact($row->contact_nsa);
             }
             if (isset($row->short_url)) {
                 $o_team->SetShortUrl($row->short_url);
             }
             if (isset($row->player_type_id)) {
                 $o_team->SetPlayerType($row->player_type_id);
             }
             $o_team->SetSchoolYears(array(1 => isset($row->year1) and $row->year1, 2 => isset($row->year2) and $row->year2, 3 => isset($row->year3) and $row->year3, 4 => isset($row->year4) and $row->year4, 5 => isset($row->year5) and $row->year5, 6 => isset($row->year6) and $row->year6, 7 => isset($row->year7) and $row->year7, 8 => isset($row->year8) and $row->year8, 9 => isset($row->year9) and $row->year9, 10 => isset($row->year10) and $row->year10, 11 => isset($row->year11) and $row->year11, 12 => isset($row->year12) and $row->year12));
             if (isset($row->update_search) and $row->update_search == 1) {
                 $o_team->SetSearchUpdateRequired();
             }
             if (isset($row->date_changed)) {
                 $o_team->SetLastAudit(new AuditData($row->modified_by_id, $row->known_as, $row->date_changed));
             }
             $club = new Club($this->GetSettings());
             if (isset($row->club_id)) {
                 $club->SetId($row->club_id);
                 if (isset($row->club_name)) {
                     $club->SetName($row->club_name);
                 }
                 if (isset($row->twitter)) {
                     $club->SetTwitterAccount($row->twitter);
                 }
                 if (isset($row->facebook)) {
                     $club->SetFacebookUrl($row->facebook);
                 }
                 if (isset($row->instagram)) {
                     $club->SetInstagramAccount($row->instagram);
                 }
                 if (isset($row->clubmark)) {
                     $club->SetClubmarkAccredited($row->clubmark);
                 }
                 if (isset($row->club_short_url)) {
                     $club->SetShortUrl($row->club_short_url);
                 }
             }
             # If the website is actually a Facebook page, move it, overriding the club Facebook page is necessary
             if (strpos($o_team->GetWebsiteUrl(), 'facebook.com/') !== false) {
                 $club->SetFacebookUrl($o_team->GetWebsiteUrl());
                 $o_team->SetWebsiteUrl('');
             }
             $o_team->SetClub($club);
             if (isset($row->ground_id) and $row->ground_id) {
                 $o_ground = new Ground($this->o_settings);
                 $o_ground->SetId($row->ground_id);
                 $address = $o_ground->GetAddress();
                 if (isset($row->saon)) {
                     $address->SetSaon($row->saon);
                 }
                 if (isset($row->town)) {
                     if (isset($row->paon)) {
                         $address->SetPaon($row->paon);
                     }
                     if (isset($row->street_descriptor)) {
                         $address->SetStreetDescriptor($row->street_descriptor);
                     }
                     if (isset($row->locality)) {
                         $address->SetLocality($row->locality);
                     }
                     $address->SetTown($row->town);
                     if (isset($row->administrative_area)) {
                         $address->SetAdministrativeArea($row->administrative_area);
                     }
                     if (isset($row->postcode)) {
                         $address->SetPostcode($row->postcode);
                     }
                     if (isset($row->latitude)) {
                         $address->SetGeoLocation($row->latitude, $row->longitude, null);
                     }
                     $o_ground->SetAddress($address);
                 }
                 if (isset($row->ground_short_url)) {
                     $o_ground->SetShortUrl($row->ground_short_url);
                 }
                 $o_team->SetGround($o_ground);
             }
         }
         # Competition/Season a cause of multiple rows
         if (isset($row->season_id) and !$o_season_builder->IsDone($row->season_id) and isset($row->competition_id)) {
             $o_season = new Season($this->o_settings);
             $o_season->SetId($row->season_id);
             $o_season->SetName($row->season_name);
             $o_season->SetIsLatest($row->is_latest);
             $o_season->SetStartYear($row->start_year);
             $o_season->SetEndYear($row->end_year);
             if (isset($row->season_short_url)) {
                 $o_season->SetShortUrl($row->season_short_url);
             }
             $o_competition = new Competition($this->o_settings);
             $o_competition->SetId($row->competition_id);
             $o_competition->SetName($row->competition_name);
             $o_season->SetCompetition($o_competition);
             $o_team->Seasons()->Add(new TeamInSeason(null, $o_season, isset($row->withdrawn_league) ? $row->withdrawn_league : null));
             unset($o_season);
             unset($o_competition);
         }
     }
     # store final team
     if ($o_team != null) {
         $this->Add($o_team);
     }
     return true;
 }
 /**
  * Adds season summary and competition data to an existing season
  *
  * @param Season $season
  * @param object $row
  */
 private function BuildSeason(Season $season, $row)
 {
     if (isset($row->season_id)) {
         $season->SetId($row->season_id);
         $season->SetName($row->season_name);
         if (isset($row->start_year)) {
             $season->SetStartYear($row->start_year);
         }
         if (isset($row->end_year)) {
             $season->SetEndYear($row->end_year);
         }
         if (isset($row->is_latest)) {
             $season->SetIsLatest($row->is_latest);
         }
         if (isset($row->intro)) {
             $season->SetIntro($row->intro);
         }
         if (isset($row->results)) {
             $season->SetResults($row->results);
         }
         if (isset($row->show_table)) {
             $season->SetShowTable($row->show_table);
         }
         if (isset($row->show_runs_scored)) {
             $season->SetShowTableRunsScored($row->show_runs_scored);
         }
         if (isset($row->show_runs_conceded)) {
             $season->SetShowTableRunsConceded($row->show_runs_conceded);
         }
         if (isset($row->short_url)) {
             $season->SetShortUrl($row->short_url);
         }
         $comp = new Competition($this->GetSettings());
         if (isset($row->competition_id)) {
             $comp->SetId($row->competition_id);
         }
         if (isset($row->competition_name)) {
             $comp->SetName($row->competition_name);
         }
         if (isset($row->competition_short_url)) {
             $comp->SetShortUrl($row->competition_short_url);
         }
         if (isset($row->notification_email)) {
             $comp->SetNotificationEmail($row->notification_email);
         }
         if (isset($row->player_type_id)) {
             $comp->SetPlayerType($row->player_type_id);
         }
         $season->SetCompetition($comp);
     }
 }
 /**
  * Populates the collection of business objects from raw data
  *
  * @return bool
  * @param MySqlRawData $o_result
  */
 protected function BuildItems(MySqlRawData $o_result)
 {
     /* @var $o_competition Competition */
     # use CollectionBuilder to handle duplicates
     $o_comp_builder = new CollectionBuilder();
     $o_season_builder = new CollectionBuilder();
     $o_team_builder = new CollectionBuilder();
     $o_points_builder = new CollectionBuilder();
     $o_matchtype_builder = new CollectionBuilder();
     $o_competition = null;
     $o_season = null;
     while ($o_row = $o_result->fetch()) {
         # check whether this is a new competition
         if (!$o_comp_builder->IsDone($o_row->competition_id)) {
             # store any exisiting competition and reset
             if ($o_competition != null) {
                 if ($o_season != null) {
                     $o_competition->AddSeason($o_season, true);
                 }
                 $o_season = null;
                 $o_matchtype_builder->Reset();
                 $this->Add($o_competition);
                 $o_season_builder->Reset();
             }
             # create the new competition
             $o_competition = new Competition($this->o_settings);
             $o_competition->SetId($o_row->competition_id);
             $o_competition->SetName($o_row->competition_name);
             if (isset($o_row->intro)) {
                 $o_competition->SetIntro($o_row->intro);
             }
             if (isset($o_row->contact)) {
                 $o_competition->SetContact($o_row->contact);
             }
             if (isset($o_row->notification_email)) {
                 $o_competition->SetNotificationEmail($o_row->notification_email);
             }
             if (isset($o_row->website)) {
                 $o_competition->SetWebsiteUrl($o_row->website);
             }
             if (isset($o_row->short_url)) {
                 $o_competition->SetShortUrl($o_row->short_url);
             }
             if (isset($o_row->active)) {
                 $o_competition->SetIsActive($o_row->active);
             }
             if (isset($o_row->players_per_team)) {
                 $o_competition->SetMaximumPlayersPerTeam($o_row->players_per_team);
             }
             if (isset($o_row->overs)) {
                 $o_competition->SetOvers($o_row->overs);
             }
             $o_competition->SetPlayerType($o_row->player_type_id);
             if (isset($o_row->update_search) and $o_row->update_search == 1) {
                 $o_competition->SetSearchUpdateRequired();
             }
             if (isset($o_row->category_id) && !is_null($o_row->category_id)) {
                 $cat = new Category();
                 $cat->SetId($o_row->category_id);
                 if (isset($o_row->category_name)) {
                     $cat->SetName($o_row->category_name);
                 }
                 if (isset($o_row->code)) {
                     $cat->SetUrl($o_row->code);
                 }
                 $o_competition->SetCategory($cat);
             }
         }
         # Seasons are the first cause of multiple rows (first in sort order after competition)
         if (isset($o_row->season_id)) {
             if (!$o_season_builder->IsDone($o_row->season_id)) {
                 if ($o_season != null) {
                     $o_competition->AddSeason($o_season, true);
                 }
                 $o_season = new Season($this->o_settings);
                 $o_season->SetId($o_row->season_id);
                 $o_season->SetName($o_row->season_name);
                 $o_season->SetIsLatest($o_row->is_latest);
                 $o_season->SetStartYear($o_row->start_year);
                 $o_season->SetEndYear($o_row->end_year);
                 if (isset($o_row->season_intro)) {
                     $o_season->SetIntro($o_row->season_intro);
                 }
                 if (isset($o_row->results)) {
                     $o_season->SetResults($o_row->results);
                 }
                 if (isset($o_row->show_table)) {
                     $o_season->SetShowTable($o_row->show_table);
                 }
                 if (isset($o_row->show_runs_scored)) {
                     $o_season->SetShowTableRunsScored($o_row->show_runs_scored);
                 }
                 if (isset($o_row->show_runs_conceded)) {
                     $o_season->SetShowTableRunsConceded($o_row->show_runs_conceded);
                 }
                 if (isset($o_row->season_short_url)) {
                     $o_season->SetShortUrl($o_row->season_short_url);
                 }
             }
             # Team only present if there is a season
             if (isset($o_row->team_id)) {
                 if (!$o_team_builder->IsDone($o_row->team_id)) {
                     if (isset($o_team)) {
                         unset($o_team);
                     }
                     $o_team = new Team($this->GetSettings());
                     $o_team->SetId($o_row->team_id);
                     $o_team->SetName($o_row->team_name);
                     $o_team->GetGround()->SetId($o_row->ground_id);
                     if (isset($o_row->team_short_url)) {
                         $o_team->SetShortUrl($o_row->team_short_url);
                     }
                     $o_season->AddTeam($o_team);
                     if (isset($o_row->withdrawn_league) and (bool) $o_row->withdrawn_league) {
                         $o_season->TeamsWithdrawnFromLeague()->Add($o_team);
                     }
                 }
                 # Points adjustments - should come with team and in order of team
                 if (isset($o_row->point_id) and !$o_points_builder->IsDone($o_row->point_id)) {
                     $o_point = new PointsAdjustment($o_row->point_id, $o_row->points, $o_team, $o_row->reason, $o_row->points_date);
                     $o_season->PointsAdjustments()->Add($o_point);
                 }
             }
             # Match types come with a season
             if (isset($o_row->match_type) and !$o_matchtype_builder->IsDone($o_row->match_type)) {
                 $o_season->MatchTypes()->Add((int) $o_row->match_type);
             }
         }
     }
     # store final competition
     if ($o_competition != null) {
         if ($o_season != null) {
             $o_competition->AddSeason($o_season, true);
         }
         $this->Add($o_competition);
     }
 }