Esempio n. 1
0
 /**
  * @return Season
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         if (isset($_GET['year']) && is_numeric($_GET['year']) && strlen($_GET['year']) == 4) {
             $year = $_GET['year'];
         } else {
             // assume new season starts in august
             if (date('n') >= 8) {
                 // assume it' not updated before the 25th (random guess) of august
                 $year = date('Y');
                 if (date('n') == 8 && date('j') < 25) {
                     $year--;
                 }
             } else {
                 // from jan to aug, use season that started last year
                 $year = date('Y') - 1;
             }
         }
         self::$instance = self::getSingle(array('nefub_id' => $year));
         if (!self::$instance) {
             self::$instance = new Season();
             self::$instance->nefub_id = $year;
             self::$instance->save();
         }
     }
     return self::$instance;
     $this->instance = $oSeason;
 }
 function OnPrePageLoad()
 {
     $this->SetPageTitle("Map of the " . $this->season->GetCompetitionName());
     $this->SetPageDescription("See a map of all the stoolball teams playing in the " . $this->season->GetCompetitionName() . ".");
     $this->LoadClientScript("/scripts/lib/markerclusterer_compiled.js");
     $this->LoadClientScript('/scripts/maps-3.js');
     $this->LoadClientScript("map.js.php?season=" . $this->season->GetId(), true);
 }
 public function load()
 {
     $this->clear();
     // Alfredo Rodriguez (Maryland)
     $season = new Season();
     $season->setYear(2012);
     $season->save();
     print_r(sprintf("Created Season: %s, %s (%s)\n", $player->getName(), $season->getYear(), $player->getId()));
 }
 function OnPrePageLoad()
 {
     # set up page
     $this->SetOpenGraphType("sports_league");
     $this->SetPageTitle("League table for the " . $this->season->GetCompetitionName());
     require_once "search/competition-search-adapter.class.php";
     $adapter = new CompetitionSearchAdapter($this->competition);
     $this->SetPageDescription($adapter->GetSearchDescription());
     $this->SetContentConstraint(StoolballPage::ConstrainBox());
     $this->SetContentCssClass("season-table");
 }
 function OnPageLoad()
 {
     /* @var $season Season */
     echo new XhtmlElement('h1', htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false));
     # display the season
     if (!is_object($this->season)) {
         $this->season = new Season($this->GetSettings());
         if (isset($_GET['competition'])) {
             $comp = new Competition($this->GetSettings());
             $comp->SetId($_GET['competition']);
             $this->season->SetCompetition($comp);
         }
         /* Create instruction panel */
         $panel = new XhtmlElement('div');
         $panel->SetCssClass('panel instructionPanel');
         $title_inner1 = new XhtmlElement('div', 'Tips for adding seasons');
         $title = new XhtmlElement('h2', $title_inner1);
         $panel->AddControl($title);
         $tab_tip = new XhtmlElement('ul');
         $tab_tip->AddControl(new XhtmlElement('li', "You'll be able to edit more details after you click 'Save'"));
         $panel->AddControl($tab_tip);
         echo $panel;
     }
     $this->edit->SetDataObject($this->season);
     echo $this->edit;
     parent::OnPageLoad();
 }
Esempio n. 6
0
 function process()
 {
     global $CONFIG;
     $query_args = array('_order' => 'e.type,e.open,e.close,e.registration_id');
     $season_id = $_GET['season'];
     if ($season_id > 0) {
         $current_season = Season::load(array('id' => $season_id));
         $query_args['season_id'] = $season_id;
         $this->title = "{$current_season->display_name} Registration";
     } else {
         $this->title = "Registration";
         $query_args['_extra'] = 'e.open < DATE_ADD(NOW(), INTERVAL 1 WEEK) AND e.close > NOW()';
         $season_id = -1;
     }
     $this->template_name = 'pages/event/list.tpl';
     $pulldown_choices = getOptionsFromQuery("SELECT s.id AS theKey, s.display_name AS theValue FROM season s, registration_events e WHERE e.season_id = s.id GROUP BY s.id HAVING count(*) > 0 ORDER BY s.year, s.season");
     $pulldown_choices[-1] = "All open events";
     $this->smarty->assign('seasons', $pulldown_choices);
     $this->smarty->assign('season_id', $season_id);
     $type_desc = event_types();
     $events = array();
     $sth = Event::query($query_args);
     while ($e = $sth->fetchObject('Event')) {
         $e->full_type = $type_desc[$e->type];
         $events[] = $e;
     }
     $this->smarty->assign('events', $events);
     return true;
 }
Esempio n. 7
0
 /**
  *
  * @return Season
  */
 public function getSeason()
 {
     if (!$this->season) {
         $this->season = Season::getByNefubId($this->season_nefub_id);
     }
     return $this->season;
 }
Esempio n. 8
0
    public function __construct($seasonId, $requestedWeek = null) {

        $this->season = Season::getByLink($seasonId);
        $this->week = 1;
        $time = time();

        while($this->week < $this->season->getWeeksCount()
            && $this->season->weekIsPublished($this->week)) {
            $this->week++;
        }

        $maxWeekMatch = Match::findOne('seasonid = ? order by week desc limit 1', [$this->season->seasonid]);
        $this->maxWeek = $maxWeekMatch->week;

        if (!Team::isMember()) {
            while (!$this->season->weekIsPublic($this->maxWeek)) {
                $this->maxWeek--;
            }
        }

        if ($requestedWeek && $requestedWeek <= $this->maxWeek) {
            $this->week = $requestedWeek;
        }
        else if ($requestedWeek) {
            HTMLResponse::exitWithRoute("/");
        }

        $this->canVote = ($this->season->getPublishTimeForWeek($this->week) - $time > 3600);
    }
 /**
  * Generates the XHTML for the control
  *
  * @return string
  */
 public function __toString()
 {
     $s_xhtml = parent::__toString();
     if ($this->o_season->PointsAdjustments()->GetCount()) {
         $s_xhtml .= '<p>The results table includes the following points adjustments:</p><ul>';
         $this->o_season->PointsAdjustments()->SortByProperty('GetDate');
         foreach ($this->o_season->PointsAdjustments() as $o_point) {
             /* @var $o_point PointsAdjustment */
             # Convert sign to positive the non-maths way
             $i_positive_points = (int) str_replace('-', '', $o_point->GetPoints());
             $s_points = $i_positive_points > 1 ? ' points' : ' point';
             $s_reason = $o_point->GetReason() ? ' for ' . $o_point->GetReason() : '';
             # Display a message about each adjustment
             if ($o_point->GetPoints() > 0) {
                 $s_xhtml .= '<li>' . htmlentities($i_positive_points . $s_points . ' awarded to ' . $o_point->GetTeam()->GetName() . $s_reason, ENT_QUOTES, "UTF-8", false) . '</li>';
             } elseif ($o_point->GetPoints() < 0) {
                 $s_xhtml .= '<li>' . htmlentities($i_positive_points . $s_points . ' deducted from ' . $o_point->GetTeam()->GetName() . $s_reason, ENT_QUOTES, "UTF-8", false) . '</li>';
             }
         }
         $s_xhtml .= '</ul>';
     }
     if (count($this->a_results_missing)) {
         $s_xhtml .= '<p class="resultPending">Waiting for results from:</p><ul class="resultPending"><li>' . implode('</li><li>', $this->a_results_missing) . '</li></ul>';
     }
     return $s_xhtml;
 }
 function OnLoadPageData()
 {
     # Set up to get stats for current season
     $four_months = 60 * 60 * 24 * 30 * 4;
     $season_dates = Season::SeasonDates();
     require_once 'stoolball/statistics/statistics-manager.class.php';
     $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection());
     $statistics_manager->FilterMaxResults(1);
     do {
         # get stats
         $statistics_manager->FilterAfterDate($season_dates[0]);
         $this->best_batting = $statistics_manager->ReadBestBattingPerformance();
         $this->best_bowling = $statistics_manager->ReadBestBowlingPerformance();
         $this->most_runs = $statistics_manager->ReadBestPlayerAggregate("runs_scored");
         $this->most_wickets = $statistics_manager->ReadBestPlayerAggregate("wickets");
         $this->most_catches = $statistics_manager->ReadBestPlayerAggregate("catches");
         # See what stats we've got
         $this->best_batting_count = count($this->best_batting);
         $this->best_bowling_count = count($this->best_bowling);
         $this->most_runs_count = count($this->most_runs);
         $this->most_wickets_count = count($this->most_wickets);
         $this->most_catches_count = count($this->most_catches);
         $has_player_stats = ($this->best_batting_count or $this->best_bowling_count or $this->most_runs_count or $this->most_wickets_count or $this->most_catches_count);
         if ($has_player_stats) {
             $start_year = gmdate("Y", $season_dates[0]);
             $end_year = gmdate("Y", $season_dates[1]);
             $this->highlight_label = ($start_year == $end_year ? $start_year : $start_year . "/" . substr($end_year, 2)) . " season";
         }
         # If there aren't any for this season (if it's the start of the season), go back 4 months and try again to get previous season
         $season_dates = Season::SeasonDates($season_dates[0] - $four_months);
     } while (!$has_player_stats);
     unset($statistics_manager);
 }
Esempio n. 11
0
File: Index.php Progetto: xJakub/LCE
 /**
  * @return void
  */
 public function show()
 {
     $season = Season::findOne('ispublic order by isdefault desc limit 1');
     if ($season) {
         HTMLResponse::exitWithRoute('/' . $season->getLink() . '/');
     }
 }
Esempio n. 12
0
 /**
  * @expectedException \bmtmgr\utils\DuplicateEntryException
  */
 public function testSeasonDuplicates()
 {
     Model::connect();
     $s = Season::create('dup', false, 'http://example.org/foo3');
     $s->save();
     $s2 = Season::create('dup', true, 'http://example.org/foo4');
     $s2->save();
 }
Esempio n. 13
0
 function __construct($id)
 {
     $this->season = Season::load(array('id' => $id));
     if (!$this->season) {
         error_exit("That season does not exist");
     }
     season_add_to_menu($this->season);
 }
Esempio n. 14
0
 /**
  * 
  * @param mixed $input
  * @param NefubObject $oOutput
  */
 protected static function handleMapping($input, NefubObject $oOutput)
 {
     $oOutput->nefub_id = $input->ID;
     $oOutput->name = $input->Name;
     $oOutput->club_nefub_id = $input->Club->ID;
     $oOutput->color_shirt = $input->Dress->Shirt;
     $oOutput->color_shorts = $input->Dress->Short;
     $oOutput->competition_nefub_id = $input->Competition->ID;
     $oOutput->season_nefub_id = Season::getInstance()->nefub_id;
 }
Esempio n. 15
0
 /**
  * @param mixed $input
  * @param NefubObject $oOutput
  */
 protected static function handleMapping($input, NefubObject $oOutput)
 {
     $oOutput->nefub_id = $input->ID;
     $oOutput->competition_nefub_id = $input->Competition->ID;
     $oOutput->season_nefub_id = Season::getInstance()->nefub_id;
     $oOutput->name = $input->Name;
     $oOutput->information = $input->Information;
     $oPouleType = NefubTypeMapper::mapTypeFromAPI($input->Type, 'PouleType');
     $oOutput->poule_type_id = $oPouleType->getId();
 }
Esempio n. 16
0
 protected function __construct()
 {
     $this->season = Season::getInstance();
     $this->smarty = new Smarty();
     $arguments = explode('?', $_SERVER['REQUEST_URI']);
     $arguments = strtolower($arguments[0]);
     $arguments = explode('/', $arguments);
     array_shift($arguments);
     $this->arguments = $arguments;
 }
 public function checkForDuplicateStartDates()
 {
     global $wpdb;
     $sql = "\n\t\t\tSELECT\n\t\t\t  COUNT(*) cnt\n\t\t\tFROM\n\t\t\t  `" . Season::table_name() . "` s\n\t\t\tWHERE\n\t\t\t  start_date IS NOT NULL\n\t\t\tGROUP BY\n\t\t\t  start_date\n\t\t\tHAVING\n\t\t\t  cnt > 1\n\t\t";
     if ($wpdb->get_var($sql)) {
         $issue = new SeasonsIssue();
         $issue->type = 'duplicate_start_dates';
         $this->issues[] = $issue;
     }
 }
    function OnPageLoad()
    {
        echo "<h1>Statistics for " . htmlentities($this->season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . "</h1>";
        require_once "_summary-data-found.php";
        require_once 'xhtml/navigation/tabs.class.php';
        $tabs = array('Summary' => $this->season->GetNavigateUrl());
        if ($this->season->MatchTypes()->Contains(MatchType::LEAGUE)) {
            $tabs['Table'] = $this->season->GetTableUrl();
        }
        if (count($this->season->GetTeams())) {
            $tabs['Map'] = $this->season->GetMapUrl();
        }
        $tabs['Statistics'] = '';
        echo new Tabs($tabs);
        ?>

        <div class="box tab-box">
            <div class="dataFilter"></div>
            <div class="box-content">
        <?php 
        if (!$has_player_stats) {
            echo "<p>There aren't any statistics for the " . htmlentities($this->season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . ' yet.</p>
			<p>To find out how to add them, see <a href="/play/manage/website/matches-and-results-why-you-should-add-yours/">Matches and results - why you should add yours</a>.</p>' . "<p>You can also view the <a href=\"" . htmlentities($this->season->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . "\">" . htmlentities($this->season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . " page</a>.</p>";
        } else {
            require_once "_summary-controls.php";
        }
        # Check for other seasons. Check is >2 becuase current season is there twice - added above
        if (count($this->competition->GetSeasons()) > 2) {
            require_once "stoolball/season-list-control.class.php";
            echo new XhtmlElement('h2', htmlentities('More statistics for the ' . $this->competition->GetName(), ENT_QUOTES, "UTF-8", false));
            $season_list = new SeasonListControl($this->competition->GetSeasons());
            $season_list->SetExcludedSeasons(array($this->season));
            $season_list->SetUrlMethod('GetStatisticsUrl');
            # Override XHTML to add link to competition stats
            $season_list_xhtml = $season_list->__toString();
            $season_list_xhtml = str_replace("<ul>", "<ul><li><a href=\"" . htmlentities($this->competition->GetStatisticsUrl(), ENT_QUOTES, "UTF-8", false) . "\">All seasons</a></li>", (string) $season_list_xhtml);
            echo $season_list_xhtml;
        }
        ?>
        </div>
        </div>
        <?php 
    }
Esempio n. 19
0
 public static function getPlannedTeamGames(Team $oTeam, $bIncludeEvents = true)
 {
     $query = "SELECT Game.*\r\n\t\t\t\t\t\tFROM Game\t\t\t\t\t\t\r\n\t\t\t\t\t\tWHERE Game.date >= CURDATE()\r\n\t\t\t\t\t\tAND\r\n\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tGame.team1_nefub_id = '" . $oTeam->nefub_id . "'\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\tGame.team2_nefub_id = '" . $oTeam->nefub_id . "'\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tOR\r\n\t\t\t\t\t\t\tGame.nefub_id IN\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\tSELECT Referee.game_nefub_id\r\n\t\t\t\t\t\t\t\tFROM Referee\r\n\t\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tReferee.team_nefub_id = '" . $oTeam->nefub_id . "'\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t\tAND Game.date IS NOT NULL\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tORDER BY Game.date ASC,\r\n\t\t\t\t\tGame.time ASC";
     $aGames = Game::getAllFromQuery($query);
     if ($bIncludeEvents) {
         $oGender = $oTeam->getCompetition()->getGender();
         $oGenre = $oTeam->getCompetition()->getGenre();
         $aEvents = Event::getAll(array('gender_id' => $oGender->getId(), 'genre_id' => $oGenre->getId(), 'season_nefub_id' => Season::getInstance()->nefub_id), 'date');
     }
     return $aGames;
 }
Esempio n. 20
0
 function process()
 {
     global $lr_session;
     $current_season_id = strtolower(variable_get('current_season', 'ongoing'));
     $this->title = "Season List";
     $this->template_name = 'pages/season/list.tpl';
     $seasons = Season::load_many(array('_order' => 'year DESC, season ASC'));
     $this->smarty->assign('current_season', $current_season_id);
     $this->smarty->assign('seasons', $seasons);
     return true;
 }
Esempio n. 21
0
 function __construct($load_mode = LOAD_RELATED_DATA)
 {
     // If we have a parent, override the overridables.
     if ($this->parent_fid) {
         $parent = Field::load(array('fid' => $this->parent_fid));
         $this->name = $parent->name;
         $this->code = $parent->code;
         $this->region = $parent->region;
         $this->location_street = $parent->location_street;
         $this->location_city = $parent->location_city;
         $this->location_province = $parent->location_province;
         $this->location_country = $parent->location_country;
         $this->driving_directions = $parent->driving_directions;
         $this->transit_directions = $parent->transit_directions;
         $this->biking_directions = $parent->biking_directions;
         $this->parking_details = $parent->parking_details;
         $this->washrooms = $parent->washrooms;
         $this->public_instructions = $parent->public_instructions;
         $this->site_instructions = $parent->site_instructions;
         $this->sponsor = $parent->sponsor;
         $this->location_url = $parent->location_url;
         $this->layout_url = $parent->layout_url;
         $this->fullname = join(" ", array($this->name, $this->num));
         $this->is_indoor = $parent->is_indoor;
         // Fields may have their own parking details, or inherit from the parent
         if (!$this->parking) {
             $this->parking = $parent->parking;
         }
     }
     if ($load_mode == LOAD_OBJECT_ONLY) {
         return;
     }
     $current_season_id = strtolower(variable_get("current_season", 1));
     $current_season = Season::load(array('id' => $current_season_id));
     $permit_dir = join("/", array(strtolower($current_season->season), $current_season->year, 'permits'));
     $system_permit_dir = join("/", array(variable_get("league_file_base", '/opt/websites/www.ocua.ca/static-content/leagues'), $permit_dir));
     # Auto-detect the permit URLs
     $this->permit_url = '';
     if (is_dir($system_permit_dir)) {
         if ($dh = opendir($system_permit_dir)) {
             while (($file = readdir($dh)) !== false) {
                 if (fnmatch($this->code . "*", $file)) {
                     $this->permit_url .= l($file, variable_get("league_url_base", 'http://www.ocua.ca/leagues') . "/{$permit_dir}/{$file}\"") . '<br />';
                 }
             }
         }
     }
     if (!$this->rating) {
         # If no rating, mark as unknown
         $this->rating = '?';
     }
     return true;
 }
Esempio n. 22
0
 /**
  * 
  * @return array
  */
 public function getTeamPersons($includeTransferedFrom = true, $includeTransferedTo = true)
 {
     $where = '';
     if (!$includeTransferedTo) {
         $where .= " AND TeamPerson.transfered != 1";
     }
     if (!$includeTransferedFrom) {
         $where .= " AND TeamPerson.transfered != -1";
     }
     $query = "SELECT TeamPerson.id\n\t\t\t\t\tFROM TeamPerson\n\t\t\t\t\tLEFT JOIN Team ON Team.nefub_id = TeamPerson.team_nefub_id\n\t\t\t\t\tWHERE\n\t\t\t\t\tTeamPerson.person_nefub_id = '" . $this->nefub_id . "'\n\t\t\t\t\tAND Team.season_nefub_id = '" . Season::getInstance()->nefub_id . "'\n\t\t\t\t\t{$where}\n\t\t\t\t\tGROUP BY TeamPerson.team_nefub_id\n\t\t\t\t\tORDER BY TeamPerson.team_nefub_id ASC";
     return TeamPerson::getAllFromQuery($query);
 }
 function OnPrePageLoad()
 {
     if (isset($this->i_season_id)) {
         $this->SetPageTitle('New ' . MatchType::Text($this->i_match_type) . ' in ' . $this->season->GetCompetitionName());
     } else {
         if ($this->team instanceof Team) {
             $this->SetPageTitle('New ' . MatchType::Text($this->i_match_type) . ' for ' . $this->team->GetName());
         }
     }
     $this->SetContentConstraint(StoolballPage::ConstrainText());
     $this->SetContentCssClass('matchEdit');
     $this->LoadClientScript('/scripts/match-fixture-edit-control-5.js');
 }
 /**
  * If the to or from parameters are in the query string apply date filter and return dates
  * @param StatisticsManager $statistics_manager
  */
 public static function SupportDateFilter(StatisticsManager $statistics_manager)
 {
     $filter_data = array(null, null, "");
     $filter_data[0] = "";
     if (isset($_GET['from'])) {
         # Replace slashes with hyphens in submitted date because then it's treated as a British date, not American
         $date = is_numeric($_GET['from']) ? (int) $_GET['from'] : strtotime(str_replace("/", "-", $_GET['from']));
         if ($date !== false) {
             $filter_data[0] = $date;
         }
     }
     $to = "";
     if (isset($_GET['to'])) {
         # Replace slashes with hyphens in submitted date because then it's treated as a British date, not American
         $date = is_numeric($_GET['to']) ? (int) $_GET['to'] : strtotime(str_replace("/", "-", $_GET['to']));
         if ($date !== false) {
             $filter_data[1] = $date;
         }
     }
     if ($filter_data[0]) {
         $statistics_manager->FilterAfterDate($filter_data[0]);
     }
     if ($filter_data[1]) {
         $statistics_manager->FilterBeforeDate($filter_data[1]);
     }
     if ($filter_data[0] and $filter_data[1]) {
         # Test whether this is a season
         $three_months_later = intval($filter_data[0]) + 60 * 60 * 24 * 30 * 3;
         $season_dates = Season::SeasonDates($three_months_later);
         if ($filter_data[0] == $season_dates[0] and $filter_data[1] == $season_dates[1]) {
             $start_year = gmdate("Y", $filter_data[0]);
             $end_year = gmdate("Y", $filter_data[1]);
             if ($start_year == $end_year) {
                 $filter_data[2] = "in the {$start_year} season ";
             } else {
                 $filter_data[2] = "in the {$start_year}/" . substr($end_year, 2, 2) . " season ";
             }
         } else {
             $filter_data[2] = "between " . Date::BritishDate($filter_data[0], false, true, false) . " and " . Date::BritishDate($filter_data[1], false, true, false) . " ";
         }
     } else {
         if ($filter_data[0]) {
             $filter_data[2] = "since " . Date::BritishDate($filter_data[0], false, true, false) . " ";
         } else {
             if ($filter_data[1]) {
                 $filter_data[2] = "before " . Date::BritishDate($filter_data[1], false, true, false) . " ";
             }
         }
     }
     return $filter_data;
 }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete season: ' . $this->data_object->GetCompetitionName()));
        if ($this->deleted) {
            ?>
			<p>The season has been deleted.</p>
			<p><a href="<?php 
            echo Html::Encode($this->data_object->GetCompetition()->GetNavigateUrl());
            ?>
">View <?php 
            echo Html::Encode($this->data_object->GetCompetition()->GetName());
            ?>
</a></p>
			<?php 
        } else {
            # Only offer delete option if there's more than one season. Don't want to delete last season because
            # that leaves an empty competition which won't display. Instead, must delete whole competition with its one remaining season.
            if ($this->has_permission and $this->seasons_in_competition > 1) {
                ?>
				<p>Deleting a season cannot be undone. Matches will not be deleted, but they will no longer be a part of this season.</p>
				<p>Are you sure you want to delete this season?</p>
				<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteSeasonUrl());
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete season" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this season');
                $panel->AddLink('view this season', $this->data_object->GetNavigateUrl());
                $panel->AddLink('edit this season', $this->data_object->GetEditSeasonUrl());
                echo $panel;
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this season.</p>
				<p><a href="<?php 
                echo Html::Encode($this->data_object->GetNavigateUrl());
                ?>
">Go back to the season</a></p>
				<?php 
            }
        }
    }
 function OnPrePageLoad()
 {
     if (!is_null($this->team)) {
         $this->SetPageTitle('Match results for ' . $this->team->GetName());
     } else {
         if (!is_null($this->season)) {
             $this->SetPageTitle('Match results for ' . $this->season->GetCompetitionName());
         } else {
             if (!is_null($this->tournament)) {
                 $this->SetPageTitle('Match results for ' . $this->tournament->GetTitle());
             }
         }
     }
     $this->LoadClientScript('/scripts/match-results-3.js');
     $this->LoadClientScript("/scripts/tiny_mce/jquery.tinymce.js");
     $this->LoadClientScript("/scripts/tinymce.js");
 }
 function OnLoadPageData()
 {
     /* @var Team $team */
     # check parameter
     if (!isset($_GET['item']) or !is_numeric($_GET['item'])) {
         $this->Redirect();
     }
     # get team
     $team_manager = new TeamManager($this->GetSettings(), $this->GetDataConnection());
     $team_manager->FilterByTeamType(array());
     $team_manager->ReadById(array($_GET['item']));
     $this->team = $team_manager->GetFirst();
     unset($team_manager);
     # must have found a team
     if (!$this->team instanceof Team) {
         $this->Redirect('/teams/');
     }
     # get match stats
     require_once 'stoolball/statistics/statistics-manager.class.php';
     $statistics_manager = new StatisticsManager($this->GetSettings(), $this->GetDataConnection());
     $statistics_manager->FilterByTeam(array($this->team->GetId()));
     $statistics_manager->ReadMatchStatistics();
     $this->stats = $statistics_manager->GetItems();
     # Get some stats on the best players
     $this->statistics_query = "?team=" . $this->team->GetId();
     if ($this->season) {
         # use midpoint of season to get season dates for filter
         $start_year = substr($this->season, 0, 4);
         $end_year = strlen($this->season) == 7 ? $start_year + 1 : $start_year;
         if ($start_year == $end_year) {
             $season_dates = Season::SeasonDates(mktime(0, 0, 0, 7, 1, $start_year));
         } else {
             $season_dates = Season::SeasonDates(mktime(0, 0, 0, 12, 31, $start_year));
         }
         $statistics_manager->FilterAfterDate($season_dates[0]);
         $statistics_manager->FilterBeforeDate($season_dates[1]);
         $this->statistics_query .= "&amp;from=" . $season_dates[0] . "&amp;to=" . $season_dates[1];
     }
     $statistics_manager->FilterMaxResults(10);
     $this->most_runs = $statistics_manager->ReadBestPlayerAggregate("runs_scored");
     $this->most_wickets = $statistics_manager->ReadBestPlayerAggregate("wickets");
     $this->most_catches = $statistics_manager->ReadBestPlayerAggregate("catches");
     $this->most_run_outs = $statistics_manager->ReadBestPlayerAggregate("run_outs");
     $this->most_player_of_match = $statistics_manager->ReadBestPlayerAggregate("player_of_match");
     unset($statistics_manager);
 }
Esempio n. 28
0
 public static function getPlannedEvents($date = null, Genre $oGenre = null, Gender $oGender = null)
 {
     $query = "SELECT Event.id\n\t\t\t\t\tFROM Event\n\t\t\t\t\tWHERE Event.season_nefub_id = '" . Season::getInstance()->nefub_id . "'\n\t\t\t\t\t ";
     if ($oGender) {
         $query .= " AND Event.gender_id " . $oGender->getId();
     }
     if ($oGenre) {
         $query .= " AND Event.genre_id " . $oGenre->getId();
     }
     if ($date) {
         $query .= " AND Event.date = '" . str_replace("'", '', $date) . "'";
     } else {
         $query .= ' AND DATE(Event.date) >= CURDATE()';
     }
     $query .= ' GROUP BY gender_id';
     $query .= ' ORDER BY Event.date ASC';
     return self::getAllFromQuery($query);
 }
Esempio n. 29
0
 protected function runTeamSchedule($nefubId, $date)
 {
     if (is_numeric($nefubId) && $date) {
         if ($oTeam = Team::getByNefubId($nefubId)) {
             $formattedDate = strftime("%A %e %B %Y", strtotime($date));
             $filename = 'agenda ' . $date . ' ' . $oTeam->name;
             $oSeason = Season::getInstance();
             $query = "SELECT Game.id FROM Game WHERE Game.date = '" . $date . "' \n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(\tGame.team1_nefub_id = '" . $oTeam->nefub_id . "' OR\n\t\t\t\t\t\t\t\t\tGame.team2_nefub_id = '" . $oTeam->nefub_id . "' OR\n\t\t\t\t\t\t\t\t\tGame.ref_team_nefub_id = '" . $oTeam->nefub_id . "')\n\t\t\t\t\t\t\tORDER BY Game.time, Game.field;\n\t\t\t\t\t\t";
             $aGames = Game::getAllFromQuery($query);
             if (count($aGames)) {
                 $title = 'Programma ' . $formattedDate . ' voor ' . utf8_decode($oTeam->name) . ' (' . $oTeam->getCompetition()->name . ')';
                 $footer = $title . '. Gedownload van http://' . $_SERVER['HTTP_HOST'] . '/team/' . $nefubId;
                 $this->renderGames($filename, $title, $aGames, $footer, false);
             }
         }
     }
     $this->redirect();
 }
Esempio n. 30
0
 function process()
 {
     global $lr_session;
     $current_season_id = $_GET['season'];
     if (!$current_season_id) {
         $current_season_id = strtolower(variable_get('current_season', 1));
     }
     $current_season = Season::load(array('id' => $current_season_id));
     if (!$current_season) {
         $current_season_id = 1;
         $current_season = Season::load(array('id' => $current_season_id));
     }
     $this->title = "{$current_season->display_name} Leagues";
     $this->template_name = 'pages/league/list.tpl';
     $this->smarty->assign('seasons', getOptionsFromQuery("SELECT id AS theKey, display_name AS theValue FROM season ORDER BY year, id"));
     $this->smarty->assign('current_season', $current_season);
     $current_season->load_leagues();
     $this->smarty->assign('leagues', $current_season->leagues);
     return true;
 }