protected function load_content($event, $permalink = null, $external_only = false)
 {
     if (!$permalink) {
         $permalink = $this->GetData('permalink');
     }
     $content = EventContent::find_by_permalink($event, $permalink, $external_only);
     if ($content) {
         return $content;
     } else {
         Error404();
     }
 }
 protected static function load_content($event, $permalink = null, $external_only = false)
 {
     if (!$permalink) {
         $permalink = $_GET['permalink'];
     }
     $content = EventContent::find_by_permalink($event, $permalink, $external_only);
     if ($content) {
         return $content;
     } else {
         Error404();
     }
 }
 public function coverage($permalink = null)
 {
     $event = self::load_event($permalink);
     $this->assign('event', $event);
     $this->assignLayout('cEvent', $event);
     $slideshow = Slideshow::find(null, "slideshows.created_at DESC", true, 5);
     $this->assign("slideshow", $slideshow);
     $news = News::find_published('', "news.publish_at DESC", true, 5);
     $this->assign('news', $news);
     $matches = EventContent::find_by_permalink($event, 'matchfeed', false);
     $this->assign('matches', $matches);
     $twitch = Twitch::find_all('twitch.public = 1', 'twitch.position ASC');
     $activeTwitch = Twitch::getActive();
     $this->assignLayout('twitch', $twitch);
     $this->assignLayout('activetwitch', $activeTwitch);
     $this->layout = 'coverage2';
     $this->title = "{$event->name} :: Coverage";
     $this->render('event/coverage2.tpl');
 }
 public function index($permalink = null)
 {
     $event = self::load_event($permalink);
     $this->assign("event", $event);
     $content = EventContent::find_by_permalink($event, 'seating', false);
     if ($content) {
         $this->assign('content', $content);
     }
     $planPermalink = $this->getData('seatingplan');
     $event_id = mysql_real_escape_string($event->id);
     $plan = null;
     if ($planPermalink) {
         $planPermalink = mysql_real_escape_string($planPermalink);
         $plan = EventSeatingPlan::find("events.id = '{$event_id}' AND seating_plans.permalink = '{$planPermalink}'");
         if (!$plan) {
             Error404('Unable to find seating plan');
         }
     } else {
         $plan = EventSeatingPlan::find("events.id = '{$event_id}'", "event_seatingplans.position ASC");
     }
     $groups = array();
     $signups = array();
     $anyseat = false;
     $noseat = false;
     $event_id = mysql_real_escape_string($event->id);
     if (Site::CurrentUser()) {
         $user_id = mysql_real_escape_string(Site::CurrentUser()->id);
         $signups = EventSignup::find_all("event_signups.event_id = '{$event_id}' AND (event_signups.user_id = '{$user_id}' OR event_signups.manager_id = '{$user_id}') AND event_signups.paid = true AND event_tickets.participant = true");
         if ($signups) {
             if ($event->lock_seating) {
                 $noseat = false;
                 foreach ($signups as $signup) {
                     if (!$signup->event_seat_id) {
                         $noseat = true;
                         break;
                     }
                 }
                 if ($noseat) {
                     Site::Flash('notice', 'Seating has been locked for this event, however you can select a seat. You will not be able to change it.');
                 } else {
                     Site::Flash('notice', 'Seating has been locked for this event. You cannot change your seat.');
                 }
             }
         }
         foreach ($signups as $signup) {
             if ($signup->event_ticket->seating_group_id) {
                 $groups[] = $signup->event_ticket->seating_group_id;
             } else {
                 $anyseat = true;
             }
         }
     }
     $this->assign('plan', $plan);
     $this->assign('groups', $groups);
     $this->assign("signups", $signups);
     $this->assign("anyseat", $anyseat);
     $this->assign('noseat', $noseat);
     $this->title = "{$event->name} :: Seating Plan";
     if ($plan) {
         $this->title .= " :: {$plan->seating_plan->name}";
     }
     $this->render("event_seat/index.tpl");
 }
 public function content($reload = false)
 {
     if ($reload or !$this->content_cache) {
         $id = mysql_real_escape_string($this->id);
         $this->content_cache = EventContent::find_all("event_content.event_id = '{$id}'");
     }
     return $this->content_cache;
 }
 public function pay($id = null)
 {
     $signup = self::load_signup($id);
     // Check signup here
     if (!$signup->paid and $signup->is_soldout()) {
         Site::Flash("error", "The ticket you have chosen has sold out");
         Redirect("bookings/{$signup->id}");
     }
     if ($signup->event->enddate < time()) {
         Site::Flash("error", "This event has now finished, it is not possible to pay for your booking");
         Redirect("bookings/{$signup->id}");
     }
     $services = $signup->check_services();
     $signup->event_services();
     $cart = Cart::create_from_signup($signup);
     if ($cart) {
         $cart->check_discounts();
         $this->assign("cart", $cart);
         $this->assign("signup", $signup);
         $this->assign("services", $services);
         $this->assign('eventpage', true);
         $terms = EventContent::find_by_permalink($signup->event, "terms");
         $this->assign("terms", $terms);
         $gateway = PaymentGateway::getActive();
         $this->assign('gateway', $gateway);
         $this->assign('baseURI', $this->getBaseURI());
         $this->title = "My Bookings :: {$signup->event->name} :: Pay";
         $this->render("event_signup/pay.tpl");
     } else {
         Site::Flash("error", "There is nothing to pay for in this booking");
         Redirect("bookings/{$signup->id}");
     }
 }