function doUp()
    {
        global $database;
        if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'OnSitePhoneNumber')) {
            $speakers_info_query = <<<SQL
SELECT ID, OnSitePhoneNumber, ConfirmedDate, RegisteredForSummit
FROM PresentationSpeaker where OnSitePhoneNumber IS NOT NULL;
SQL;
            $res = DB::query($speakers_info_query);
            foreach ($res as $row) {
                $speaker_id = intval($row['ID']);
                $on_site_phone = intval($row['OnSitePhoneNumber']);
                $confirmed_date = $row['ConfirmedDate'];
                $registered = (bool) $row['RegisteredForSummit'];
                $speaker = PresentationSpeaker::get()->byID($speaker_id);
                if (is_null($speaker)) {
                    continue;
                }
                if (PresentationSpeakerSummitAssistanceConfirmationRequest::get()->filter(array('SummitID' => 5, 'SpeakerID' => $speaker_id))->count() > 0) {
                    continue;
                }
                $assistance = PresentationSpeakerSummitAssistanceConfirmationRequest::create();
                $assistance->SpeakerID = $speaker_id;
                $assistance->SummitID = 5;
                $assistance->OnSitePhoneNumber = $on_site_phone;
                $assistance->ConfirmationDate = $confirmed_date;
                $assistance->RegisteredForSummit = $registered;
                $assistance->IsConfirmed = true;
                $assistance->write();
            }
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'OnSitePhoneNumber');
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'ConfirmedDate');
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'RegisteredForSummit');
        }
    }
 /**
  * @param SS_HTTPRequest $r
  */
 public function presentations(SS_HTTPRequest $r)
 {
     $data = [];
     $speaker = null;
     $key = $r->getVar('key');
     if ($key) {
         $username = PresentationSpeaker::hash_to_username($key);
         $speaker = PresentationSpeaker::get()->filter('Member.Email', $username)->first();
     } elseif ($speakerID = Session::get('UploadMedia.SpeakerID')) {
         $speaker = PresentationSpeaker::get()->byID($speakerID);
     }
     // Speaker not found
     if (!$speaker) {
         return $this->httpError(404, 'Sorry, that does not appear to be a valid token.');
     }
     Session::set('UploadMedia.SpeakerID', $speaker->ID);
     $mostRecentSummit = Summit::get_most_recent();
     $presentations = $speaker->PublishedPresentations($mostRecentSummit->ID);
     // No presentations
     if (!$presentations->exists()) {
         return $this->httpError(404, 'Sorry, it does not appear that you have any presentations.');
     }
     // IF there's only one presentation with no media, go ahead and forward to it's page
     if ($presentations->count() == 1) {
         $slide = $presentations->first()->MaterialType('PresentationSlide');
         if (!$slide) {
             $presentationID = $presentations->first()->ID;
             return $this->redirect(Controller::join_links($this->Link(), '/presentation/', $presentationID, 'upload'));
         }
     }
     $data['Speaker'] = $speaker;
     $data['Presentations'] = $presentations;
     return $this->customise($data);
 }
 public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'));
     if ($this->SchedID) {
         return $fields->tab('SchedData')->readonly('Title')->readonly('Description')->readonly('EventStart')->readonly('EventEnd')->readonly('EventKey')->readonly('EventType')->readonly('Goers')->readonly('SchedID')->readonly('InviteOnly')->readonly('Seats')->readonly('Venue')->readonly('VenueID')->tab('EditableData')->checkbox('DisplayOnSite')->text('YouTubeID')->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->listbox('PresentationSpeakers')->configure()->setSource(PresentationSpeaker::get()->map('ID', 'Title')->toArray())->setMultiple(true)->end()->imageUpload('VideoThumbnail')->upload('RelatedMedia')->tag('Tags', 'Tags', Tag::get(), $this->Tags());
     } else {
         return $fields->text('Title')->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->tag('Tags', 'Tags', Tag::get(), $this->Tags())->date('EventStart')->configure()->setConfig('showcalendar', true)->end()->date('EventEnd')->configure()->setConfig('showcalendar', true)->end()->htmlEditor('Description')->checkbox('InviteOnly')->numeric('Seats')->text('Venue')->text('YouTubeID')->imageUpload('VideoThumbnail')->upload('RelatedMedia')->checkbox('DisplayOnSite');
     }
 }
 public function getSpeakerProfileImage(SS_HTTPRequest $request)
 {
     $speaker_id = intval($request->param('SpeakerID'));
     $speaker = PresentationSpeaker::get()->byID($speaker_id);
     if (is_null($speaker)) {
         return $this->notFound();
     }
     $photo_url = $speaker->ProfilePhoto();
     $body = file_get_contents($photo_url);
     $ext = 'jpg';
     $response = new SS_HTTPResponse($body, 200);
     $response->addHeader('Content-Type', 'image/' . $ext);
     return $response;
 }
Esempio n. 5
0
 function doSavePhoneNumber($data, $form)
 {
     if (isset($data['speakerHash'])) {
         $hashKey = Convert::raw2sql($data['speakerHash']);
     }
     if (isset($hashKey)) {
         $speakerID = substr(base64_decode($hashKey), 3);
     }
     if (isset($speakerID) && is_numeric($speakerID) && isset($data['OnSitePhoneNumber']) && $data['OnSitePhoneNumber'] != '' && ($Speaker = PresentationSpeaker::get()->byID($speakerID))) {
         $Speaker->OnSitePhoneNumber = Convert::raw2sql($data['OnSitePhoneNumber']);
         $Speaker->ConfirmedDate = SS_Datetime::now()->Value;
         $Speaker->RegisteredForSummit = Convert::raw2sql($data['RegisteredForSummit']);
         $Speaker->write();
         Controller::curr()->redirect(Controller::curr()->Link() . 'Thanks/');
     }
 }
 public function confirm()
 {
     parent::init();
     $getVars = $this->request->getVars();
     $hashKey = $getVars['h'];
     if (isset($hashKey)) {
         $speakerID = substr(base64_decode($hashKey), 3);
     }
     if (isset($speakerID) && is_numeric($speakerID) && ($Speaker = PresentationSpeaker::get()->byID($speakerID))) {
         Session::set('ConfirmSpeakerHash', $hashKey);
         Session::set('Speaker', $Speaker);
         $Speaker->Confirmed = true;
         $Speaker->write();
         $data['FirstName'] = $Speaker->FirstName;
         $data['LastName'] = $Speaker->LastName;
         $data['Summit'] = Summit::get_active();
         return $this->customise($data)->renderWith(array('SummitConfirmSpeakerPage', 'SummitPage'), $this->parent);
     } else {
         return $this->httpError(404, 'Sorry, this speaker confirmation code does not seem to be correct.');
     }
 }
Esempio n. 7
0
 /**
  * @param SS_HTTPRequest $r
  */
 public function emailspeakers(SS_HTTPRequest $r)
 {
     $summit = Summit::get_most_recent();
     $confirm = $r->getVar('confirm');
     $limit = $r->getVar('limit');
     $speakers = PresentationSpeaker::get()->innerJoin('Presentation_Speakers', 'Presentation_Speakers.PresentationSpeakerID = PresentationSpeaker.ID')->innerJoin('SummitEvent', 'SummitEvent.ID = Presentation_Speakers.PresentationID')->innerJoin('Presentation', 'Presentation.ID = SummitEvent.ID')->exclude(['Presentation.CategoryID' => [40, 41, 46, 45, 48]])->filter(['SummitID' => $summit->ID, 'SummitEvent.Published' => true]);
     $totalBeforeLimit = $speakers->count();
     $appliedLimit = $confirm ? null : ($limit ?: 50);
     $speakers = $speakers->limit($appliedLimit);
     foreach ($speakers as $speaker) {
         /* @var DataList */
         $presentations = $speaker->PublishedPresentations($summit->ID);
         // Todo -- how to deal with this?
         // !$speaker->GeneralOrKeynote() &&
         // !SchedSpeakerEmailLog::BeenEmailed($Speaker->email) &&
         if (!$presentations->exists()) {
             echo "Skipping {$speaker->getName()}. Has no published presentations<br>";
             continue;
         }
         if (!EmailValidator::validEmail($speaker->Member()->Email)) {
             echo $speaker->Member()->Email . " is not a valid email address. Skipping." . $this->br();
             continue;
         }
         $to = $speaker->Member()->Email;
         $subject = "Important Speaker Information for OpenStack Summit in {$summit->Title}";
         $email = EmailFactory::getInstance()->buildEmail('*****@*****.**', $to, $subject);
         $email->setUserTemplate("upload-presentation-slides-email");
         $email->populateTemplate(['Speaker' => $speaker, 'Presentations' => $presentations, 'Summit' => $summit]);
         if ($confirm) {
             //SchedSpeakerEmailLog::addSpeaker($to);
             $email->send();
         } else {
             echo $email->debug();
         }
         echo 'Email sent to ' . $to . ' (' . $speaker->getName() . ')' . $this->br();
     }
     echo $this->br(3) . "Sent a sample of {$appliedLimit} emails out of {$totalBeforeLimit} total" . $this->br();
 }
Esempio n. 8
0
 /**
  * @return DataList
  */
 private function getAllowedSpeakers()
 {
     return PresentationSpeaker::get();
 }
Esempio n. 9
0
 public function handleSpeakersForSched()
 {
     $activeSummit = Summit::get_active();
     $filepath = $_SERVER['DOCUMENT_ROOT'] . '/assets/speaker-import.csv';
     $fp = fopen($filepath, 'w');
     // Setup file to be UTF8
     fprintf($fp, chr(0xef) . chr(0xbb) . chr(0xbf));
     $Speakers = PresentationSpeaker::get()->filter('SummitID', $activeSummit->ID);
     foreach ($Speakers as $Speaker) {
         $AcceptedPresentations = $Speaker->AcceptedPresentations();
         $PhotoURL = "";
         if ($Speaker->PhotoID != 0) {
             $PhotoURL = 'http://www.openstack.org' . $Speaker->Photo()->getURL();
         }
         if ($Speaker->Bio == NULL) {
             $SpeakerWithBio = PresentationSpeaker::get()->filter(array('MemberID' => $Speaker->MemberID, 'Bio:not' => NULL))->first();
             if ($SpeakerWithBio && $SpeakerWithBio->Bio) {
                 $Speaker->Bio = $SpeakerWithBio->Bio;
             }
         }
         if ($AcceptedPresentations->count()) {
             $fullName = $Speaker->FirstName . ' ' . $Speaker->LastName;
             $fields = array($fullName, $Speaker->Member()->Email, ' ', ' ', $Speaker->Title, ' ', $Speaker->Bio, ' ', $PhotoURL);
             fputcsv($fp, $fields);
         }
     }
     fclose($fp);
     header("Cache-control: private");
     header("Content-type: application/force-download");
     header("Content-transfer-encoding: binary\n");
     header("Content-disposition: attachment; filename=\"speaker-import.csv\"");
     header("Content-Length: " . filesize($filepath));
     readfile($filepath);
 }
 public function editSpeaker(SS_HTTPRequest $request)
 {
     $summit_id = intval($request->param('SummitID'));
     $summit = Summit::get()->byID($summit_id);
     $speaker_id = intval($request->param('SpeakerID'));
     $speaker = PresentationSpeaker::get()->byID($speaker_id);
     Requirements::css('summit/css/simple-sidebar.css');
     Requirements::css('summit/css/summit-admin-edit-speaker.css');
     Requirements::css('themes/openstack/bower_assets/chosen/chosen.min.css');
     Requirements::css('themes/openstack/bower_assets/sweetalert/dist/sweetalert.css');
     // tag input
     Requirements::css('themes/openstack/bower_assets/bootstrap-tagsinput/dist/bootstrap-tagsinput.css');
     Requirements::css('themes/openstack/bower_assets/bootstrap-tagsinput/dist/bootstrap-tagsinput-typeahead.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('summit/javascript/simple-sidebar.js');
     Requirements::javascript('//tinymce.cachefly.net/4.3/tinymce.min.js');
     Requirements::javascript('themes/openstack/bower_assets/typeahead.js/dist/typeahead.bundle.min.js');
     Requirements::javascript('themes/openstack/bower_assets/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js');
     Requirements::javascript('summit/javascript/summitapp-editspeaker.js');
     return $this->getViewer('EditSpeaker')->process($this->customise(array('Summit' => $summit, 'Speaker' => $speaker)));
 }
Esempio n. 11
0
 private function getAllowedSpeakers()
 {
     return PresentationSpeaker::get()->filter(array('SummitID' => $this->SummitID));
 }
 /**
  * Implement this method in the task subclass to
  * execute via the TaskRunner
  */
 public function run($request)
 {
     set_time_limit(0);
     $api = new TrackChairAPI();
     $api->handleRestoreOrders();
     $type = intval($request->getVar('type'));
     if (empty($type)) {
         $type = 1;
     }
     $speakers = PresentationSpeaker::get()->filter('SummitID', Summit::get_active()->ID);
     $only_accepted = array();
     $accepted_rejected = array();
     $only_rejected = array();
     $only_alternate = array();
     $accepted_alternate = array();
     $alternate_rejected = array();
     foreach ($speakers as $speaker) {
         $rejected = $speaker->UnacceptedPresentations();
         $alternate = $speaker->AlternatePresentations();
         $accepted = $speaker->AcceptedPresentations();
         if ($accepted->count() > 0 && $rejected->count() === 0 && $alternate->count() === 0) {
             // only accepted
             if (!$speaker->Member()) {
                 continue;
             }
             $email = $speaker->Member()->Email;
             if (empty($email)) {
                 continue;
             }
             foreach ($accepted as $row) {
                 $only_accepted[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'ACCEPTED');
             }
             continue;
         }
         if ($accepted->count() === 0 && $rejected->count() === 0 && $alternate->count() > 0) {
             // only alternated
             if (!$speaker->Member()) {
                 continue;
             }
             $email = $speaker->Member()->Email;
             if (empty($email)) {
                 continue;
             }
             foreach ($alternate as $row) {
                 $only_alternate[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'ALTERNATE');
             }
             continue;
         }
         if ($accepted->count() === 0 && $rejected->count() > 0 && $alternate->count() === 0) {
             // only rejected
             if (!$speaker->Member()) {
                 continue;
             }
             $email = $speaker->Member()->Email;
             if (empty($email)) {
                 continue;
             }
             foreach ($rejected as $row) {
                 $only_rejected[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'REJECTED');
             }
             continue;
         }
         if ($accepted->count() > 0 && $rejected->count() === 0 && $alternate->count() > 0) {
             if (!$speaker->Member()) {
                 continue;
             }
             $email = $speaker->Member()->Email;
             if (empty($email)) {
                 continue;
             }
             // only accepted
             foreach ($accepted as $row) {
                 $accepted_alternate[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'ACCEPTED');
             }
             // only alternated
             foreach ($alternate as $row) {
                 $accepted_alternate[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'ALTERNATE');
             }
             continue;
         }
         if ($accepted->count() > 0 && $rejected->count() > 0 && $alternate->count() === 0) {
             if (!$speaker->Member()) {
                 continue;
             }
             $email = $speaker->Member()->Email;
             if (empty($email)) {
                 continue;
             }
             // accepted and rejected
             foreach ($accepted as $row) {
                 $accepted_rejected[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'ACCEPTED');
             }
             foreach ($rejected as $row) {
                 $accepted_rejected[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'REJECTED');
             }
             continue;
         }
         if ($accepted->count() === 0 && $rejected->count() > 0 && $alternate->count() > 0) {
             if (!$speaker->Member()) {
                 continue;
             }
             $email = $speaker->Member()->Email;
             if (empty($email)) {
                 continue;
             }
             foreach ($alternate as $row) {
                 $alternate_rejected[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'ALTERNATE');
             }
             foreach ($rejected as $row) {
                 $alternate_rejected[] = array('PresentationID' => $row->ID, 'PresentationTitle' => $row->Title, 'SpeakerEmail' => $speaker->Member()->Email, 'SpeakerID' => $speaker->Member()->ID, 'Status' => 'REJECTED');
             }
             continue;
         }
     }
     switch ($type) {
         case 1:
             $filename = 'only_accepted_speakers.cvs';
             $result = $only_accepted;
             break;
         case 2:
             $filename = 'only_alternate_speakers.cvs';
             $result = $only_alternate;
             break;
         case 3:
             $filename = 'only_rejected_speakers.cvs';
             $result = $only_rejected;
             break;
         case 4:
             $filename = 'accepted_alternate_speakers.cvs';
             $result = $accepted_alternate;
             break;
         case 5:
             $filename = 'accepted_rejected_speakers.cvs';
             $result = $accepted_rejected;
             break;
         case 6:
             $filename = 'alternate_rejected_speakers.cvs';
             $result = $alternate_rejected;
             break;
     }
     CSVExporter::getInstance()->export($filename, $result);
 }
Esempio n. 13
0
 /**
  * @param ISummit $summit
  * @param array $event_data
  * @return mixed
  */
 public function updateEvent(ISummit $summit, array $event_data)
 {
     $event_repository = $this->event_repository;
     return $this->tx_service->transaction(function () use($summit, $event_data, $event_repository) {
         if (!isset($event_data['id'])) {
             throw new EntityValidationException(array('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(array('event doest not belongs to summit'));
         }
         $event->Title = $event_data['title'];
         $event->Description = $event_data['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 = intval($event_data['event_type']);
         $event->AllowedSummitTypes()->setByIDList($event_data['summit_type']);
         $event->Tags()->setByIDList(explode(',', $event_data['tags']));
         $event->Sponsors()->setByIDList(explode(',', $event_data['sponsors']));
         // Speakers, if one of the added members is not a speaker, we need to make him one
         if ($event->isPresentation()) {
             $presentation = $event_repository->getPresentationById($event_id);
             $speaker_ids = array();
             $member_ids = explode(',', $event_data['speakers']);
             foreach ($member_ids as $member_id) {
                 $speaker = PresentationSpeaker::get()->filter('MemberID', $member_id)->first();
                 if (!$speaker) {
                     $member = Member::get()->byID($member_id);
                     $speaker = new PresentationSpeaker();
                     $speaker->FirstName = $member->FirstName;
                     $speaker->LastName = $member->Surname;
                     $speaker->MemberID = $member->ID;
                     $speaker->write();
                 }
                 $speaker_ids[] = $speaker->ID;
             }
             $event->Speakers()->setByIDList($speaker_ids);
         }
         return $event;
     });
 }
 /**
  * @return PresentationSpeaker|null
  */
 public function getSpeakerProfile()
 {
     return PresentationSpeaker::get()->filter(array('MemberID' => $this->owner->ID))->first();
 }
 private function getSpeaker($email)
 {
     $speaker = PresentationSpeaker::get()->filter(array('Member.Email' => $email, 'SummitID' => Summit::get_active()->ID))->first();
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('Member.SecondEmail' => $email, 'SummitID' => Summit::get_active()->ID))->first();
     }
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('Member.ThirdEmail' => $email, 'SummitID' => Summit::get_active()->ID))->first();
     }
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('RegistrationRequest.Email' => $email, 'RegistrationRequest.IsConfirmed' => false, 'SummitID' => Summit::get_active()->ID))->first();
     }
     return $speaker;
 }
 /**
  * Handles requests that update speakers attached to this presentation
  * and hands them off to a sub-sub controller
  * @param   $r SS_HTTPRequest
  * @return  RequestHandler
  */
 public function handleSpeaker(SS_HTTPRequest $r)
 {
     if ($r->param('SpeakerID') === 'new') {
         $speaker = PresentationSpeaker::create();
     } else {
         $speaker = PresentationSpeaker::get()->filter(array('ID' => $r->param('SpeakerID')))->first();
     }
     if (!$speaker) {
         return $this->httpError(404, 'Speaker not found');
     }
     if ($speaker->isInDB() && (!$speaker->Presentations()->byID($this->presentation->ID) && $this->presentation->ModeratorID != $speaker->ID)) {
         return $this->httpError(403, 'That speaker is not part of this presentation');
     }
     $request = PresentationPage_ManageSpeakerRequest::create($speaker, $this);
     return $request->handleRequest($r, DataModel::inst());
 }
 /**
  * @param string $email
  * @return IPresentationSpeaker
  */
 public function getByEmail($email)
 {
     $speaker = PresentationSpeaker::get()->filter(array('Member.Email' => $email))->first();
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('Member.SecondEmail' => $email))->first();
     }
     if (is_null($speaker)) {
         $speaker = PresentationSpeaker::get()->filter(array('Member.ThirdEmail' => $email))->first();
     }
     if (is_null($speaker)) {
         $registration_request = SpeakerRegistrationRequest::get()->filter(array('Email' => $email, 'IsConfirmed' => 0))->first();
         if (!is_null($registration_request)) {
             $speaker = $registration_request->Speaker();
         }
     }
     return $speaker;
 }
 function addAction($data, $form)
 {
     //Check for a logged in member
     if ($CurrentMember = Member::currentUser()) {
         // Find a site member (in any group) based on the MemberID field
         $id = Convert::raw2sql($data['MemberID']);
         $member = DataObject::get_by_id("Member", $id);
         if ($data['SpeakerID'] && is_numeric($data['SpeakerID'])) {
             $speaker = PresentationSpeaker::get()->byID(intval($data['SpeakerID']));
         } elseif ($member) {
             $speaker = PresentationSpeaker::get()->filter('MemberID', $member->ID)->first();
         }
         if (!$speaker) {
             $speaker = new PresentationSpeaker();
         }
         //Find or create the 'speaker' group
         if (!($userGroup = DataObject::get_one('Group', "Code = 'speakers'"))) {
             $userGroup = new Group();
             $userGroup->Code = "speakers";
             $userGroup->Title = "Speakers";
             $userGroup->Write();
             $member->Groups()->add($userGroup);
         }
         //Add member to the group
         $member->Groups()->add($userGroup);
         if ($data['Country'] != '' && $data['Country'] != $member->Country) {
             $member->Country = convert::raw2sql($data['Country']);
         }
         if ($data['ReplaceName'] == 1) {
             $member->FirstName = $data['FirstName'];
         }
         if ($data['ReplaceSurname'] == 1) {
             $member->Surname = $data['LastName'];
         }
         if ($data['ReplaceBio'] == 1) {
             $member->Bio = $data['Bio'];
         }
         $member->write();
         $form->saveInto($speaker);
         $speaker->MemberID = $member->ID;
         $speaker->AdminID = Member::currentUser()->ID;
         // Attach Photo
         if ($member->PhotoID && $speaker->PhotoID == 0) {
             $speaker->PhotoID = $member->PhotoID;
         }
         $speaker->AskedAboutBureau = TRUE;
         $speaker->write();
         $this->controller->redirect($this->controller()->Link() . 'speaker?saved=1');
     } else {
         return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
     }
 }
 public function FilterForm()
 {
     return Form::create($this, "FilterForm", FieldList::create()->text('Keywords')->dropdown('Category')->configure()->setSource(PresentationCategory::get()->map('ID', 'Title'))->setEmptyString('-- Any category --')->end()->dropdown('Speaker')->configure()->setSource(PresentationSpeaker::get()->map('ID', 'Title'))->setEmptyString('-- Any speaker --')->end()->dropdown('Summit')->configure()->setSource(Summit::get()->map('ID', 'Title'))->setEmptyString('-- Any summit --')->end(), FieldList::create(FormAction::create('doSearch', 'Search')))->disableSecurityToken()->setFormAction($this->Link())->loadDataFrom($_REQUEST)->setFormMethod('GET');
 }
 /**
  * Reverses the migration
  */
 public function doDown()
 {
     foreach (Presentation::get()->filter('Legacy', true) as $p) {
         $p->Speakers()->setByIdList(array());
         foreach ($p->Materials()->filter('ClassName', 'PresentationVideo') as $material) {
             echo "Deleted video # " . $material->ID . $this->br();
             $material->delete();
         }
         echo "Deleted presentation # " . $p->ID . $this->br();
         $p->delete();
     }
     if (!Presentation::get()->filter('Legacy', true)->exists()) {
         echo "Deleted all legacy presentations" . $this->br();
     } else {
         echo "*** FAIL: Did not delete all legacy presentations" . $this->br();
     }
     foreach (PresentationSpeaker::get()->filter('Notes', '[LEGACY]') as $speaker) {
         $speaker->delete();
     }
     if (!PresentationSpeaker::get()->filter('Notes', '[LEGACY]')->exists()) {
         echo "Deleted all legacy speakers" . $this->br();
     } else {
         echo "*** FAIL: Did not delete all legacy speakers" . $this->br();
     }
     Summit::get()->filter('Title', ['San Diego', 'Portland', 'Atlanta'])->removeAll();
     if (!Summit::get()->filter('Title', ['San Diego', 'Portland', 'Atlanta'])->exists()) {
         echo "Deleted legacy summits" . $this->br();
     } else {
         echo "*** FAIL: Did not delete legacy summits" . $this->br();
     }
 }
 function addAction($data, $form)
 {
     //Check for a logged in member
     if ($CurrentMember = Member::currentUser()) {
         // Find a site member (in any group) based on the MemberID field
         $id = Convert::raw2sql($data['MemberID']);
         $member = DataObject::get_by_id("Member", $id);
         if ($data['SpeakerID'] && is_numeric($data['SpeakerID'])) {
             $speaker = PresentationSpeaker::get()->byID(intval($data['SpeakerID']));
         } elseif ($member) {
             $speaker = PresentationSpeaker::get()->filter('MemberID', $member->ID)->first();
         }
         if (!$speaker) {
             $speaker = new PresentationSpeaker();
         }
         //Find or create the 'speaker' group
         if (!($userGroup = DataObject::get_one('Group', "Code = 'speakers'"))) {
             $userGroup = new Group();
             $userGroup->Code = "speakers";
             $userGroup->Title = "Speakers";
             $userGroup->Write();
             $member->Groups()->add($userGroup);
         }
         //Add member to the group
         $member->Groups()->add($userGroup);
         if ($data['Country'] != '' && $data['Country'] != $member->Country) {
             $member->Country = convert::raw2sql($data['Country']);
         }
         if ($data['ReplaceName'] == 1) {
             $member->FirstName = $data['FirstName'];
         }
         if ($data['ReplaceSurname'] == 1) {
             $member->Surname = $data['LastName'];
         }
         if ($data['ReplaceBio'] == 1) {
             $member->Bio = $data['Bio'];
         }
         $member->write();
         $form->saveInto($speaker);
         $speaker->MemberID = $member->ID;
         $speaker->AdminID = Member::currentUser()->ID;
         // Attach Photo
         if ($member->PhotoID && $speaker->PhotoID == 0) {
             $speaker->PhotoID = $member->PhotoID;
         }
         $speaker->AskedAboutBureau = TRUE;
         // Languages
         foreach ($speaker->Languages() as $currentlang) {
             $currentlang->delete();
         }
         foreach ($data['Language'] as $lang) {
             if (trim($lang) != '') {
                 $spoken_lang = SpeakerLanguage::create(array('Language' => $lang));
                 $speaker->Languages()->add($spoken_lang);
             }
         }
         // Expertise
         $speaker->AreasOfExpertise()->removeAll();
         foreach ($data['Expertise'] as $exp) {
             if (trim($exp) != '') {
                 $expertise = SpeakerExpertise::create(array('Expertise' => $exp));
                 $speaker->AreasOfExpertise()->add($expertise);
             }
         }
         // Presentation Link
         $speaker->OtherPresentationLinks()->removeAll();
         foreach ($data['PresentationLink'] as $key => $link) {
             if (trim($link) != '') {
                 $presentation_title = trim($data['PresentationTitle'][$key]);
                 $presentation_link = SpeakerPresentationLink::create(array('LinkUrl' => $link, 'Title' => $presentation_title));
                 $speaker->OtherPresentationLinks()->add($presentation_link);
             }
         }
         // Travel Preferences
         $speaker->TravelPreferences()->removeAll();
         foreach ($data['CountriesToTravel'] as $travel_country) {
             $travel_pref = SpeakerTravelPreference::create(array('Country' => $travel_country));
             $speaker->TravelPreferences()->add($travel_pref);
         }
         $speaker->write();
         $form->sessionMessage('Your profile has been updated', 'good');
         Session::clear("FormInfo.{$form->FormName()}.data", $data);
         return $this->controller()->redirectBack();
     } else {
         return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
     }
 }
 /**
  * @param array $params
  * @return array
  */
 public function getSpeakers($params = [])
 {
     $start = isset($params['start']) ? $params['start'] : 0;
     $speakers = PresentationSpeaker::get()->innerJoin('Presentation_Speakers', 'Presentation_Speakers.PresentationSpeakerID = PresentationSpeaker.ID')->innerJoin('Presentation', 'Presentation.ID = Presentation_Speakers.PresentationID')->innerJoin('PresentationMaterial', 'PresentationMaterial.PresentationID = Presentation.ID')->innerJoin('PresentationVideo', 'PresentationVideo.ID = PresentationMaterial.ID')->sort('COUNT(Presentation_Speakers.ID) DESC')->alterDataQuery(function ($query) {
         $query->groupby('PresentationSpeaker.ID');
     });
     if (isset($params['letter'])) {
         $speakers = $speakers->filter('LastName:StartsWith', $params['letter'])->sort('LastName ASC');
     }
     $total = $speakers->count();
     $speakers = $speakers->limit(SummitVideoApp::config()->default_speaker_limit, $start);
     $hasMore = $total > $start + $speakers->count();
     $response = ['results' => [], 'has_more' => $hasMore, 'total' => $total];
     foreach ($speakers as $s) {
         $response['results'][] = $this->createSpeakerJSON($s);
     }
     return $response;
 }
Esempio n. 23
0
 function SaveProfile($data, $form)
 {
     //Check for a logged in member
     if ($CurrentMember = Member::currentUser()) {
         //Check for another member with the same email address
         if (Member::get()->filter(array('Email' => Convert::raw2sql($data['Email']), 'ID:not' => $CurrentMember->ID))->count() > 0) {
             $form->addErrorMessage("Email", 'Sorry, that email address already exists.', "bad");
             Session::set("FormInfo.Form_EditProfileForm.data", $data);
             return $this->redirect($this->Link('?error=1'));
         } else {
             // Clean up bio
             if ($data["Bio"]) {
                 $config = HTMLPurifier_Config::createDefault();
                 // Remove any CSS or inline styles
                 $config->set('CSS.AllowedProperties', array());
                 $purifier = new HTMLPurifier($config);
                 $cleanedBio = $purifier->purify($data["Bio"]);
             }
             $form->saveInto($CurrentMember);
             if (isset($cleanedBio)) {
                 $CurrentMember->Bio = $cleanedBio;
             }
             if ($data['Gender'] == 'Specify') {
                 $CurrentMember->Gender = $data['GenderSpecify'];
             }
             if ($CurrentMember->isChanged('Email')) {
                 $sender = new MemberRegistrationSenderService();
                 $sender->send($CurrentMember->resetConfirmation());
             }
             $CurrentMember->write();
             $speaker = PresentationSpeaker::get()->filter('MemberID', $CurrentMember->ID)->first();
             if ($speaker) {
                 if ($data['ReplaceName'] == 1) {
                     $speaker->FirstName = $data['FirstName'];
                 }
                 if ($data['ReplaceSurname'] == 1) {
                     $speaker->Surname = $data['Surname'];
                 }
                 if ($data['ReplaceBio'] == 1) {
                     $speaker->Bio = $data['Bio'];
                 }
                 $speaker->write();
             }
             // If they do not have a photo uploaded, but they have provided a twitter URL, attempt to grab a photo from twitter
             if ($CurrentMember->TwitterName && !$CurrentMember->Photo()->Exists()) {
                 $this->ProfilePhotoFromTwitter($CurrentMember);
             }
             return $this->redirect($this->Link('?saved=1'));
         }
     } else {
         return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
     }
 }
Esempio n. 24
0
 public function results()
 {
     $empty_search = true;
     $where_string = "PresentationSpeaker.AvailableForBureau = 1";
     if ($spoken_language = $this->getSearchQuery('spoken_language')) {
         $empty_search = false;
         $languages = "'" . implode("','", $spoken_language) . "'";
         $where_string .= " AND SpeakerLanguage.Language IN ({$languages})";
     }
     if ($country_origin = $this->getSearchQuery('country_origin')) {
         $empty_search = false;
         $countries = "'" . implode("','", $country_origin) . "'";
         $where_string .= " AND Countries.Name IN ({$countries})";
     }
     if ($travel_preference = $this->getSearchQuery('travel_preference')) {
         $empty_search = false;
         $preferences = "'" . implode("','", $travel_preference) . "'";
         $where_string .= " AND Countries2.Name IN ({$preferences})";
     }
     if ($query = $this->getSearchQuery('search_query')) {
         $empty_search = false;
         $where_string .= " AND (PresentationSpeaker.FirstName LIKE '%{$query}%' OR PresentationSpeaker.LastName LIKE '%{$query}%'\n                          OR CONCAT_WS(' ',PresentationSpeaker.FirstName,PresentationSpeaker.LastName) LIKE '%{$query}%'\n                          OR CONCAT_WS(', ',PresentationSpeaker.LastName,PresentationSpeaker.FirstName) LIKE '%{$query}%'\n                          OR SpeakerExpertise.Expertise LIKE '%{$query}%' OR Org.Name LIKE '%{$query}%')";
     }
     //die($where_string);
     if (!$empty_search) {
         $Results = PresentationSpeaker::get()->leftJoin("SpeakerExpertise", "SpeakerExpertise.SpeakerID = PresentationSpeaker.ID")->leftJoin("Countries", "Countries.Code = PresentationSpeaker.Country")->leftJoin("Member", "Member.ID = PresentationSpeaker.MemberID")->leftJoin("Affiliation", "Affiliation.MemberID = Member.ID")->leftJoin("Org", "Org.ID = Affiliation.OrganizationID")->leftJoin("SpeakerLanguage", "SpeakerLanguage.SpeakerID = PresentationSpeaker.ID")->leftJoin("SpeakerTravelPreference", "SpeakerTravelPreference.SpeakerID = PresentationSpeaker.ID")->leftJoin("Countries", "Countries2.Code = SpeakerTravelPreference.Country", "Countries2")->where($where_string);
         // No Member was found
         if (!isset($Results) || $Results->count() == 0) {
             return $this->customise($Results);
         }
         // If there is only one person with this name, go straight to the resulting profile page
         if ($Results && $Results->Count() == 1) {
             $this->redirect($this->Link() . 'profile/' . $Results->First()->ID);
         }
         $Output = new ArrayData(array('Title' => 'Results', 'Results' => $Results));
         if ($Results->count() == 0) {
             $message = $this->getViewer('results')->process($this->customise($Output));
             $this->response->setBody($message);
             throw new SS_HTTPResponse_Exception($this->response, 404);
         }
         return $this->customise($Output);
     }
     $this->redirect($this->Link());
 }
Esempio n. 25
0
 public function results()
 {
     if ($query = $this->getSearchQuery()) {
         // Search for only foundation members (Group 5) against the query.
         $filter = "FirstName LIKE '%{$query}%'\n\t\t\t\t\tOR LastName LIKE '%{$query}%'\n\t\t\t\t\tOR IRCHandle LIKE '%{$query}%'";
         $Results = PresentationSpeaker::get()->where($filter);
         // No Member was found
         if (!isset($Results) || $Results->count() == 0) {
             return $this->customise($Results);
         }
         // For AutoComplete
         if (Director::is_ajax()) {
             $Speakers = $Results->map('ID', 'Name');
             $Suggestions = '';
             foreach ($Speakers as $Speaker) {
                 $Suggestions = $Suggestions . $Speaker . '|' . '1' . "\n";
             }
             return $Suggestions;
         } else {
             $filter = "FirstName LIKE '%{$query}%'\n\t\t\t\t\tOR LastName LIKE '%{$query}%'\n\t\t\t\t\tOR IRCHandle LIKE '%{$query}%'";
             $OneSpeaker = PresentationSpeaker::get()->where($filter);
             // see if one member exactly matches the search term
             if ($OneSpeaker) {
                 $Results = $OneSpeaker;
             }
             // If there is only one person with this name, go straight to the resulting profile page
             if ($OneSpeaker && $OneSpeaker->Count() == 1) {
                 $this->redirect($this->Link() . 'profile/' . $OneSpeaker->First()->ID);
             }
             $Output = new ArrayData(array('Title' => 'Results', 'Results' => $Results));
             if ($Results->count() == 0) {
                 $message = $this->getViewer('results')->process($this->customise($Output));
                 $this->response->setBody($message);
                 throw new SS_HTTPResponse_Exception($this->response, 404);
             }
             return $this->customise($Output);
         }
     }
     $this->redirect($this->Link());
 }
 /**
  * Gets the speaker for this member in the current summit
  * 
  * @param  Summit $summit
  * @return PresentationSpeaker
  */
 public function getCurrentSpeakerProfile($summit = null)
 {
     $summit = $summit ?: Summit::get_active();
     if (!$summit) {
         return false;
     }
     return PresentationSpeaker::get()->filter(array('MemberID' => $this->owner->ID, 'SummitID' => $summit->ID))->first();
 }
Esempio n. 27
0
 /**
  * @param ISummitEvent $event
  * @param array $event_data
  * @return ISummitEvent
  * @throws NotFoundEntityException
  * @throws ValidationException
  * @throws null
  */
 public static function updatePresentation(ISummitEvent $event, array $event_data)
 {
     // Speakers, if one of the added members is not a speaker, we need to make him one
     if ($event instanceof Presentation) {
         foreach ($event_data['speakers'] as $speaker) {
             if (!isset($speaker['speaker_id']) || !isset($speaker['member_id'])) {
                 throw new EntityValidationException('missing parameter on speakers collection!');
             }
             $speaker_id = intval($speaker['speaker_id']);
             $member_id = intval($speaker['member_id']);
             $speaker = $speaker_id > 0 ? PresentationSpeaker::get()->byID($speaker_id) : null;
             $speaker = is_null($speaker) && $member_id > 0 ? PresentationSpeaker::get()->filter('MemberID', $member_id)->first() : $speaker;
             if (is_null($speaker)) {
                 $member = Member::get()->byID($member_id);
                 if (is_null($member)) {
                     throw new NotFoundEntityException('Member', sprintf(' member id %s', $member_id));
                 }
                 $speaker = new PresentationSpeaker();
                 $speaker->FirstName = $member->FirstName;
                 $speaker->LastName = $member->Surname;
                 $speaker->MemberID = $member->ID;
                 $speaker->write();
             }
             $speaker_ids[] = $speaker->ID;
             $event->ModeratorID = 0;
         }
         $event->Speakers()->setByIDList($speaker_ids);
         if ($event->Type()->Type == 'Keynotes' || $event->Type()->Type == 'Panel') {
             if (!isset($event_data['moderator'])) {
                 throw new EntityValidationException('moderator is required!');
             }
             $moderator = $event_data['moderator'];
             if (!isset($moderator['member_id']) || !isset($moderator['speaker_id'])) {
                 throw new EntityValidationException('missing parameter on moderator!');
             }
             $speaker_id = intval($moderator['speaker_id']);
             $member_id = intval($moderator['member_id']);
             $moderator = $speaker_id > 0 ? PresentationSpeaker::get()->byID($speaker_id) : null;
             $moderator = is_null($moderator) && $member_id > 0 ? PresentationSpeaker::get()->filter('MemberID', $member_id)->first() : $moderator;
             if (is_null($moderator)) {
                 $member = Member::get()->byID($member_id);
                 if (is_null($member)) {
                     throw new NotFoundEntityException('Member', sprintf(' member id %s', $member_id));
                 }
                 $moderator = PresentationSpeaker::create();
                 $moderator->FirstName = $member->FirstName;
                 $moderator->LastName = $member->Surname;
                 $moderator->MemberID = $member->ID;
                 $moderator->write();
             }
             $event->ModeratorID = $moderator->ID;
         }
         $track = PresentationCategory::get()->byID(intval($event_data['track']));
         if (is_null($track)) {
             throw new NotFoundEntityException('Track');
         }
         $event->CategoryID = $track->ID;
         $event->AttendeesExpectedLearnt = html_entity_decode($event_data['expect_learn']);
         $event->Level = $event_data['level'];
     }
     return $event;
 }