Exemplo n.º 1
0
 function process()
 {
     global $lr_session;
     $this->title = $this->team->name;
     $this->template_name = 'pages/team/view.tpl';
     $this->smarty->assign('team', $this->team);
     if ($this->team->home_field) {
         $field = Field::load(array('fid' => $this->team->home_field));
         $this->smarty->assign('home_field', $field);
     }
     $teamSBF = $this->team->calculate_sbf();
     if ($teamSBF) {
         $this->smarty->assign('team_sbf', $teamSBF);
         $league = League::load(array('league_id' => $this->team->league_id));
         $this->smarty->assign('league_sbf', $league->calculate_sbf());
     }
     if ($lr_session->has_permission('team', 'player shirts', $this->team->team_id)) {
         $this->smarty->assign('display_shirts', true);
     }
     $rosterPositions = Team::get_roster_positions();
     $this->smarty->assign('roster_positions', $rosterPositions);
     $this->team->get_roster();
     $this->team->check_roster_conflict();
     foreach ($this->team->roster as $player) {
         $player->status = $rosterPositions[$player->status];
     }
     $min_roster = $league->min_roster_size;
     if ($this->team->roster_count < $min_roster && ($lr_session->is_captain_of($this->team->team_id) || $lr_session->is_admin()) && $this->team->roster_deadline > 0) {
         $this->smarty->assign('roster_requirement', $min_roster);
         $this->smarty->assign('display_roster_note', true);
     }
     return true;
 }
Exemplo n.º 2
0
 function process()
 {
     global $lr_session;
     $this->title = "{$this->team->name} &raquo; Spirit";
     $this->template_name = 'pages/team/spirit.tpl';
     // load the league
     $league = League::load(array('league_id' => $this->team->league_id));
     // if the person doesn't have permission to see this team's spirit, bail out
     if (!$lr_session->has_permission('team', 'view', $this->team->team_id, 'spirit')) {
         error_exit("You do not have permission to view this team's spirit results");
     }
     if ($league->display_sotg == 'coordinator_only' && !$lr_session->is_coordinator_of($league->league_id)) {
         error_exit("Spirit results are restricted to coordinator-only");
     }
     $s = new Spirit();
     $s->display_numeric_sotg = $league->display_numeric_sotg();
     /*
      * Grab schedule info
      */
     $games = Game::load_many(array('either_team' => $this->team->team_id, '_order' => 'g.game_date'));
     if (!is_array($games)) {
         error_exit('There are no games scheduled for this team');
     }
     $this->smarty->assign('question_keys', array_merge(array('full'), $s->question_keys(), array('score_entry_penalty')));
     $this->smarty->assign('question_headings', $s->question_headings());
     $this->smarty->assign('num_spirit_columns', count($s->question_headings()) + 1);
     $this->smarty->assign('num_comment_columns', count($s->question_headings()) + 2);
     $rows = array();
     foreach ($games as $game) {
         if (!$game->is_finalized()) {
             continue;
         }
         if ($game->home_id == $this->team->team_id) {
             $opponent_id = $game->away_id;
             $opponent_name = $game->away_name;
             $home_away = '(home)';
         } else {
             $opponent_id = $game->home_id;
             $opponent_name = $game->home_name;
             $home_away = '(away)';
         }
         $thisrow = array('game_id' => $game->game_id, 'day_id' => $game->day_id, 'given_by_id' => $opponent_id, 'given_by_name' => $opponent_name, 'has_entry' => 0);
         # Fetch spirit answers for games
         $entry = $game->get_spirit_entry($this->team->team_id);
         if (!$entry) {
             $rows[] = $thisrow;
             continue;
         }
         $thisrow['has_entry'] = 1;
         // can only see comments if you're a coordinator
         if ($lr_session->has_permission('league', 'view', $this->team->league_id, 'spirit')) {
             $thisrow['comments'] = $entry['comments'];
         }
         $thisrow = array_merge($thisrow, (array) $s->fetch_game_spirit_items_html($entry));
         $rows[] = $thisrow;
     }
     $this->smarty->assign('spirit_detail', $rows);
     return true;
 }
Exemplo n.º 3
0
 function get_league()
 {
     if (!$this->league) {
         $this->league = League::load(array('league_id' => $this->game->league_id));
         league_add_to_menu($this->league);
     }
     return $this->league;
 }
Exemplo n.º 4
0
 function __construct($id)
 {
     $this->league = League::load(array('league_id' => $id));
     if (!$this->league) {
         error_exit("That league does not exist");
     }
     league_add_to_menu($this->league);
 }
Exemplo n.º 5
0
 function __construct($what, $id)
 {
     $this->league = League::load(array('league_id' => $id));
     if (!$this->league) {
         error_exit("That league does not exist");
     }
     if ($what == 'schedule' || $what == 'combined') {
         $this->need_schedule = true;
     }
     if ($what == 'standings' || $what == 'combined') {
         $this->need_standings = true;
     }
 }
Exemplo n.º 6
0
 function confirm($targetleague, $target_team)
 {
     $output .= form_hidden('edit[step]', 'perform');
     $output .= form_hidden('edit[target]', $targetleague->league_id);
     if ($target_team) {
         $output .= form_hidden('edit[swaptarget]', $target_team->team_id);
     }
     $sourceleague = League::load(array('league_id' => $this->team->league_id));
     $output .= para("You are attempting to move the team <b>" . $this->team->name . "</b> to <b>{$targetleague->fullname}</b>");
     if ($target_team) {
         $output .= para("This team will be swapped with <b>{$target_team->name}</b>, which will be moved to <b>{$sourceleague->fullname}</b>.");
         $output .= para("Both teams' schedules will be adjusted so that each team faces any opponents the other had been scheduled for");
     }
     $output .= para("If this is correct, please click 'Submit' below.");
     $output .= form_submit("Submit");
     return form($output);
 }
Exemplo n.º 7
0
 function generateConfirm(&$edit, $datestamp)
 {
     $dataInvalid = $this->isDataInvalid($edit);
     if ($dataInvalid) {
         error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again");
     }
     $this->smarty->assign('start_date', $datestamp);
     $this->smarty->assign('edit', $edit);
     $leagues = array();
     foreach ($edit['availability'] as $league_id) {
         $league = League::load(array('league_id' => $league_id));
         $leagues[$league_id] = $league->fullname;
     }
     $this->smarty->assign('leagues', $leagues);
     return true;
 }