function up()
    {
        echo "Starting Migration Proc ...<BR>";
        //check if migration already had ran ...
        $migration = Migration::get()->filter('Name', $this->title)->first();
        if (!$migration) {
            $presentation_type = SummitEventType::get("SummitEventType", "Type = 'Presentation' AND SummitID = 5")->first();
            if ($presentation_type) {
                $presentation_type_id = $presentation_type->ID;
            } else {
                $presentation_type = new SummitEventType();
                $presentation_type->Type = 'Presentation';
                $presentation_type->SummitID = 5;
                $presentation_type->Color = '#D0A9F5';
                $presentation_type_id = $presentation_type->Write();
            }
            $SQL = <<<SQL
                UPDATE SummitEvent SET TypeID = {$presentation_type_id} WHERE ClassName = 'Presentation' AND SummitID = 5;
SQL;
            DB::query($SQL);
            $migration = new Migration();
            $migration->Name = $this->title;
            $migration->Description = $this->description;
            $migration->Write();
        }
        echo "Ending  Migration Proc ...<BR>";
    }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $allowed_types = new DropdownField('Type', 'Type', array('Presentation' => 'Presentation', 'Keynotes' => 'Keynotes', 'Panel' => 'Panel'));
     $fields->replaceField('Type', $allowed_types);
     $fields->add(new TextField("MaxSpeakers", "Max Speakers"));
     $fields->add(new TextField("MinSpeakers", "Min Speakers"));
     $fields->add(new TextField("MaxModerators", "Max Moderators"));
     $fields->add(new TextField("MinModerators", "Min Moderators"));
     return $fields;
 }
 function doUp()
 {
     global $database;
     $result = DB::query("SELECT E.ID,E.SummitID,E.TypeID,ET.Type FROM SummitEvent AS E LEFT JOIN SummitEventType AS ET ON ET.ID = E.TypeID WHERE ET.SummitID != E.SummitID");
     foreach ($result as $event) {
         $summit_id = $event['SummitID'];
         $event_id = $event['ID'];
         $old_type = $event['Type'];
         $new_type_id = SummitEventType::get()->where("Type = '{$old_type}' AND SummitID = {$summit_id}")->first()->ID;
         DB::query("UPDATE SummitEvent SET TypeID = {$new_type_id} WHERE ID = {$event_id}");
     }
 }
 protected function validate()
 {
     $valid = parent::validate();
     if (!$valid->valid()) {
         return $valid;
     }
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $summit = Summit::get()->byID($summit_id);
     if (!$summit) {
         return $valid->error('Invalid Summit!');
     }
     $count = intval(SummitEventType::get()->filter(array('SummitID' => $summit->ID, 'Type' => trim($this->Type), 'ID:ExactMatch:not' => $this->ID))->count());
     if ($count > 0) {
         return $valid->error(sprintf('Summit Event Type %s already exists!. please set another one', $this->Type));
     }
     return $valid;
 }
 public function run($request)
 {
     $summit_id = intval($request->requestVar('SummitID'));
     if ($summit_id <= 0) {
         throw new RuntimeException("invalid summit id");
     }
     $summit = Summit::get()->byID($summit_id);
     if (is_null($summit)) {
         throw new RuntimeException("invalid summit");
     }
     $count = 0;
     $presentations = Presentation::get()->filter(array('SummitID' => $summit_id, 'TypeID' => 0))->where(" Title IS NOT NULL AND Title <>'' ");
     Summit::seedBasicEventTypes($summit_id);
     $type = SummitEventType::get()->filter(array('Type' => 'Presentation', 'SummitID' => $summit_id))->first();
     if (is_null($type)) {
         throw new RuntimeException("invalid event type");
     }
     foreach ($presentations as $p) {
         $p->TypeID = $type->ID;
         $p->write();
         ++$count;
     }
     echo "Fixed {$count} presentations.";
 }
Exemple #6
0
 /**
  * @param int $summit_id
  * @throws ValidationException
  * @throws null
  */
 public static function seedBasicEventTypes($summit_id)
 {
     if (!SummitEventType::get()->filter(array('Type' => 'Presentation', 'SummitID' => $summit_id))->first()) {
         $presentation = new SummitEventType();
         $presentation->Type = 'Presentation';
         $presentation->SummitID = $summit_id;
         $presentation->write();
     }
     if (!SummitEventType::get()->filter(array('Type' => 'Keynotes', 'SummitID' => $summit_id))->first()) {
         $key_note = new SummitEventType();
         $key_note->Type = 'Keynotes';
         $key_note->SummitID = $summit_id;
         $key_note->write();
     }
     if (!SummitEventType::get()->filter(array('Type' => 'Hand-on Labs', 'SummitID' => $summit_id))->first()) {
         $hand_on = new SummitEventType();
         $hand_on->Type = 'Hand-on Labs';
         $hand_on->SummitID = $summit_id;
         $hand_on->write();
     }
     if (!SummitEventType::get()->filter(array('Type' => 'Lunch & Breaks', 'SummitID' => $summit_id))->first()) {
         $key_note = new SummitEventType();
         $key_note->Type = 'Lunch & Breaks';
         $key_note->SummitID = $summit_id;
         $key_note->write();
     }
     if (!SummitEventType::get()->filter(array('Type' => 'Evening Events', 'SummitID' => $summit_id))->first()) {
         $key_note = new SummitEventType();
         $key_note->Type = 'Evening Events';
         $key_note->SummitID = $summit_id;
         $key_note->write();
     }
 }
Exemple #7
0
 public function getCMSFields()
 {
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Short Description'));
     $f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end();
     $f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?'));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation'));
     $locations_source = array();
     foreach ($locations as $l) {
         $locations_source[$l->ID] = $l->getFullName();
     }
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source));
     $ddl_location->setEmptyString('-- Select a Location --');
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type')));
     $ddl_location->setEmptyString('-- Select a Event Type --');
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     if ($this->ID > 0) {
         // summits types
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id));
         $summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config);
         $f->addFieldToTab('Root.Main', $summit_types);
         // sponsors
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config);
         $f->addFieldToTab('Root.Sponsors', $sponsors);
         // feedback
         $config = new GridFieldConfig_RecordEditor(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config);
         $f->addFieldToTab('Root.Feedback', $feedback);
     }
     return $f;
 }
 /**
  * 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);
         }
     }
 }
 public function getCMSFields()
 {
     Requirements::customScript("\n        jQuery( document ).ready(function() {\n            jQuery('body').on('change','#Form_ItemEditForm_RSVPTemplateID',\n                function(){\n                    jQuery('#Form_ItemEditForm_action_save').click();\n                }\n            );\n        });");
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Abstract'));
     $f->addFieldToTab('Root.Main', new TextField('HeadCount', 'HeadCount'));
     $f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end();
     $f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?'));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldsToTab('Root.Main', new ReadonlyField('AvgFeedbackRate', 'AvgFeedbackRate'));
     $locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation'));
     $locations_source = array();
     foreach ($locations as $l) {
         $locations_source[$l->ID] = $l->getFullName();
     }
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source));
     $ddl_location->setEmptyString('-- Select a Location --');
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type')));
     $ddl_location->setEmptyString('-- Select a Event Type --');
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     if ($this->ID > 0) {
         // summits types
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id));
         $summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config);
         $f->addFieldToTab('Root.Main', $summit_types);
         // sponsors
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config);
         $f->addFieldToTab('Root.Sponsors', $sponsors);
         // feedback
         $config = new GridFieldConfig_RecordEditor(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config);
         $f->addFieldToTab('Root.Feedback', $feedback);
         // rsvp
         $f->addFieldsToTab('Root.RSVP', new TextField('RSVPLink', 'RSVP External Link'));
         $rsvp_template = new DropdownField('RSVPTemplateID', 'Select a Template', RSVPTemplate::get()->filter('SummitID', $summit_id)->map());
         $rsvp_template->setEmptyString('-- View All Templates --');
         $f->addFieldToTab('Root.RSVP', LiteralField::create('AddNew', 'Or add a new custom RSVP Configuration'));
         $f->addFieldToTab('Root.RSVP', $rsvp_template);
         $f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserNumber', 'Max # Number'));
         $f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserWaitListNumber', 'Max # Wait List'));
         $f->addFieldToTab('Root.RSVP', $rsvp_template);
         if ($this->RSVPTemplate()->exists()) {
             $config = new GridFieldConfig_RecordEditor(100);
             $config->removeComponentsByType('GridFieldAddNewButton');
             $config->addComponent(new GridFieldAjaxRefresh(1000, false));
             $rsvps = new GridField('RSVPSubmissions', 'RSVP Submissions', $this->RSVPSubmissions(), $config);
             $f->addFieldToTab('Root.RSVP', $rsvps);
         }
     }
     if ($this->ID > 0) {
         $_REQUEST['SummitEventID'] = $this->ID;
     }
     return $f;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $f = parent::getCMSFields();
     $f->removeByName('TypeID');
     $f->dropdown('Level', 'Level', $this->dbObject('Level')->enumValues())->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->listbox('Topics', 'Topics', PresentationTopic::get()->map('ID', 'Title')->toArray())->configure()->setMultiple(true)->end()->text('OtherTopic', 'Other topic')->htmleditor('ProblemAddressed', 'What is the problem or use case you’re addressing in this session?')->htmleditor('AttendeesExpectedLearnt', 'What should attendees expect to learn?')->tab('Preview')->literal('preview', sprintf('<iframe width="%s" height="%s" frameborder="0" src="%s"></iframe>', '100%', '400', Director::absoluteBaseURL() . $this->PreviewLink()));
     $f->addFieldToTab('Root.Main', $ddl_type = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter(array('SummitID' => $summit_id))->where(" Type ='Presentation' OR Type ='Keynotes' OR Type ='Panel' ")->map('ID', 'Type')));
     $ddl_type->setEmptyString('-- Select a Presentation Type --');
     if ($this->ID > 0) {
         // speakers
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $speakers = new GridField('Speakers', 'Speakers', $this->Speakers(), $config);
         $f->addFieldToTab('Root.Speakers', $speakers);
         $config->getComponentByType('GridFieldAddExistingAutocompleter')->setResultsFormat('$Name - $Member.Email')->setSearchList($this->getAllowedSpeakers());
         // moderator
         $f->addFieldToTab('Root.Speakers', $ddl_moderator = new DropdownField('ModeratorID', 'Moderator', $this->Speakers()->map('ID', 'Name')));
         $ddl_moderator->setEmptyString('-- Select a Moderator --');
         $config = GridFieldConfig_RecordEditor::create(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('PresentationVideo' => 'Video', 'PresentationSlide' => 'Slide', 'PresentationLink' => 'Link'));
         $config->addComponent($multi_class_selector);
         $config->addComponent($sort = new GridFieldSortableRows('Order'));
         $gridField = new GridField('Materials', 'Materials', $this->Materials(), $config);
         $f->addFieldToTab('Root.Materials', $gridField);
     }
     return $f;
 }
 /**
  * @param ISummit $summit
  * @param array $event_data
  * @return mixed
  */
 public function updateEvent(ISummit $summit, array $event_data)
 {
     $event_repository = $this->event_repository;
     $this_var = $this;
     return $this->tx_service->transaction(function () use($this_var, $summit, $event_data, $event_repository) {
         if (!isset($event_data['id'])) {
             throw new EntityValidationException('missing required param: id');
         }
         $event_id = intval($event_data['id']);
         $event = $event_repository->getById($event_id);
         if (is_null($event)) {
             throw new NotFoundEntityException('Summit Event', sprintf('id %s', $event_id));
         }
         if (intval($event->SummitID) !== intval($summit->getIdentifier())) {
             throw new EntityValidationException('event doest not belongs to summit');
         }
         $event_type_id = intval($event_data['event_type']);
         $event_type = SummitEventType::get()->byID($event_type_id);
         if (is_null($event_type)) {
             throw new NotFoundEntityException('EventType');
         }
         if (!self::checkEventType($event, $event_type)) {
             throw new EntityValidationException('Invalid event type!');
         }
         $start_date = $event_data['start_date'];
         $end_date = $event_data['end_date'];
         if (!empty($start_date) || !empty($end_date)) {
             $d1 = new DateTime($start_date);
             $d2 = new DateTime($end_date);
             if ($d1 >= $d2) {
                 throw new EntityValidationException('Start Date should be lower than End Date!');
             }
             if (!$summit->belongsToDuration($d1)) {
                 throw new EntityValidationException('Start Date should be inside Summit Duration!');
             }
             if (!$summit->belongsToDuration($d2)) {
                 throw new EntityValidationException('Start Date should be inside Summit Duration!');
             }
         }
         $event->Title = html_entity_decode($event_data['title']);
         $event->RSVPLink = html_entity_decode($event_data['rsvp_link']);
         $event->HeadCount = intval($event_data['headcount']);
         $event->ShortDescription = html_entity_decode($event_data['short_description']);
         $event->setStartDate($event_data['start_date']);
         $event->setEndDate($event_data['end_date']);
         $event->AllowFeedBack = $event_data['allow_feedback'];
         $event->LocationID = intval($event_data['location_id']);
         $event->TypeID = $event_type_id;
         $summit_types = $event_data['summit_type'] ? $event_data['summit_type'] : array();
         $event->AllowedSummitTypes()->setByIDList($summit_types);
         $tags = $event_data['tags'] ? explode(',', $event_data['tags']) : array();
         $event->Tags()->setByIDList($tags);
         $sponsors = $event_data['sponsors'] ? explode(',', $event_data['sponsors']) : array();
         $event->Sponsors()->setByIDList($sponsors);
         self::updatePresentation($event, $event_data);
         $must_publish = (bool) $event_data['publish'];
         if ($event->isPublished() || $must_publish) {
             $this_var->validateBlackOutTimesAndTimes($event);
             $event->unPublish();
             $event->publish();
         }
         $event->write();
         return $event;
     });
 }
 protected function getEntities()
 {
     $summit_id = intval($_REQUEST['SummitID']);
     return SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type');
 }
 protected function getEntities()
 {
     $summit_id = intval(Controller::curr()->getRequest()->param('ID'));
     return SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type');
 }