function process() { global $dbh; $edit =& $_POST['edit']; $this->template_name = 'pages/slot/availability.tpl'; $this->title = "{$this->slot->field->fullname} » Gameslot {$this->slot->slot_id} Availability"; if ($edit['step'] == 'perform') { foreach ($this->slot->leagues as $league) { if (!count($edit['availability']) || !in_array($league->league_id, $edit['availability'])) { $this->slot->remove_league($league); } } if (count($edit['availability']) > 0) { foreach ($edit['availability'] as $league) { $this->slot->add_league($league); } } if (!$this->slot->save()) { error_exit("Internal error: couldn't save gameslot"); } $this->smarty->assign('message', 'Changes saved'); } $this->smarty->assign('slot', $this->slot); $weekday = strftime("%A", $this->slot->date_timestamp); $sth = League::query(array('_day' => $weekday, 'status' => 'open', '_order' => 'l.league_id')); $leagues = array(); while ($league = $sth->fetchObject('League', array(LOAD_OBJECT_ONLY))) { if ($league->tier) { $league->fullname = sprintf("{$league->name} Tier %02d", $league->tier); } else { $league->fullname = $league->name; } $leagues[$league->league_id] = "({$league->season_name}) {$league->fullname}"; } $this->smarty->assign('leagues', $leagues); $current_selections = array(); foreach ($this->slot->leagues as $league) { $current_selections[] = $league->league_id; } $this->smarty->assign('current_leagues', $current_selections); return true; }
function generateForm($datestamp) { $this->smarty->assign('field', $this->field); $this->smarty->assign('start_date', $datestamp); // TODO: replace getOptionsFromTimeRange with smarty plugin // TODO: implement for each field a usual_start_time to use as the start_time value $this->smarty->assign('start_time', '18:30'); $this->smarty->assign('end_time', '---'); $this->smarty->assign('start_end_times', getOptionsFromTimeRange(00, 2400, 5)); $weekday = strftime("%A", $datestamp); $sth = League::query(array('_day' => $weekday, 'status' => 'open', '_order' => 'l.league_id')); $leagues = array(); while ($league = $sth->fetchObject('League', array(LOAD_OBJECT_ONLY))) { $leagues[$league->league_id] = "({$league->season_name}) {$league->fullname}"; } $this->smarty->assign('leagues', $leagues); // TODO: perhaps have a repeat_until date instead? $this->smarty->assign('repeat_options', getOptionsFromRange(1, 24)); return true; }
function generateForm($datestamp) { $this->smarty->assign('field', $this->field); $this->smarty->assign('start_date', $datestamp); $this->smarty->assign('start_time', '18:30'); $this->smarty->assign('end_time', '---'); $this->smarty->assign('start_end_times', getOptionsFromTimeRange(00, 2400, 5)); $weekday = strftime("%A", $datestamp); $leagues = array(); $sth = League::query(array('_day' => $weekday, 'status' => 'open')); $leagues = array(); while ($league = $sth->fetchObject('League', array(LOAD_OBJECT_ONLY))) { $leagues[$league->league_id] = "{$league->season_name} - {$league->fullname}"; } $this->smarty->assign('leagues', $leagues); $this->smarty->assign('repeat_options', getOptionsFromRange(1, 24)); return true; }
function __construct($load_mode = LOAD_RELATED_DATA) { global $dbh; /* set any defaults for unset values */ if (!$this->height) { $this->height = 0; } if (!$this->user_id) { return; } /* set derived attributes */ $this->fullname = "{$this->firstname} {$this->lastname}"; if ($this->user_id == 'new' || $load_mode == LOAD_OBJECT_ONLY) { return; } /* Now fetch team info */ $sth = $dbh->prepare("SELECT\n\t\t\t\tr.status AS position,\n\t\t\t\tr.team_id,\n\t\t\t\tt.name,\n\t\t\t\tl.league_id,\n\t\t\t\tIF(l.tier,CONCAT_WS(' ',l.name,'Tier',l.tier),l.name) AS league_name,\n\t\t\t\tl.season,\n\t\t\t\tl.day,\n\t\t\t\tl.status AS league_status\n\t\t\tFROM\n\t\t\t\tteamroster r\n\t\t\t\tINNER JOIN team t ON (r.team_id = t.team_id)\n\t\t\t\tINNER JOIN leagueteams lt ON (lt.team_id = t.team_id)\n\t\t\t\tINNER JOIN league l ON (lt.league_id = l.league_id)\n\t\t\tWHERE\n\t\t\t\tr.player_id = ?\n\t\t\tORDER BY\n\t\t\t\tl.season DESC, l.day"); $sth->setFetchMode(PDO::FETCH_CLASS, 'Team', array(LOAD_OBJECT_ONLY)); $sth->execute(array($this->user_id)); $this->teams = array(); while ($team = $sth->fetch()) { if ($team->position == 'captain' || $team->position == 'assistant' || $team->position == 'coach') { # TODO: evil hack. $this->is_a_captain = true; } $this->teams[$team->team_id] = $team; $this->teams[$team->team_id]->id = $team->team_id; } /* Fetch league info. Can't use League::load as it calls Person::load, * which makes this recursively painful. */ $sth = $dbh->prepare("SELECT\n\t\t\t\tl.league_id,\n\t\t\t\tl.name,\n\t\t\t\tl.tier,\n\t\t\t\tl.season,\n\t\t\t\tl.day,\n\t\t\t\tl.schedule_type,\n\t\t\t\tl.status AS league_status,\n\t\t\t\tm.status\n\t\t\tFROM\n\t\t\t \tleaguemembers m\n\t\t\t\tINNER JOIN league l ON (m.league_id = l.league_id)\n\t\t\tWHERE\n\t\t\t\tm.status = 'coordinator'\n\t\t\tAND\n\t\t\t\tm.player_id = ?\n\t\t\t ORDER BY l.season, l.day, l.name, l.tier"); $sth->setFetchMode(PDO::FETCH_CLASS, 'League', array(LOAD_OBJECT_ONLY)); $sth->execute(array($this->user_id)); $this->leagues = array(); while ($league = $sth->fetch()) { # TODO: evil hack... this belongs in the league constructor, no? $this->is_a_coordinator = true; if ($league->tier) { $league->fullname = sprintf("{$league->name} Tier %02d", $league->tier); } else { $league->fullname = $league->name; } $this->leagues[$league->league_id] = $league; } /* Evil hack to get 'Inactive Teams' into menu */ if ($this->is_a_coordinator) { $sth = League::query(array('league_id' => 1)); $this->leagues[1] = $sth->fetchObject('League', array(LOAD_OBJECT_ONLY)); } return true; }