public function getSponsorOptions(SS_HTTPRequest $request)
 {
     try {
         $query_string = $request->getVars();
         $query = Convert::raw2sql($query_string['query']);
         $summit_id = intval($request->param('SUMMIT_ID'));
         $event_id = intval($request->param('EVENT_ID'));
         $summit = $this->summit_repository->getById($summit_id);
         if (is_null($summit)) {
             throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id));
         }
         $event = $this->summitevent_repository->getById($event_id);
         if (is_null($event)) {
             throw new NotFoundEntityException('SummitEvent', sprintf(' id %s', $event_id));
         }
         $sponsors = DB::query("SELECT C.ID AS id, C.Name AS name FROM Company AS C\n                                    WHERE C.Name LIKE '{$query}%'\n                                    ORDER BY C.Name");
         $json_array = array();
         foreach ($sponsors as $sponsor) {
             $json_array[] = $sponsor;
         }
         echo json_encode($json_array);
     } catch (NotFoundEntityException $ex2) {
         SS_Log::log($ex2->getMessage(), SS_Log::WARN);
         return $this->notFound($ex2->getMessage());
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->serverError();
     }
 }
 public function unPublishEvent(SS_HTTPRequest $request)
 {
     try {
         if (!$this->isJson()) {
             return $this->validationError(array('invalid content type!'));
         }
         $query_string = $request->getVars();
         $summit_id = intval($request->param('SUMMIT_ID'));
         $event_id = intval($request->param('EVENT_ID'));
         $summit = $this->summit_repository->getById($summit_id);
         if (is_null($summit)) {
             throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id));
         }
         $event = $this->summitevent_repository->getById($event_id);
         if (is_null($event)) {
             throw new NotFoundEntityException('SummitEvent', sprintf(' id %s', $event_id));
         }
         $this->summit_service->unpublishEvent($summit, $event);
         return $this->ok();
     } catch (EntityValidationException $ex1) {
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         return $this->validationError($ex1->getMessages());
     } catch (NotFoundEntityException $ex3) {
         SS_Log::log($ex3->getMessage(), SS_Log::WARN);
         return $this->notFound($ex3->getMessage());
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->serverError();
     }
 }
 public function DoGlobalSearch(SS_HTTPRequest $request)
 {
     $term = Convert::raw2sql($request->requestVar('t'));
     if (empty($term)) {
         return $this->httpError(404);
     }
     $summit_id = $this->Summit()->ID;
     $speakers = $this->speaker_repository->searchBySummitAndTerm($this->Summit(), $term);
     $events = $this->event_repository->searchBySummitAndTerm($this->Summit(), $term);
     return $this->renderWith(array('SummitAppSchedPage_globalSearchResults', 'SummitPage', 'Page'), array('SpeakerResults' => new ArrayList($speakers), 'EventResults' => new ArrayList($events), 'SearchTerm' => $term));
 }
 public function DoGlobalSearch(SS_HTTPRequest $request)
 {
     $term = Convert::raw2sql($request->requestVar('t'));
     if (empty($term)) {
         return $this->httpError(404);
     }
     $summit_id = $this->Summit()->ID;
     $db_term = SummitScheduleGlobalSearchTerm::get()->filter(array('Term' => $term, 'SummitID' => $summit_id))->first();
     if (is_null($db_term)) {
         $db_term = SummitScheduleGlobalSearchTerm::create();
     }
     $db_term->Hits = intval($db_term->Hits) + 1;
     $db_term->Term = $term;
     $db_term->SummitID = $summit_id;
     $db_term->write();
     $popular_terms = SummitScheduleGlobalSearchTerm::get()->filter(array('SummitID' => $summit_id))->sort('Term', 'ASC')->limit(25, 0);
     $speakers = $this->speaker_repository->searchBySummitAndTerm($this->Summit(), $term);
     $events = $this->event_repository->searchBySummitAndTerm($this->Summit(), $term);
     return $this->renderWith(array('SummitAppSchedPage_globalSearchResults', 'SummitPage', 'Page'), array('SpeakerResults' => new ArrayList($speakers), 'EventResults' => new ArrayList($events), 'SearchTerm' => $term, 'PopularTerms' => $popular_terms));
 }
 public function room_metrics(SS_HTTPRequest $request)
 {
     $summit_id = intval($request->param('SummitID'));
     $summit = Summit::get()->byID($summit_id);
     Requirements::css('summit/css/simple-sidebar.css');
     Requirements::css('summit/css/summit-admin-room-metrics.css');
     Requirements::css('themes/openstack/bower_assets/sweetalert/dist/sweetalert.css');
     Requirements::css('themes/openstack/bower_assets/jquery-ui/themes/smoothness/jquery-ui.css');
     Requirements::css("themes/openstack/bower_assets/jqplot-bower/dist/jquery.jqplot.min.css");
     Requirements::javascript("themes/openstack/bower_assets/jqplot-bower/dist/jquery.jqplot.min.js");
     Requirements::javascript("themes/openstack/bower_assets/jqplot-bower/dist/plugins/jqplot.canvasTextRenderer.min.js");
     Requirements::javascript("themes/openstack/bower_assets/jqplot-bower/dist/plugins/jqplot.canvasAxisLabelRenderer.min.js");
     Requirements::javascript("themes/openstack/bower_assets/jqplot-bower/dist/plugins/jqplot.dateAxisRenderer.min.js");
     Requirements::javascript("themes/openstack/bower_assets/jqplot-bower/dist/plugins/jqplot.highlighter.min.js");
     Requirements::javascript("themes/openstack/bower_assets/jqplot-bower/dist/plugins/jqplot.cursor.min.js");
     Requirements::javascript('themes/openstack/bower_assets/sweetalert/dist/sweetalert.min.js');
     Requirements::javascript('summit/javascript/simple-sidebar.js');
     Requirements::javascript('themes/openstack/javascript/jquery-ajax-loader.js');
     $current_events = $this->event_repository->getCurrentPublished($summit_id);
     $current_events = SummitEvent::get()->where("ID = 14960");
     return $this->getViewer('room_metrics')->process($this->customise(array('Summit' => $summit, 'Events' => $current_events)));
 }
 /**
  * @param SummitEvent $event
  * @throws EntityValidationException
  */
 public function validateBlackOutTimesAndTimes(SummitEvent $event)
 {
     // validate blackout times and speaker conflict
     $event_on_timeframe = $this->event_repository->getPublishedByTimeFrame(intval($event->SummitID), $event->getStartDate(), $event->getEndDate());
     foreach ($event_on_timeframe as $c_event) {
         // if the published event is BlackoutTime or if there is a BlackoutTime event in this timeframe
         if (!$event->Location()->overridesBlackouts() && ($event->Type()->BlackoutTimes || $c_event->Type()->BlackoutTimes) && $event->ID != $c_event->ID) {
             throw new EntityValidationException(sprintf("You can't publish Event (%s) %s  on this timeframe, it conflicts with (%s) %s.", $event->ID, $event->Title, $c_event->ID, $c_event->Title));
         }
         // if trying to publish an event on a slot occupied by another event
         if (intval($event->LocationID) == $c_event->LocationID && $event->ID != $c_event->ID) {
             throw new EntityValidationException(sprintf("You can't publish Event (%s) %s  on this timeframe, it conflicts with (%s) %s.", $event->ID, $event->Title, $c_event->ID, $c_event->Title));
         }
         // validate speaker conflict
         if ($event instanceof Presentation && $c_event instanceof Presentation && $event->ID != $c_event->ID) {
             foreach ($event->Speakers() as $speaker) {
                 if ($c_event->Speakers()->find('ID', $speaker->ID)) {
                     throw new EntityValidationException(sprintf("You can't publish Event %s (%s) on this timeframe, speaker %s its presention in room %s at this time.", $event->Title, $event->ID, $speaker->getName(), $c_event->getLocationName()));
                 }
             }
         }
     }
 }