Exemple #1
0
 function perform(&$edit)
 {
     $this->field->set('num', $edit['num']);
     $this->field->set('status', $edit['status']);
     $this->field->set('rating', $edit['rating']);
     if (isset($edit['parent_fid'])) {
         $this->field->set('parent_fid', $edit['parent_fid']);
     }
     if ($edit['parent_fid'] == 0) {
         $this->field->set('parent_fid', '');
         $this->field->set('name', $edit['name']);
         $this->field->set('code', $edit['code']);
         $this->field->set('location_street', $edit['location_street']);
         $this->field->set('location_city', $edit['location_city']);
         $this->field->set('location_province', $edit['location_province']);
         $this->field->set('location_country', $edit['location_country']);
         $this->field->set('location_postalcode', $edit['location_postalcode']);
         $this->field->set('is_indoor', $edit['is_indoor']);
         $this->field->set('region', $edit['region']);
         $this->field->set('location_url', $edit['location_url']);
         $this->field->set('layout_url', $edit['layout_url']);
         $this->field->set('driving_directions', $edit['driving_directions']);
         $this->field->set('transit_directions', $edit['transit_directions']);
         $this->field->set('biking_directions', $edit['biking_directions']);
         $this->field->set('parking_details', $edit['parking_details']);
         $this->field->set('washrooms', $edit['washrooms']);
         $this->field->set('public_instructions', $edit['public_instructions']);
         $this->field->set('site_instructions', $edit['site_instructions']);
         $this->field->set('sponsor', $edit['sponsor']);
     }
     if (!$this->field->save()) {
         error_exit("Internal error: couldn't save changes");
     }
     return true;
 }
Exemple #2
0
 function process()
 {
     $this->template_name = 'pages/slot/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 Availability Report » {$formattedDay}";
     $sth = GameSlot::query(array('game_date' => sprintf('%d-%d-%d', $year, $month, $day), '_order' => 'g.game_start, field_code, field_num'));
     $num_open = 0;
     $slots = array();
     while ($g = $sth->fetch()) {
         // load game info, if game scheduled
         if ($g['game_id']) {
             $g['game'] = Game::load(array('game_id' => $g['game_id']));
         } else {
             $num_open++;
         }
         $slots[] = $g;
     }
     $this->smarty->assign('slots', $slots);
     $this->smarty->assign('num_fields', count($slots));
     $this->smarty->assign('num_open', $num_open);
     return true;
 }
 function save()
 {
     global $dbh;
     if (!count($this->_modified_fields)) {
         // No modifications, no need to save
         return true;
     }
     if (!$this->_in_database) {
         if (!$this->create()) {
             error_exit("Couldn't create registration");
         }
     }
     $fields = array();
     $fields_data = array();
     foreach ($this->_modified_fields as $key => $value) {
         $fields[] = "{$key} = ?";
         if (empty($this->{$key})) {
             $fields_data[] = null;
         } else {
             $fields_data[] = $this->{$key};
         }
     }
     if (count($fields_data) != count($fields)) {
         error_exit("Internal error: Incorrect number of fields set");
     }
     $sth = $dbh->prepare('UPDATE registrations SET ' . join(", ", $fields) . ' WHERE order_id = ?');
     $fields_data[] = $this->order_id;
     $sth->execute($fields_data);
     if (1 < $sth->rowCount()) {
         # Affecting zero rows is possible but usually unwanted
         error_exit("Internal error: Strange number of rows affected");
     }
     unset($this->_modified_fields);
     return true;
 }
 function perform($edit = array())
 {
     $fields = array();
     if (validate_nonblank($edit['username'])) {
         $fields['username'] = $edit['username'];
     }
     if (validate_nonblank($edit['email'])) {
         $fields['email'] = $edit['email'];
     }
     if (count($fields) < 1) {
         error_exit("You must supply at least one of username or email address");
     }
     /* Now, try and find the user */
     $user = Person::load($fields);
     /* Now, we either have one or zero users.  Regardless, we'll present
      * the user with the same output; that prevents them from using this
      * to guess valid usernames.
      */
     if ($user) {
         /* Generate a password */
         $pass = generate_password();
         $user->set_password($pass);
         if (!$user->save()) {
             error_exit("Error setting password");
         }
         /* And fire off an email */
         $rc = send_mail($user, false, false, _person_mail_text('password_reset_subject', array('%site' => variable_get('app_name', 'Leaguerunner'))), _person_mail_text('password_reset_body', array('%fullname' => "{$user->firstname} {$user->lastname}", '%username' => $user->username, '%password' => $pass, '%site' => variable_get('app_name', 'Leaguerunner'))));
         if ($rc == false) {
             error_exit("System was unable to send email to that user.  Please contact system administrator.");
         }
     }
 }
Exemple #5
0
 function process()
 {
     global $lr_session;
     $payments = array();
     $paypal = new PaypalHandler();
     $talkback_results = $paypal->talkback('pdt');
     if (!$talkback_results || $talkback_results['status'] == false) {
         return false;
     }
     // confirm that data from PayPal matches registrations
     $item_numbers = preg_grep_keys('/item_number[0-9]*/', $talkback_results['message']);
     foreach ($item_numbers as $key => $value) {
         // get current Item # from PayPal, which is the last character in $key
         $item = substr($key, -1);
         $status = $paypal->validatePayment($value, $talkback_results['message']['mc_gross_' . $item], $lr_session->user->user_id);
         if ($status['status'] == false) {
             error_exit($status['message']);
         } else {
             // PaymentRegistration object passed back in message on success
             array_push($payments, $status['message']);
         }
     }
     // output confirmation view
     $this->smarty->assign('payments', $payments);
     $this->smarty->assign('order_id_format', variable_get('order_id_format', '%d'));
     $this->title = 'Registration ' . $this->registration->formatted_order_id() . '- Payment Received';
     $this->template_name = 'pages/registration/paypal.tpl';
     return true;
 }
Exemple #6
0
 function save()
 {
     global $dbh;
     if (!count($this->_modified_fields)) {
         // No modifications, no need to save
         return true;
     }
     if (!$this->_in_database) {
         if (!$this->create()) {
             error_exit("Failed to create note");
         }
     }
     $fields = array();
     $fields_data = array();
     foreach ($this->_modified_fields as $key => $value) {
         $fields[] = "{$key} = ?";
         $fields_data[] = $this->{$key};
     }
     if (count($fields_data) != count($fields)) {
         error_exit("Internal error: Incorrect number of fields set");
     }
     $sth = $dbh->prepare('UPDATE note SET ' . join(", ", $fields) . ', edited = NOW() WHERE id = ?');
     $fields_data[] = $this->id;
     $sth->execute($fields_data);
     if (1 != $sth->rowCount()) {
         # Affecting zero rows is possible but usually unwanted
         error_exit("Internal error: Strange number of rows affected");
     }
     unset($this->_modified_fields);
     return true;
 }
Exemple #7
0
 function perform(&$edit)
 {
     $this->event->set('name', $edit['name']);
     $this->event->set('description', $edit['description']);
     $this->event->set('type', $edit['type']);
     $this->event->set('season_id', $edit['season_id']);
     $this->event->set('currency_code', $edit['currency_code']);
     $this->event->set('cost', $edit['cost']);
     $this->event->set('gst', $edit['gst']);
     $this->event->set('pst', $edit['pst']);
     $time = $edit['open_time'];
     if ($time == '24:00') {
         $time = '23:59:00';
     }
     $this->event->set('open', $edit['open_date'] . ' ' . $time);
     $time = $edit['close_time'];
     if ($time == '24:00') {
         $time = '23:59:00';
     }
     $this->event->set('close', $edit['close_date'] . ' ' . $time);
     $this->event->set('cap_male', $edit['cap_male']);
     $this->event->set('cap_female', $edit['cap_female']);
     $this->event->set('multiple', $edit['multiple']);
     $this->event->set('anonymous', $edit['anonymous']);
     if (!$this->event->save()) {
         error_exit("Internal error: couldn't save changes");
     }
     return true;
 }
Exemple #8
0
 function process()
 {
     global $lr_session, $dbh;
     $this->template_name = 'pages/team/list.tpl';
     $ops = array('view' => 'team/view');
     if ($lr_session->has_permission('team', 'delete')) {
         $ops['delete'] = 'team/delete';
     }
     $this->title = 'List Teams';
     $sth = $dbh->prepare("SELECT DISTINCT UPPER(SUBSTRING(t.name,1,1)) as letter\n\t\t\tFROM team t\n\t\t\tLEFT JOIN leagueteams lt ON t.team_id = lt.team_id\n\t\t\tORDER BY letter asc");
     $sth->execute();
     $letters = $sth->fetchAll(PDO::FETCH_COLUMN);
     $this->smarty->assign('current_letter', $this->letter);
     $this->smarty->assign('letters', $letters);
     $query = "SELECT t.name, t.team_id FROM team t WHERE t.name LIKE ? ORDER BY t.name";
     $sth = $dbh->prepare($query);
     $sth->execute(array("{$this->letter}%"));
     $sth->setFetchMode(PDO::FETCH_CLASS, 'Person', array(LOAD_OBJECT_ONLY));
     $teams = array();
     $hits = 0;
     while ($team = $sth->fetch()) {
         if (++$hits > 1000) {
             error_exit("Too many search results; query terminated");
         }
         $teams[] = $team;
     }
     $this->smarty->assign('teams', $teams);
     $this->smarty->assign('ops', $ops);
     return true;
 }
 function process()
 {
     global $dbh;
     $data = array('Order ID');
     foreach ($this->formbuilder->_questions as $question) {
         $data[] = $question->qkey;
     }
     if (empty($data)) {
         error_exit('No survey details available for download.');
     }
     header('Content-type: text/x-csv');
     header("Content-Disposition: attachment; filename=\"{$this->event->name}_survey.csv\"");
     $out = fopen('php://output', 'w');
     fputcsv($out, $data);
     $sth = $dbh->prepare('SELECT order_id FROM registrations r WHERE r.registration_id = ?  ORDER BY order_id');
     $sth->execute(array($this->event->registration_id));
     while ($row = $sth->fetch()) {
         $data = array(sprintf(variable_get('order_id_format', '%d'), $row['order_id']));
         // Add all of the answers
         $fsth = $dbh->prepare('SELECT akey FROM registration_answers WHERE order_id = ?  AND qkey = ?');
         foreach ($this->formbuilder->_questions as $question) {
             $fsth->execute(array($row['order_id'], $question->qkey));
             $foo = $fsth->fetchColumn();
             $data[] = preg_replace('/\\s\\s+/', ' ', $foo);
         }
         fputcsv($out, $data);
     }
     fclose($out);
     exit;
 }
Exemple #10
0
 function __construct($id)
 {
     $this->slot = GameSlot::load(array('slot_id' => $id));
     if (!$this->slot) {
         error_exit("That gameslot does not exist");
     }
 }
Exemple #11
0
 function perform($edit)
 {
     $this->league->set('name', $edit['name']);
     $this->league->set('status', $edit['status']);
     if (is_array($edit['day'])) {
         $edit['day'] = join(",", $edit['day']);
     }
     $this->league->set('day', $edit['day']);
     $this->league->set('season', $edit['season']);
     $this->league->set('roster_deadline', $edit['roster_deadline']);
     $this->league->set('min_roster_size', $edit['min_roster_size']);
     $this->league->set('tier', $edit['tier']);
     $this->league->set('ratio', $edit['ratio']);
     $this->league->set('current_round', $edit['current_round']);
     $this->league->set('schedule_type', $edit['schedule_type']);
     if ($edit['schedule_type'] == 'ratings_ladder' || $edit['schedule_type'] == 'ratings_wager_ladder') {
         $this->league->set('games_before_repeat', $edit['games_before_repeat']);
     }
     $this->league->set('display_sotg', $edit['display_sotg']);
     $this->league->set('coord_list', $edit['coord_list']);
     $this->league->set('capt_list', $edit['capt_list']);
     $this->league->set('excludeTeams', $edit['excludeTeams']);
     $this->league->set('finalize_after', $edit['finalize_after']);
     if (!$this->league->save()) {
         error_exit("Internal error: couldn't save changes");
     }
     return true;
 }
 function process()
 {
     $games = Game::load_many(array('league_id' => $this->league->league_id, '_order' => 'g.game_date,g.game_id'));
     if (!is_array($games)) {
         error_exit("There are no games scheduled for this league");
     }
     $s = new Spirit();
     $s->display_numeric_sotg = $this->league->display_numeric_sotg();
     // Start the output, let the browser know what type it is
     header('Content-type: text/x-csv');
     header("Content-Disposition: attachment; filename=\"spirit{$this->league_id}.csv\"");
     $out = fopen('php://output', 'w');
     $header = array_merge(array('Game #', 'Date', 'Giver Name', 'Giver ID', 'Given To', 'Given To ID', 'SOTG Total'), (array) $s->question_headings(), array('Comments'));
     fputcsv($out, $header);
     while (list(, $game) = each($games)) {
         $teams = array($game->home_team => $game->home_name, $game->away_team => $game->away_name);
         while (list($giver, $giver_name) = each($teams)) {
             $recipient = $game->get_opponent_id($giver);
             # Fetch spirit answers for games
             $entry = $game->get_spirit_entry($recipient);
             if (!$entry) {
                 $entry = array(comments => 'Team did not submit a spirit rating');
             }
             $thisrow = array($game->game_id, strftime('%a %b %d %Y', $game->timestamp), $giver_name, $giver, $teams[$recipient], $recipient, $entry['numeric_sotg'], $entry['timeliness'], $entry['rules_knowledge'], $entry['sportsmanship'], $entry['rating_overall'], $entry['score_entry_penalty'], $entry['comments']);
             fputcsv($out, $thisrow);
         }
     }
     fclose($out);
     // Returning would cause the Leaguerunner menus to be added
     exit;
 }
Exemple #13
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;
 }
Exemple #14
0
 function __construct($id)
 {
     $this->team = Team::load(array('team_id' => $id));
     if (!$this->team) {
         error_exit("That team does not exist");
     }
     team_add_to_menu($this->team);
 }
Exemple #15
0
 function __construct($id)
 {
     $this->game = Game::load(array('game_id' => $id));
     if (!$this->game) {
         error_exit("That game does not exist");
     }
     game_add_to_menu($this->get_league(), $this->game);
 }
 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);
 }
 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($id)
 {
     $this->person = Person::load(array('user_id' => $id));
     if (!$this->person) {
         error_exit("That user does not exist");
     }
     person_add_to_menu($this->person);
 }
Exemple #19
0
 function __construct($type)
 {
     if (!preg_match('/^[a-z]+$/', $type)) {
         error_exit('invalid type');
     }
     $this->title = 'Settings';
     $this->type = $type;
 }
 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);
 }
Exemple #21
0
 function __construct($id)
 {
     $this->note = Note::load(array('id' => $id));
     if (!$this->note) {
         error_exit("That note does not exist");
     }
     $this->note->load_creator();
     note_add_to_menu($this->note);
 }
 function __construct($id)
 {
     $this->registration = Registration::load(array('order_id' => $id));
     if (!$this->registration) {
         error_exit("That registration does not exist");
     }
     $this->event = Event::load(array('registration_id' => $this->registration->registration_id));
     registration_add_to_menu($this->registration);
 }
Exemple #23
0
 function perform(&$edit)
 {
     list($rc, $message) = $this->league->reschedule_games_for_day($edit['olddate'], $edit['newdate']);
     if ($rc) {
         local_redirect(url("schedule/view/" . $this->league->league_id));
     } else {
         error_exit("Failure rescheduling games: {$message}");
     }
 }
Exemple #24
0
 function perform($edit = array())
 {
     global $lr_session;
     $this->note->set('note', $edit['note']);
     if (!$this->note->save()) {
         error_exit("Internal error: couldn't save changes");
     }
     return true;
 }
Exemple #25
0
 function process()
 {
     $this->title = "Reports: {$this->field->fullname}";
     if (!$this->field) {
         error_exit("That field does not exist");
     }
     $this->template_name = 'pages/field/reports.tpl';
     $this->smarty->assign('reports', FieldReport::load_many(array('field_id' => $this->field->fid, '_order' => 'created DESC')));
     return true;
 }
Exemple #26
0
 function save($edit)
 {
     foreach ($this->save_vars as $var) {
         $this->field->set($var, $edit[$var]);
     }
     if (!$this->field->save()) {
         return error_exit("Internal error: couldn't save changes");
     }
     return true;
 }
Exemple #27
0
 function process()
 {
     $this->title = "{$this->league->fullname} &raquo; Captain Emails";
     $this->template_name = 'pages/league/captemail.tpl';
     $captains = $this->league->get_captains();
     if (!count($captains)) {
         error_exit("That league contains no teams.");
     }
     $this->smarty->assign('list', player_rfc2822_address_list($captains, true));
     return true;
 }
Exemple #28
0
 function perform($edit)
 {
     $this->season->set('display_name', $edit['display_name']);
     $this->season->set('year', $edit['year']);
     $this->season->set('season', $edit['season']);
     $this->season->set('archived', $edit['archived']);
     if (!$this->season->save()) {
         error_exit("Internal error: couldn't save changes");
     }
     return true;
 }
Exemple #29
0
 function __construct($type)
 {
     if (!preg_match('/^[a-z]+$/', $type)) {
         error_exit('invalid type');
     }
     $function = $type . '_settings';
     if (!function_exists($function)) {
         error_exit('invalid type');
     }
     $this->type = $type;
 }
Exemple #30
0
 function process()
 {
     global $lr_session;
     $this->title = "{$this->league->fullname} &raquo; Standings";
     $this->template_name = 'pages/league/standings.tpl';
     if ($this->league->schedule_type == 'none') {
         error_exit("This league does not have a schedule or standings.");
     }
     $s = new Spirit();
     $round = $_GET['round'];
     if (!isset($round)) {
         $round = $this->league->current_round;
     }
     // check to see if this league is on round 2 or higher...
     // if so, set the $current_round so that the standings table is split up
     if ($round > 1) {
         $current_round = $round;
     }
     // TODO: calculate_standings should set the ->round_XXX values on each team object
     list($order, $season, $round) = $this->league->calculate_standings(array('round' => $current_round));
     $teams = array();
     $seed = 1;
     while (list(, $tid) = each($order)) {
         $team = $season[$tid];
         $team->seed = $seed++;
         // Don't need the current round for a ladder schedule.
         if ($this->league->schedule_type == "roundrobin") {
             if ($current_round) {
                 $team->round_win = $round[$tid]->win;
                 $team->round_loss = $round[$tid]->loss;
                 $team->round_tie = $round[$tid]->tie;
                 $team->round_defaults_against = $round[$tid]->defaults_against;
                 $team->round_points_for = $round[$tid]->points_for;
                 $team->round_points_against = $round[$tid]->points_against;
             }
         }
         // TODO: should be a helper on the Team object
         if (count($team->streak) > 1) {
             $team->display_streak = count($team->streak) . $team->streak[0];
         } else {
             $team->display_streak = '-';
         }
         $team->sotg_average = $s->average_sotg($team->spirit, false);
         $team->sotg_image = $s->full_spirit_symbol_html($team->sotg_average);
         $teams[] = $team;
     }
     $this->smarty->assign('league', $this->league);
     $this->smarty->assign('teams', $teams);
     $this->smarty->assign('highlight_team', $this->teamid);
     $this->smarty->assign('display_round', $current_round > 1);
     return true;
 }