/**
  * @param $data
  * @param $form
  * @return mixed
  */
 public function doUpload($data, $form)
 {
     $material = PresentationSlide::create();
     $material->SlideID = $data['Slide'];
     $material->write();
     $this->presentation->Materials()->filter(['ClassName' => 'PresentationSlide'])->removeAll();
     $this->presentation->Materials()->add($material);
     $token = SecurityToken::inst()->getValue();
     return $form->controller()->redirect(Controller::join_links($form->controller()->Link(), 'success', "?key={$token}&material={$material->ID}"));
 }
    protected function processRecordIds(array $ids, $entity_id, $gridField, $request)
    {
        $summit_id = intval($request->param('ID'));
        if ((is_null($ids) || count($ids) === 0) && strstr($entity_id, '_ALL') !== false) {
            $entity_id = explode('_', $entity_id);
            $entity_id = intval($entity_id[0]);
            $query = <<<SQL
INSERT INTO SummitEvent_AllowedSummitTypes
(
`SummitEventID`,
`SummitTypeID`)
SELECT ID, {$entity_id} FROM SummitEvent WHERE SummitID = {$summit_id} AND ClassName = '{$gridField->getModelClass()}'
AND NOT EXISTS (SELECT 1 FROM SummitEvent_AllowedSummitTypes
WHERE
SummitEvent_AllowedSummitTypes.SummitEventID = SummitEvent.ID AND SummitEvent_AllowedSummitTypes.SummitTypeID = {$entity_id});
SQL;
            DB::query($query);
        } else {
            foreach ($ids as $id) {
                $event = SummitEvent::get()->byID($id);
                if (is_null($event)) {
                    continue;
                }
                $event->AllowedSummitTypes()->add($entity_id);
            }
        }
    }
 public function getCMSFields()
 {
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : Summit::ActiveSummitID();
     Requirements::javascript('summit/javascript/SummitPushNotification.js');
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', $txt = new TextareaField('Message', 'Message'));
     $txt->setAttribute('required', 'true');
     $f->addFieldToTab('Root.Main', $ddl_channel = new DropdownField('Channel', 'Channel', singleton('SummitPushNotification')->dbObject('Channel')->enumValues()));
     $f->addFieldToTab('Root.Main', $ddl_events = new DropdownField('EventID', 'Event', SummitEvent::get()->filter(['Published' => 1, 'SummitID' => $summit_id])->sort('Title', 'ASC')->Map('ID', 'FormattedTitle')));
     $f->addFieldToTab('Root.Main', $ddl_groups = new DropdownField('GroupID', 'Group', Group::get()->sort('Title', 'ASC')->Map('ID', 'Title')));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     $ddl_channel->setEmptyString('--SELECT A CHANNEL--');
     $ddl_channel->setAttribute('required', 'true');
     $ddl_events->setEmptyString('--SELECT AN EVENT--');
     $ddl_events->addExtraClass('hidden');
     $ddl_groups->setEmptyString('--SELECT A GROUP--');
     $ddl_groups->addExtraClass('hidden');
     $config = GridFieldConfig_RelationEditor::create(50);
     $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $config->removeComponentsByType('GridFieldAddNewButton');
     $config->addComponent($auto_completer = new CustomGridFieldAddExistingAutocompleter('buttons-before-right'));
     $auto_completer->setResultsFormat('$Title ($Email)');
     $recipients = new GridField('Recipients', 'Member Recipients', $this->Recipients(), $config);
     $f->addFieldToTab('Root.Main', $recipients);
     return $f;
 }
 protected function processRecordIds(array $ids, $entity_id)
 {
     foreach ($ids as $id) {
         $event = SummitEvent::get()->byID($id);
         if (is_null($event)) {
             continue;
         }
         $event->AllowedSummitTypes()->add($entity_id);
     }
 }
 /**
  * @param $data
  * @param Form $form
  * @return bool|SS_HTTPResponse
  */
 public function saveLink($data, Form $form)
 {
     $url = $data['Link'];
     // Attach a protocol if needed
     if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://') {
         $url = 'http://' . $url;
     }
     if (!filter_var($url, FILTER_VALIDATE_URL)) {
         $form->sessionMessage('That does not appear to be a valid URL', 'bad');
         return $this->Controller()->redirectBack();
     }
     $material = PresentationSlide::create();
     $material->Link = $url;
     $material->write();
     $this->presentation->Materials()->filter(['ClassName' => 'PresentationSlide'])->removeAll();
     $this->presentation->Materials()->add($material);
     $token = SecurityToken::inst()->getValue();
     return $this->Controller()->redirect(Controller::join_links($this->Controller()->Link(), 'success', "?key={$token}&material={$material->ID}"));
 }
 protected function processRecordIds(array $ids, $entity_id, $gridField, $request)
 {
     foreach ($ids as $id) {
         $event = SummitEvent::get()->byID($id);
         if (is_null($event)) {
             continue;
         }
         $event->TypeID = $entity_id;
         $event->write();
     }
 }
 /**
  * @param int $summit_id
  * @return array
  */
 public function getCurrentPublished($summit_id)
 {
     $summit = Summit::get()->byID($summit_id);
     if (is_null($summit)) {
         throw new InvalidArgumentException('summit not found!');
     }
     $current_date = gmdate('d/m/Y H:i:s');
     $list = SummitEvent::get()->filter(array('SummitID' => $summit_id, 'Published' => 1))->where("StartDate < '{$current_date}' AND EndDate > '{$current_date}'");
     return $list;
 }
 /**
  * @param ISummit $summit_id
  * @param array $days
  * @param string $start_time
  * @param string $end_time
  * @param array $locations
  * @return array
  */
 public function getPublishedByTimeAndVenue(ISummit $summit, $days, $start_time, $end_time, $locations)
 {
     $where_clause = '';
     if (!empty($days)) {
         $where_clause .= "(";
         foreach ($days as $day) {
             $start_date = $summit->convertDateFromTimeZone2UTC($day . ' ' . $start_time);
             $end_date = $summit->convertDateFromTimeZone2UTC($day . ' ' . $end_time);
             $where_clause .= "(StartDate < '{$end_date}' AND EndDate > '{$start_date}') OR ";
         }
         $where_clause = substr($where_clause, 0, -4) . ")";
     }
     if (!empty($locations)) {
         $locations_string = implode(',', $locations);
         $where_clause .= " AND LocationID IN ({$locations_string})";
     }
     $events = SummitEvent::get()->filter(array('SummitID' => $summit->getIdentifier(), 'Published' => 1))->where($where_clause)->sort('LocationID,StartDate')->toArray();
     return $events;
 }
 /**
  * Implement this method in the task subclass to
  * execute via the TaskRunner
  */
 public function run($request)
 {
     set_time_limit(0);
     $summit_id = intval($request->getVar('summit_id'));
     if (empty($summit_id)) {
         throw new InvalidArgumentException('missing summit_id param!');
     }
     $client = new GuzzleHttp\Client();
     $query = array('api_key' => SCHED_API_KEY, 'format' => 'json');
     $response = $client->get("http://openstacksummitoctober2015tokyo.sched.org/api/session/list", array('query' => $query));
     if ($response->getStatusCode() !== 200) {
         throw new Exception('invalid status code!');
     }
     $content_type = $response->getHeader('content-type');
     if (empty($content_type)) {
         throw new Exception('invalid content type!');
     }
     if ($content_type !== 'application/json') {
         throw new Exception('invalid content type!');
     }
     $summit = Summit::get()->byID($summit_id);
     if (is_null($summit)) {
         throw new InvalidArgumentException('missing summit_id param!');
     }
     $json = $response->getBody()->getContents();
     $events = json_decode($json, true);
     foreach ($events as $sched_event) {
         try {
             if ($sched_event["active"] !== "Y") {
                 continue;
             }
             $title = $sched_event["name"];
             $start_date = $sched_event["event_start"];
             $end_date = $sched_event["event_end"];
             $event_type = isset($sched_event["event_type"]) ? $sched_event["event_type"] : $title;
             $venue = $sched_event["venue"];
             $event = SummitEvent::get()->filter(array("SummitID" => $summit_id, "Title" => trim($title), "StartDate" => $summit->convertDateFromTimeZone2UTC($start_date), "EndDate" => $summit->convertDateFromTimeZone2UTC($end_date)))->first();
             if (is_null($event)) {
                 $event = SummitEvent::get()->filter(array("SummitID" => $summit_id, "Title" => trim($title)))->first();
             }
             $location = SummitVenueRoom::get()->filter(array("SummitID" => $summit_id, "Name" => trim($venue)))->first();
             if (is_null($location) && $venue !== 'TBA') {
                 // create location
                 $main_venue = SummitVenue::get()->filter(array("SummitID" => $summit_id))->first();
                 $location = new SummitVenueRoom();
                 $location->SummitID = $summit_id;
                 $location->Name = trim($venue);
                 $location->VenueID = $main_venue->ID;
                 $location->write();
             }
             if (is_null($event)) {
                 // create event and event type ...
                 if (isset($sched_event['speakers'])) {
                     continue;
                 }
                 $type = SummitEventType::get()->filter(array("SummitID" => $summit_id, "Type" => trim($event_type)))->first();
                 if (is_null($type)) {
                     $type = new SummitEventType();
                     $type->SummitID = $summit_id;
                     $type->Type = trim($event_type);
                     $type->write();
                 }
                 $event = new SummitEvent();
                 $event->TypeID = $type->ID;
                 $event->SummitID = $summit_id;
                 $event->Title = trim($title);
                 $event->write();
             }
             $event->StartDate = $start_date;
             $event->EndDate = $end_date;
             if (!is_null($location)) {
                 $event->LocationID = $location->ID;
             }
             $event->write();
             if ($event->isPublished()) {
                 continue;
             }
             $event_id = $event->ID;
             if (intval($event->AllowedSummitTypes()->count()) === 0) {
                 DB::query("INSERT INTO SummitEvent_AllowedSummitTypes\n(SummitEventID, SummitTypeID)\nSELECT SummitEvent.ID, SummitType.ID FROM SummitEvent, SummitType WHERE SummitEvent.ID = {$event_id} ;\n");
             }
             $event->publish();
             $event->write();
         } catch (ValidationException $ex) {
             SS_Log::log($ex->getMessage(), SS_Log::ERR);
         }
     }
 }
Example #10
0
         return;
     }
     $speaker_id = $item->ID;
     $event = new SummitEntityEvent();
     $event->EntityClassName = 'SpeakerFromPresentation';
     $event->EntityID = $speaker_id;
     $event->Type = 'DELETE';
     $event->OwnerID = Member::currentUserID();
     $event->SummitID = $presentation->SummitID;
     $event->Metadata = json_encode(array('event_id' => $presentation_id));
     $event->write();
 }
 if ($item instanceof SummitType && $list->getJoinTable() === 'SummitEvent_AllowedSummitTypes') {
     // removed summit type from event
     $event_id = intval($list->getForeignID());
     $summit_event = SummitEvent::get()->byID($event_id);
     if (is_null($summit_event)) {
         return;
     }
     $summit_type_id = $item->ID;
     $event = new SummitEntityEvent();
     $event->EntityClassName = 'SummitTypeFromEvent';
     $event->EntityID = $summit_type_id;
     $event->Type = 'DELETE';
     $event->OwnerID = Member::currentUserID();
     $event->SummitID = $summit_event->SummitID;
     $event->Metadata = json_encode(array('event_id' => $event_id));
     $event->write();
 }
 if ($item instanceof PresentationCategory && $list->getJoinTable() === 'PresentationCategoryGroup_Categories') {
     $group_id = intval($list->getForeignID());
Example #11
0
    /**
     * @return ValidationResult
     */
    protected function validate()
    {
        if (!$this->TypeID) {
            $this->assignEventType();
        }
        $valid = parent::validate();
        if (!$valid->valid()) {
            return $valid;
        }
        $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
        $summit = Summit::get()->byID($summit_id);
        // validate that each speakers is assigned one time at one location
        $start_date = $summit->convertDateFromTimeZone2UTC($this->getStartDate());
        $end_date = $summit->convertDateFromTimeZone2UTC($this->getEndDate());
        $presentation_id = $this->getIdentifier();
        $location_id = $this->LocationID;
        $speakers_id = array();
        $speakers = $this->Speakers();
        foreach ($speakers as $speaker) {
            array_push($speakers_id, $speaker->ID);
        }
        $speakers_id = implode(', ', $speakers_id);
        if (empty($start_date) || empty($end_date) || empty($speakers_id)) {
            return $valid;
        }
        $query = <<<SQL
SELECT COUNT(P.ID) FROM Presentation P
INNER JOIN SummitEvent E ON E.ID = P.ID
WHERE
E.Published = 1              AND
E.StartDate <= '{$end_date}'  AND
'{$start_date}' <= E.EndDate AND
E.ID <> {$presentation_id}     AND
E.LocationID = {$location_id}  AND
E.LocationID <> 0            AND
EXISTS
(
\tSELECT PS.ID FROM Presentation_Speakers PS WHERE PresentationSpeakerID IN ({$speakers_id}) AND
\tPresentationID = P.ID
);
SQL;
        $qty = intval(DB::query($query)->value());
        if ($qty > 0) {
            return $valid->error('There is a speaker assigned to another presentation on that date/time range !');
        }
        return $valid;
    }
 public function hasRSVPSubmission($event_id)
 {
     $event = SummitEvent::get()->byID($event_id);
     if (!$event) {
         return false;
     }
     return $event->RSVPSubmissions()->filter('SubmittedByID', $this->ID)->count() > 0;
 }
Example #13
0
 /**
  * @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()));
                 }
             }
         }
     }
 }
 /**
  * @param int $event_id
  * @return string
  */
 public function getGoogleCalEventId($event_id)
 {
     $event = SummitEvent::get()->byID($event_id);
     if (is_null($event)) {
         return false;
     }
     if (!$this->isAttendee($event->SummitID)) {
         return false;
     }
     return $this->owner->getSummitAttendee($event->SummitID)->getGoogleCalEventId($event);
 }
 public function editEvent(SS_HTTPRequest $request)
 {
     $summit_id = intval($request->param('SummitID'));
     $summit = Summit::get()->byID($summit_id);
     $event_id = intval($request->param('EventID'));
     $event = SummitEvent::get()->byID($event_id);
     Requirements::css('summit/css/simple-sidebar.css');
     Requirements::css('themes/openstack/bower_assets/chosen/chosen.min.css');
     Requirements::css('themes/openstack/bower_assets/sweetalert/dist/sweetalert.css');
     Requirements::javascript('themes/openstack/bower_assets/sweetalert/dist/sweetalert.min.js');
     Requirements::javascript('themes/openstack/bower_assets/jquery-validate/dist/jquery.validate.min.js');
     Requirements::javascript('themes/openstack/bower_assets/jquery-validate/dist/additional-methods.min.js');
     Requirements::javascript('themes/openstack/bower_assets/chosen/chosen.jquery.min.js');
     Requirements::javascript('themes/openstack/bower_assets/bootstrap3-typeahead/bootstrap3-typeahead.min.js');
     Requirements::javascript('summit/javascript/simple-sidebar.js');
     Requirements::javascript('summit/javascript/summitapp-editevent.js');
     return $this->getViewer('EditEvent')->process($this->customise(array('Summit' => $summit, 'Event' => $event)));
 }
Example #16
0
 public function getAllowedSchedule()
 {
     $summit = $this->Summit();
     if (is_null($summit)) {
         $summit = Summit::get()->byID(intval($_REQUEST['SummitID']));
     }
     return SummitEvent::get()->filter(array('Published' => true, 'SummitID' => $summit->ID));
 }
 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)));
 }