function process() { $edit =& $_POST['edit']; $this->template_name = 'pages/league/edit.tpl'; $this->smarty->assign('status', getOptionsFromEnum('league', 'status')); $this->smarty->assign('seasons', getOptionsFromQuery("SELECT id AS theKey, display_name AS theValue FROM season ORDER BY year, id")); $this->smarty->assign('days', getOptionsFromEnum('league', 'day')); $this->smarty->assign('ratios', getOptionsFromEnum('league', 'ratio')); $this->smarty->assign('schedule_types', getOptionsFromEnum('league', 'schedule_type')); $this->smarty->assign('display_sotg', getOptionsFromEnum('league', 'display_sotg')); $this->smarty->assign('excludeTeams', getOptionsFromEnum('league', 'excludeTeams')); /* TODO: 10 is a magic number. Make it a config variable */ $this->smarty->assign('tiers', getOptionsFromRange(0, 10)); /* TODO: 5 is a magic number. Make it a config variable */ $this->smarty->assign('rounds', getOptionsFromRange(0, 5)); $this->smarty->assign('games_before_repeat', getOptionsFromRange(0, 9)); if ($edit['step'] == 'perform') { $errors = $this->check_input_errors($edit); if (count($errors) > 0) { $this->smarty->assign('edit', $edit); $this->smarty->assign('formErrors', $errors); return true; } $this->perform($edit); local_redirect(url("league/view/" . $this->league->league_id)); } else { /* Deal with multiple days and start times */ if (strpos($league->day, ",")) { $league->day = explode(',', $league->day); } $this->smarty->assign('edit', (array) $this->league); } return true; }
function generateForm(&$edit) { global $lr_session, $CONFIG; $this->smarty->assign('privacy_url', variable_get('privacy_policy', '')); $this->smarty->assign('app_org_short_name', variable_get('app_org_short_name', 'the league')); $this->smarty->assign('province_names', getProvinceNames()); $this->smarty->assign('state_names', getStateNames()); $this->smarty->assign('country_names', getCountryNames()); $player_classes = array('player' => 'Player', 'visitor' => 'Non-player account'); if ($lr_session->has_permission('person', 'edit', $this->person->id, 'class')) { $player_classes['administrator'] = 'Leaguerunner administrator'; $player_classes['volunteer'] = 'Volunteer'; } # Volunteers can unset themselves as volunteer if they wish. if ($this->person->class == 'volunteer') { $player_classes['volunteer'] = 'Volunteer'; } $this->smarty->assign('player_classes', $player_classes); $this->smarty->assign('player_statuses', getOptionsFromEnum('person', 'status')); $this->smarty->assign('skill_levels', getOptionsFromRange(1, 10)); $this->smarty->assign('start_years', getOptionsFromRange(1986, strftime('%Y', time()), 'reverse')); $this->smarty->assign('shirt_sizes', getShirtSizes()); $this->smarty->assign('dog_questions', variable_get('dog_questions', 1)); return true; }
function process() { $edit =& $_POST['edit']; $this->template_name = 'pages/season/edit.tpl'; $this->smarty->assign('yes_no', array('No', 'Yes')); $this->smarty->assign('seasons', getOptionsFromEnum('season', 'season')); if ($edit['step'] == 'perform') { $errors = $this->check_input_errors($edit); if (count($errors) > 0) { $this->smarty->assign('edit', $edit); $this->smarty->assign('formErrors', $errors); return true; } $this->perform($edit); local_redirect(url("season/view/" . $this->season->id)); } else { /* Deal with multiple days and start times */ if (strpos($season->day, ",")) { $season->day = explode(',', $season->day); } $this->season->archived = $this->season->archived ? 1 : 0; $this->smarty->assign('edit', (array) $this->season); } return true; }
function generateForm() { $output = form_hidden('edit[step]', 'confirm'); $player = $this->registration->user(); if (!$player) { return false; } $noneditable = array(); $noneditable[] = array('Name', l($player->fullname, url("person/view/{$player->id}"))); $noneditable[] = array('Member ID', $player->member_id); $noneditable[] = array('Event', l($this->event->name, url("event/view/{$this->event->registration_id}"))); $noneditable[] = array('Registered Price', $this->registration->total_amount); $form = '<div class="pairtable">' . table(NULL, $noneditable) . '</div>'; $pay_opts = getOptionsFromEnum('registrations', 'payment'); array_shift($pay_opts); $form .= form_select('Registration Status', 'edit[payment]', $this->registration->payment, $pay_opts); $form .= form_textarea('Notes', 'edit[notes]', $this->registration->notes, 45, 5); $output .= form_group('Registration details', $form); if ($this->formbuilder) { $this->formbuilder->bulk_set_answers_sql('SELECT qkey, akey FROM registration_answers WHERE order_id = ?', array($this->registration->order_id)); if (count($this->formbuilder->_answers) > 0) { $output .= form_group('Registration answers', $this->formbuilder->render_editable(true)); } else { $output .= form_group('Registration answers', $this->formbuilder->render_editable(false)); } } $output .= form_submit('Submit') . form_reset('Reset'); return form($output); }
function process() { $this->title = 'Registration ' . $this->registration->formatted_order_id(); $this->template_name = 'pages/registration/view.tpl'; $this->smarty->assign('reg', $this->registration); $this->smarty->assign('event', $this->event); // TODO: should be get_user() for consistency. $this->smarty->assign('registrant', $this->registration->user()); $this->form_load(); if (!$this->event->anonymous && $this->formbuilder) { $this->formbuilder->bulk_set_answers_sql('SELECT qkey, akey FROM registration_answers WHERE order_id = ?', array($this->registration->order_id)); $this->smarty->assign('formbuilder_render_viewable', $this->formbuilder->render_viewable()); } $pay_opts = getOptionsFromEnum('registration_payments', 'payment_type'); array_shift($pay_opts); $this->smarty->assign('payment_types', $pay_opts); $this->smarty->assign('payment_details', $this->registration->get_payments()); }
function generateForm(&$edit) { $this->smarty->assign('field_statuses', array('open' => 'open', 'closed' => 'closed')); $this->smarty->assign('ratings', field_rating_values()); // TODO: Should become Field::get_eligible_parents() $sth = Field::query(array('_extra' => 'ISNULL(parent_fid)', '_order' => 'f.name,f.num')); $parents = array(); $parents[0] = "---"; while ($p = $sth->fetch(PDO::FETCH_OBJ)) { $parents[$p->fid] = $p->fullname; } $this->smarty->assign('parents', $parents); $this->smarty->assign('regions', getOptionsFromEnum('field', 'region')); $this->smarty->assign('noyes', array(0 => 'No', 1 => 'Yes')); $this->smarty->assign('province_names', getProvinceNames()); $this->smarty->assign('state_names', getStateNames()); $this->smarty->assign('country_names', getCountryNames()); return true; }
function process() { $edit =& $_POST['edit']; $this->template_name = 'pages/team/edit.tpl'; $this->smarty->assign('status', getOptionsFromEnum('team', 'status')); if ($edit['step'] == 'perform') { $errors = $this->check_input_errors($edit); if (count($errors) > 0) { $this->smarty->assign('edit', $edit); $this->smarty->assign('formErrors', $errors); return true; } $this->perform($edit); local_redirect(url("team/view/" . $this->team->team_id)); } else { $this->smarty->assign('edit', (array) $this->team); } return true; }
function generateForm($data = array()) { $output = form_hidden("edit[step]", "confirm"); $output .= form_textfield("Field Identification", 'edit[num]', $data['num'], 15, 15, "Location of this field at the given site; cannot be 0"); $output .= form_select("Field Status", 'edit[status]', $data['status'], array('open' => 'open', 'closed' => 'closed')); $output .= form_select("Field Rating", 'edit[rating]', $data['rating'], field_rating_values(), "Rate this field on the scale provided"); // TODO: Should become Field::get_eligible_parents() $sth = Field::query(array('_extra' => 'ISNULL(parent_fid)', '_order' => 'f.name,f.num')); $parents = array(); $parents[0] = "---"; while ($p = $sth->fetch(PDO::FETCH_OBJ)) { $parents[$p->fid] = $p->fullname; } $output .= form_select("Parent Field", 'edit[parent_fid]', $data['parent_fid'], $parents, "Inherit location and name from other field"); if (!$data['parent_fid']) { $output .= form_textfield("Field Name", 'edit[name]', $data['name'], 35, 255, "Name of field (do not append number)"); $output .= form_textfield("Field Code", 'edit[code]', $data['code'], 3, 3, "Three-letter abbreviation for field site"); $output .= form_select("Region", 'edit[region]', $data['region'], getOptionsFromEnum('field', 'region'), "Area of city this field is located in"); $output .= form_select("Is indoor", 'edit[is_indoor]', $data['is_indoor'], array(0 => 'No', 1 => 'Yes'), "Is this an indoor field"); $output .= form_textfield('Street and Number', 'edit[location_street]', $data['location_street'], 25, 100); $output .= form_textfield('City', 'edit[location_city]', $data['location_city'], 25, 100, 'Name of city'); $output .= form_select('Province', 'edit[location_province]', $data['location_province'], getProvinceNames(), 'Select a province from the list'); $output .= form_textfield("Location Map", 'edit[location_url]', $data['location_url'], 50, 255, "URL for image that shows how to reach the field"); $output .= form_textfield("Layout Map", 'edit[layout_url]', $data['layout_url'], 50, 255, "URL for image that shows how to set up fields at the site"); $output .= form_textarea("Driving Directions", 'edit[driving_directions]', $data['driving_directions'], 60, 5, ""); $output .= form_textarea("Parking Details", 'edit[parking_details]', $data['parking_details'], 60, 5, ""); $output .= form_textarea("Transit Directions", 'edit[transit_directions]', $data['transit_directions'], 60, 5, ""); $output .= form_textarea("Biking Directions", 'edit[biking_directions]', $data['biking_directions'], 60, 5, ""); $output .= form_textarea("Public Washrooms", 'edit[washrooms]', $data['washrooms'], 60, 5, ""); $output .= form_textarea("Special Instructions", 'edit[public_instructions]', $data['public_instructions'], 60, 5, "Specific instructions for this site that don't fit any other category."); $output .= form_textarea("Private Instructions", 'edit[site_instructions]', $data['site_instructions'], 60, 5, "Instructions for this site that should be shown only to logged-in members."); $output .= form_textarea("Sponsorship", 'edit[sponsor]', $data['sponsor'], 60, 5, ""); } $output .= form_submit('Submit') . form_reset('Reset'); return form($output); }
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"'); }