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; }
function process() { global $CONFIG; $this->template_name = 'pages/team/ical.tpl'; $this->smarty->assign('team', $this->team); $this->smarty->assign('short_league_name', variable_get('app_org_short_name', 'League')); # Our timezone is specified as US/Eastern, but ical wants US-Eastern. bleh. $timezone = preg_replace("!/!", "-", $CONFIG['localization']['local_tz']); $this->smarty->assign('timezone', $timezone); /* * Grab schedule info */ $games = Game::load_many(array('either_team' => $this->team->team_id, 'published' => 1, '_order' => 'g.game_date DESC,g.game_start,g.game_id')); // We'll be outputting an ical header('Content-type: text/calendar; charset=UTF-8'); // Prevent caching header("Cache-Control: no-cache, must-revalidate"); // get domain URL for signing games $arr = explode('@', variable_get('app_admin_email', "@{$short_league_name}")); $this->smarty->assign('domain_url', $arr[1]); // date stamp this file // MUST be in UTC $this->smarty->assign('now', gmstrftime('%Y%m%dT%H%M%SZ')); while (list(, $game) = each($games)) { $opponent_id = $game->home_id == $this->team->team_id ? $game->away_id : $game->home_id; $game->opponent = Team::load(array('team_id' => $opponent_id)); $game->field = Field::load(array('fid' => $game->fid)); } $this->smarty->assign('games', $games); }
function __construct($id) { $this->field = Field::load(array('fid' => $id)); if (!$this->field) { error_exit("That field does not exist"); } field_add_to_menu($this->field); }
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; }
function __construct() { global $dbh; $sth = $dbh->prepare('SELECT league_id from league_gameslot_availability WHERE slot_id = ?'); $sth->execute(array($this->slot_id)); $this->leagues = array(); while ($league = $sth->fetch(PDO::FETCH_OBJ)) { $league->league_status = 'loaded'; $this->leagues[$league->league_id] = $league; } /* set derived attributes */ if ($this->fid) { $this->field = Field::load(array('fid' => $this->fid)); } return true; }
function generateConfirm($edit) { $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"); } $output = form_hidden("edit[step]", "perform"); $ratings = field_rating_values(); if ($edit['parent_fid']) { $parent = Field::load(array('fid' => $edit['parent_fid'])); $rows = array(); $rows[] = array("Name:", $parent->name); $rows[] = array("Status:", form_hidden('edit[status]', $edit['status']) . check_form($edit['status'])); $rows[] = array("Number:", form_hidden('edit[num]', $edit['num']) . check_form($edit['num'])); $rows[] = array("Field Rating:", form_hidden('edit[rating]', $edit['rating']) . $ratings[$edit['rating']]); $rows[] = array("Parent Field:", form_hidden('edit[parent_fid]', $edit['parent_fid']) . $parent->fullname); } else { $rows = array(); $rows[] = array("Name:", form_hidden('edit[name]', $edit['name']) . check_form($edit['name'])); $rows[] = array("Status:", form_hidden('edit[status]', $edit['status']) . check_form($edit['status'])); $rows[] = array("Number:", form_hidden('edit[num]', $edit['num']) . check_form($edit['num'])); $rows[] = array("Field Rating:", form_hidden('edit[rating]', $edit['rating']) . $ratings[$edit['rating']]); $rows[] = array("Is indoor:", form_hidden('edit[is_indoor]', $edit['is_indoor']) . ($edit['is_indoor'] ? 'Yes' : 'No')); $rows[] = array("Code:", form_hidden('edit[code]', $edit['code']) . check_form($edit['code'])); $rows[] = array("Region:", form_hidden('edit[region]', $edit['region']) . check_form($edit['region'])); $rows[] = array("Street:", form_hidden('edit[location_street]', $edit['location_street']) . check_form($edit['location_street'])); $rows[] = array("City:", form_hidden('edit[location_city]', $edit['location_city']) . check_form($edit['location_city'])); $rows[] = array("Province:", form_hidden('edit[location_province]', $edit['location_province']) . check_form($edit['location_province'])); $rows[] = array("Location Map:", form_hidden('edit[location_url]', $edit['location_url']) . check_form($edit['location_url'])); $rows[] = array("Layout Map:", form_hidden('edit[layout_url]', $edit['layout_url']) . check_form($edit['layout_url'])); $rows[] = array("Driving Directions:", form_hidden('edit[driving_directions]', $edit['driving_directions']) . check_form($edit['driving_directions'])); $rows[] = array("Parking Details:", form_hidden('edit[parking_details]', $edit['parking_details']) . check_form($edit['parking_details'])); $rows[] = array("Transit Directions:", form_hidden('edit[transit_directions]', $edit['transit_directions']) . check_form($edit['transit_directions'])); $rows[] = array("Biking Directions:", form_hidden('edit[biking_directions]', $edit['biking_directions']) . check_form($edit['biking_directions'])); $rows[] = array("Public Washrooms:", form_hidden('edit[washrooms]', $edit['washrooms']) . check_form($edit['washrooms'])); $rows[] = array("Special Instructions:", form_hidden('edit[public_instructions]', $edit['public_instructions']) . check_form($edit['public_instructions'])); $rows[] = array("Private Instructions:", form_hidden('edit[site_instructions]', $edit['site_instructions']) . check_form($edit['site_instructions'])); $rows[] = array("Sponsorship:", form_hidden('edit[sponsor]', $edit['sponsor']) . check_form($edit['sponsor'])); } $rows[] = array(form_submit('Submit'), ""); $output .= "<div class='pairtable'>" . table(null, $rows) . "</div>"; return form($output); }
function process() { $this->template_name = 'pages/fieldreport/day.tpl'; list($year, $month, $day) = preg_split("/[\\/-]/", $_GET['date']); $today = getdate(); $yyyy = is_numeric($year) ? $year : $today['year']; $mm = is_numeric($month) ? $month : $today['mon']; $dd = is_numeric($day) ? $day : $today['mday']; if (!validate_date_input($yyyy, $mm, $dd)) { error_exit('That date is not valid'); } $this->smarty->assign('date', sprintf("%4d/%02d/%02d", $yyyy, $mm, $dd)); $formattedDay = strftime('%A %B %d %Y', mktime(6, 0, 0, $mm, $dd, $yyyy)); $this->title = "Field Reports » {$formattedDay}"; $sth = FieldReport::query(array('date_played' => sprintf('%d-%d-%d', $yyyy, $mm, $dd), '_order' => 'field_id ASC')); $reports = array(); while ($r = $sth->fetchObject('FieldReport')) { $r->field = Field::load(array('fid' => $r->field_id)); $reports[] = $r; } $this->smarty->assign('reports', $reports); return true; }
private function __form(Section $existing = null) { // Status message: $callback = Administration::instance()->getPageCallback(); if (isset($callback['flag']) && !is_null($callback['flag'])) { switch ($callback['flag']) { case 'saved': $this->alerts()->append(__('Section updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/sections/new/', ADMIN_URL . '/blueprints/sections/')), AlertStack::SUCCESS); break; case 'created': $this->alerts()->append(__('Section created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/sections/new/', ADMIN_URL . '/blueprints/sections/')), AlertStack::SUCCESS); break; } } if (!$this->alerts()->valid() and $existing instanceof Section) { $this->appendSyncAlert(); } $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::LARGE); $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Sections')))); $this->appendSubheading($existing instanceof Section ? $existing->name : __('New Section')); if ($existing instanceof Section) { $this->appendViewOptions(); } // Essentials: $fieldset = $this->createElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild($this->createElement('h3', __('Essentials'))); $label = Widget::Label('Name'); $label->appendChild(Widget::Input('essentials[name]', $this->section->name)); $fieldset->appendChild(isset($this->errors->name) ? Widget::wrapFormElementWithError($label, $this->errors->name) : $label); $label = Widget::Label(__('Navigation Group')); $label->appendChild($this->createElement('em', __('Created if does not exist'))); $label->appendChild(Widget::Input('essentials[navigation-group]', $this->section->{"navigation-group"})); $fieldset->appendChild(isset($this->errors->{'navigation-group'}) ? Widget::wrapFormElementWithError($label, $this->errors->{'navigation-group'}) : $label); $navigation_groups = Section::fetchUsedNavigationGroups(); if (is_array($navigation_groups) && !empty($navigation_groups)) { $ul = $this->createElement('ul', NULL, array('class' => 'tags singular')); foreach ($navigation_groups as $g) { $ul->appendChild($this->createElement('li', $g)); } $fieldset->appendChild($ul); } $input = Widget::Input('essentials[hidden-from-publish-menu]', 'yes', 'checkbox', $this->section->{'hidden-from-publish-menu'} == 'yes' ? array('checked' => 'checked') : array()); $label = Widget::Label(__('Hide this section from the Publish menu')); $label->prependChild($input); $fieldset->appendChild($label); $left->appendChild($fieldset); // Fields $fieldset = $this->createElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild($this->createElement('h3', __('Fields'))); $div = $this->createElement('div'); $h3 = $this->createElement('h3', __('Fields')); $h3->setAttribute('class', 'label'); $div->appendChild($h3); $duplicator = new Duplicator(__('Add Field')); $duplicator->setAttribute('id', 'section-duplicator'); $fields = $this->section->fields; $types = array(); foreach (new FieldIterator() as $pathname) { $type = preg_replace(array('/^field\\./', '/\\.php$/'), NULL, basename($pathname)); $types[$type] = Field::load($pathname); } // To Do: Sort this list based on how many times a field has been used across the system uasort($types, create_function('$a, $b', 'return strnatcasecmp($a->name(), $b->name());')); if (is_array($types)) { foreach ($types as $type => $field) { $defaults = array(); $field->findDefaultSettings($defaults); $field->section = $this->section->handle; foreach ($defaults as $key => $value) { $field->{$key} = $value; } $item = $duplicator->createTemplate($field->name()); $field->displaySettingsPanel($item, new MessageStack()); } } if (is_array($fields)) { foreach ($fields as $position => $field) { $field->sortorder = $position; if ($this->errors->{"field::{$position}"}) { $messages = $this->errors->{"field::{$position}"}; } else { $messages = new MessageStack(); } $item = $duplicator->createInstance($field->name, $field->name()); $field->displaySettingsPanel($item, $messages); } } $duplicator->appendTo($fieldset); $right->appendChild($fieldset); $layout->appendTo($this->Form); $div = $this->createElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : 'Create Section', array('accesskey' => 's'))); if ($this->_context[0] == 'edit') { $div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this section')))); } $this->Form->appendChild($div); }
function generateForm() { global $lr_session; # Alias, to avoid typing. Bleh. $game =& $this->game; $league =& $this->league; $game->load_score_entries(); $output = form_hidden('edit[step]', 'confirm'); $teams = $league->teams_as_array(); /* Now, since teams may not be in league any longer, we need to force * them to appear in the pulldown */ $teams[$game->home_id] = $game->home_name; $teams[$game->away_id] = $game->away_name; $output .= form_item("League/Division", l($league->fullname, "league/view/{$league->league_id}")); $output .= form_item("Home Team", l($game->home_name, "team/view/{$game->home_id}")); $output .= form_item("Away Team", l($game->away_name, "team/view/{$game->away_id}")); $output .= form_item("Date and Time", "{$game->game_date}, {$game->game_start} until " . $game->display_game_end() . $note); $field = Field::load(array('fid' => $game->fid)); $output .= form_item("Location", l("{$field->fullname} ({$game->field_code})", "field/view/{$game->fid}"), $note); if ($lr_session->is_coordinator_of($game->league_id)) { $output .= form_item("Site Ranking (home team)", $game->get_site_ranking($game->home_id)); $output .= form_item("Site Ranking (away team)", $game->get_site_ranking($game->away_id)); } $output .= form_item("Game Status", $game->status); if (isset($game->round)) { $output .= form_item("Round", $game->round); } $spirit_group = ''; $score_group = ''; /* * Now, for scores and spirit info. Possibilities: * - game has been finalized: * - everyone can see scores * - coordinator can edit scores/spirit * - game has not been finalized * - players only see "not yet submitted" * - captains can see submitted scores * - coordinator can see everything, edit final scores/spirit */ if ($game->approved_by) { // Game has been finalized if (!$this->can_edit) { // If we're not editing, display score. If we are, // it will show up below. switch ($game->status) { case 'home_default': $home_status = " (defaulted)"; break; case 'away_default': $away_status = " (defaulted)"; break; case 'forfeit': $home_status = " (forfeit)"; $away_status = " (forfeit)"; break; } $score_group .= form_item("Home ({$game->home_name} [rated: {$game->rating_home}]) Score", "{$game->home_score} {$home_status}"); $score_group .= form_item("Away ({$game->away_name} [rated: {$game->rating_away}]) Score", "{$game->away_score} {$away_status}"); } if ($game->home_score == $game->away_score && $game->rating_points == 0) { $score_group .= form_item("Rating Points", "No points were transferred between teams"); } else { if ($game->home_score >= $game->away_score) { $winner = l($game->home_name, "team/view/{$game->home_id}"); $loser = l($game->away_name, "team/view/{$game->away_id}"); } elseif ($game->home_score < $game->away_score) { $winner = l($game->away_name, "team/view/{$game->away_id}"); $loser = l($game->home_name, "team/view/{$game->home_id}"); } $score_group .= form_item("Rating Points", $game->rating_points, $winner . " gain " . $game->rating_points . " points and " . $loser . " lose " . $game->rating_points . " points"); } switch ($game->approved_by) { case APPROVAL_AUTOMATIC: $approver = 'automatic approval'; break; case APPROVAL_AUTOMATIC_HOME: $approver = 'automatic approval using home submission'; break; case APPROVAL_AUTOMATIC_AWAY: $approver = 'automatic approval using away submission'; break; case APPROVAL_AUTOMATIC_FORFEIT: $approver = 'game automatically forfeited due to lack of score submission'; break; default: $approver = Person::load(array('user_id' => $game->approved_by)); $approver = l($approver->fullname, "person/view/{$approver->user_id}"); } $score_group .= form_item("Score Approved By", $approver); } else { /* * Otherwise, scores are still pending. */ if ($lr_session->is_coordinator_of($game->league_id)) { $list = player_rfc2822_address_list($game->get_captains(), true); $output .= para(l('Click here to send an email', "mailto:{$list}") . ' to all captains.'); } $stats_group = ''; /* Use our ratings to try and predict the game outcome */ $homePct = $game->home_expected_win(); $awayPct = $game->away_expected_win(); $stats_group .= form_item("Chance to win", table(null, array(array($game->home_name, sprintf("%0.1f%%", 100 * $homePct)), array($game->away_name, sprintf("%0.1f%%", 100 * $awayPct)), array("View the " . l('Ratings Table', "game/ratings/{$game->game_id}") . " for this game.")))); $output .= form_group("Statistics", $stats_group); $score_group .= form_item('', "Score not yet finalized"); if ($lr_session->has_permission('game', 'view', $game, 'submission')) { $score_group .= form_item("Score as entered", $this->score_entry_display()); } } // Now, we always want to display this edit code if we have // permission to edit. if ($this->can_edit) { $score_group .= form_select('Game Status', 'edit[status]', $game->status, getOptionsFromEnum('schedule', 'status'), "To mark a game as defaulted, select the appropriate option here. Appropriate scores will automatically be entered."); $score_group .= form_textfield("Home ({$game->home_name} [rated: {$game->rating_home}]) score", 'edit[home_score]', $game->home_score, 2, 2); $score_group .= form_textfield("Away ({$game->away_name} [rated: {$game->rating_away}]) score", 'edit[away_score]', $game->away_score, 2, 2); } $output .= form_group("Scoring", $score_group); if ($lr_session->has_permission('game', 'view', $game, 'spirit')) { $ary = $game->get_spirit_entry($game->home_id); $s = new Spirit(); $formbuilder = $s->as_formbuilder(); if ($ary) { $formbuilder->bulk_set_answers($ary); // TODO: when not editable, display viewable tabular format with symbols $home_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'home') : $formbuilder->render_viewable(true, 'home'); } else { $formbuilder->bulk_set_answers($s->default_spirit_answers()); $home_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'home') : 'Not entered'; } $formbuilder->clear_answers(); $ary = $game->get_spirit_entry($game->away_id); if ($ary) { $formbuilder->bulk_set_answers($ary); $away_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'away') : $formbuilder->render_viewable(true, 'away'); } else { $formbuilder->bulk_set_answers($s->default_spirit_answers()); $away_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'away') : 'Not entered'; } $output .= form_group("Spirit assigned TO home ({$game->home_name})", $home_spirit_group); $output .= form_group("Spirit assigned TO away ({$game->away_name})", $away_spirit_group); } if ($lr_session->has_permission('field', 'view reports')) { $sth = FieldReport::query(array('game_id' => $this->game->game_id)); $header = array("Date Reported", "Reported By", "Report"); while ($r = $sth->fetchObject('FieldReport')) { $rows[] = array($r->created, l($r->reporting_user_fullname, url("person/view/" . $r->reporting_user_id)), $r->report_text); } $output .= form_group("This game's field reports for " . $field->fullname, "<div class='listtable'>" . table($header, $rows) . "</div>\n"); } if ($this->can_edit) { $output .= para(form_submit("submit") . form_reset("reset")); } return $script . form($output, 'post', null, 'id="score_form"'); }