public function show($id = null) { $group = self::load_group($id); $sort = "user_groups.id ASC"; if (isset($_GET['sort'])) { $options = array("nickname" => "users.nickname ASC", "email" => "users.email ASC", "activated" => "users.activated DESC", "created" => "users.created_at ASC"); if (isset($options[$_GET['sort']])) { $sort = $options[$_GET['sort']]; } } $group_events = array(); foreach ($group->events() as $event) { $group_events[] = $event->id; } $all_events = Event::find_all(); $events = array(); foreach ($all_events as $event) { if (!in_array($event->id, $group_events)) { $events[] = $event; } } $this->assign("events", $events); $this->assign("users", $group->user_groups($sort)); $this->assign("group", $group); $this->title = "View Group"; $this->render("group/show.tpl"); }
public function edit($id = null) { $this->tinymce = true; $survey = self::load_survey($id); if ($this->post) { $survey->name = $this->PostData("name"); $survey->description = $this->PostData("description"); $survey->permalink = $this->PostData("permalink"); $survey->intro = $this->PostData("intro"); $survey->finish = $this->PostData("finish"); $survey->active = $this->PostData("active"); $survey->event_id = $this->PostData("event_id"); if ($survey->Save()) { Site::Flash("notice", "The survey has been edited"); Redirect("admin/surveys/{$survey->id}"); } } $all_events = Event::find_all("", "events.startdate ASC"); $events = array('' => 'None'); foreach ($all_events as $event) { $events[$event->id] = $event->name; } $this->assign("events", $events); $this->assign("survey", $survey); $this->title = "Edit Survey"; $this->render("survey/edit.tpl"); }
public function index() { $all_events = Event::find_all("events.visible = true OR events.advertised = true", "events.startdate DESC"); $events = array(); foreach ($all_events as $event) { if ($event->check_user(Site::CurrentUser())) { $events[] = $event; } } $this->assign("events", $events); $this->title = "Events"; $this->render("event/index.tpl"); }
public function show($nickname = null) { $user = $this->load_user($nickname); $all_events = Event::find_all("", "events.startdate DESC"); $events = array(); foreach ($all_events as $event) { $events[$event->id] = $event->name; } $this->assign("user", $user); $this->assign("events", $events); $this->title = "View User"; $this->render("user/show.tpl"); }
public static function render($title = null, $headcontent = null) { self::init(); global $site; global $config; $smarty = new SmartySite(); $smarty->assign("title", $title); $smarty->assign("site", $site); $smarty->assign("content", "|--|CONTENT|--|"); $smarty->assign("headcontent", $headcontent); $smarty->assign("next_event", Event::next_event()); $all_events = Event::find_all("events.visible = true", "events.startdate DESC"); $events = array(); foreach ($all_events as $event) { if ($event->check_user(Site::CurrentUser())) { $events[] = $event; } } $smarty->assign("all_events", $events); $output = $smarty->fetch("application/layout.tpl"); $output = explode("|--|CONTENT|--|", $output); return array("header" => $output[0], "footer" => $output[1]); }
public function save() { if ($this->permalink == "") { $this->permalink = self::make_permalink($this->name); } // If this is a new event, create a new achievement category if (!$this->achievement_category_id) { $achievement_category = new AchievementCategory(); $achievement_category->category_name = $this->name; $achievement_category->save(); $this->achievement_category_id = $achievement_category->id; } $result = parent::save(self::table); if ($result && $this->next) { $id = mysql_real_escape_string($this->id); $events = Event::find_all("events.next = TRUE and events.id <> '{$id}'"); foreach ($events as $event) { $event->next = false; $event->save(); } } return $result; }
function RenderPage($title, $content, $layout = "layout", $nosql = false, $vars = array()) { global $site; global $config; $smarty = new SmartySite(); $smarty->assign("title", $title); $smarty->assign("content", $content); $smarty->assign("headcontent", ""); $smarty->assign("site", $site); foreach ($vars as $name => $value) { $smarty->assign($name, $value); } if (isset($_SESSION['csrf'])) { $smarty->assign("csrf", $_SESSION['csrf']); } if (!$nosql) { $revert = false; if (isset($config['dev_sql']) && $config['dev_sql']) { $config['dev_sql'] = false; $revert = true; } $smarty->assign("next_event", Event::next_event()); $events = array('future' => Event::find_all("(events.visible = true OR events.advertised = true) AND events.enddate > NOW()", "events.enddate ASC"), 'past' => Event::find_all("(events.visible = true OR events.advertised = true) AND events.enddate <= NOW()", "events.enddate DESC")); foreach ($events as $type => $collection) { ${$type} = array(); foreach ($collection as $key => $event) { if ($event->check_user(Site::CurrentUser())) { array_push(${$type}, $event); } } $smarty->assign("{$type}Events", ${$type}); } $smallEvents = array(); $largeEvents = array(); foreach ($future as $event) { if ($event->capacity < 50) { $smallEvents[] = $event; } else { $largeEvents[] = $event; } } $smallEvents = array_slice($smallEvents, 0, 3); $largeEvents = array_slice($largeEvents, 1, 1); $smarty->assign('smallEvents', $smallEvents); $smarty->assign('largeEvents', $largeEvents); if ($revert) { $config['dev_sql'] = true; } } // Determine SSL or not $protocol = "http"; if (isset($_SERVER['SERVER_PORT']) and $_SERVER['SERVER_PORT'] == 443) { $protocol = "https"; } $baseuri = "{$protocol}://{$_SERVER['HTTP_HOST']}"; $smarty->assign("protocol", $protocol); $smarty->assign("baseuri", $baseuri); $smarty->display("application/{$layout}.tpl"); if (isset($config['dev_sql']) && $config['dev_sql']) { file_put_contents("logs/sql.log", "\r\n", FILE_APPEND); } die; }
public function index($permalink = null) { $sort = $this->GetData('sort', "id"); if ($sort == "nickname") { $order = "users.nickname ASC"; } elseif ($sort == "date") { $order = "event_signups.created_at DESC"; } elseif ($sort == "id") { $order = "event_signups.id ASC"; } elseif ($sort == "seat") { $order = "event_seats.row ASC, event_seats.number ASC"; } elseif ($sort == "ticket") { $order = "event_tickets.name ASC"; } elseif ($sort == "event") { $order = "events.name DESC"; } elseif ($sort == "voucher") { $order = "event_signups.voucher DESC"; } else { $order = "event_signups.paid DESC, users.nickname ASC"; } if (isset($_SESSION['signupadminquery'])) { $query = $_SESSION['signupadminquery']; } else { $query = (object) array('event_id' => null, 'signup_id' => null); } if (isset($_GET['event_id'])) { $query->event_id = $this->GetData('event_id'); } if (isset($_GET['signup_id'])) { $query->signup_id = $this->GetData('signup_id'); } $_SESSION['signupadminquery'] = $query; $filters = array(); if ($query->event_id) { $event_id = mysql_real_escape_string($query->event_id); $filters[] = "events.id = '{$event_id}'"; } if ($query->signup_id) { $signup_id = mysql_real_escape_string($query->signup_id); $filters[] = "event_signups.id = '{$signup_id}'"; } $filter = implode(' AND ', $filters); $page = $this->GetData('page', 1); $signups = EventSignup::paginate($filter, $order, $page, 100); $allEvents = Event::find_all("", "events.startdate DESC"); $events = array('' => 'All'); foreach ($allEvents as $event) { $events[$event->id] = $event->name; } $this->assign('query', $query); $this->assign('events', $events); $this->assign("signups", $signups); $this->assign("sort", $sort); $this->title = "Event Signups"; $this->render("event_signup/index.tpl"); }
public function index() { $events = Event::find_all("", "events.created_at ASC"); $this->assign("events", $events); $this->title = "Events"; $this->render("event/index.tpl"); }