/**
  * @return void
  * @desc Re-build from data posted by this control the data object this control is editing
  */
 function BuildPostedDataObject()
 {
     $o_comp = new Competition($this->GetSettings());
     if (isset($_POST['item'])) {
         $o_comp->SetId($_POST['item']);
     }
     $o_comp->SetIsActive(isset($_POST['active']));
     $o_comp->SetName($_POST['name']);
     $o_comp->SetIntro(ucfirst(trim($_POST['intro'])));
     $o_comp->SetContact($_POST['contact']);
     $o_comp->SetWebsiteUrl($_POST['website']);
     $o_comp->SetNotificationEmail($_POST['notification']);
     $o_comp->SetShortUrl($_POST[$this->GetNamingPrefix() . 'ShortUrl']);
     $o_comp->SetPlayerType($_POST['playerType']);
     $o_comp->SetMaximumPlayersPerTeam($_POST['players']);
     $o_comp->SetOvers($_POST['overs']);
     $s_key = $this->GetNamingPrefix() . 'category';
     if (isset($_POST[$s_key]) && $_POST[$s_key] && is_numeric($_POST[$s_key])) {
         $cat = new Category();
         $cat->SetId($_POST[$s_key]);
         $o_comp->SetCategory($cat);
     }
     $this->SetDataObject($o_comp);
 }
 /**
  * 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);
     }
 }