コード例 #1
0
 function saveLink($data, $form)
 {
     $url = $data['HostedMediaURL'];
     $EventID = Session::get('UploadMedia.PresentationID');
     if ($EventID) {
         $Event = VideoPresentation::get()->byID($EventID);
     }
     // 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();
     } elseif (!$Event) {
         $data["HasError"] = TRUE;
         return $this->controller()->Customise($data);
     } else {
         $Event->HostedMediaURL = $url;
         $Event->MediaType = 'URL';
         $Event->write();
         Session::set('UploadMedia.Success', TRUE);
         Session::set('UploadMedia.URL', $url);
         Session::set('UploadMedia.Type', 'URL');
         Controller::curr()->redirect($form->controller()->link() . 'Success');
     }
 }
コード例 #2
0
ファイル: SchedSpeaker.php プロジェクト: rbowen/openstack-org
 function PresentationsWithoutMedia()
 {
     $Presentations = VideoPresentation::get()->filter('speakers:PartialMatch', $this->name);
     $MissingMedia = FALSE;
     if ($Presentations) {
         // Loop over each presentation and see if this speaker has one without either a link or an uploaded file.
         foreach ($Presentations as $Presentation) {
             if (!$Presentation->HostedMediaURL() && !$Presentation->UploadedMedia()) {
                 $MissingMedia = TRUE;
             }
         }
     }
     return $MissingMedia;
 }
コード例 #3
0
 public function handleSchedUpdate(SS_HTTPRequest $r)
 {
     if (!Member::currentUser()) {
         return $this->httpError(403);
     }
     $schedID = $r->param('SchedID');
     $presentation = VideoPresentation::get_by_event_key($schedID);
     if (!$presentation) {
         $presentation = VideoPresentation::create(array('event_key' => $schedID));
     }
     // Only allow one writeable property here
     if ($youTube = $r->postVar('youtubeid')) {
         $presentation->YouTubeID = $youTube;
         $presentation->write();
         return new SS_HTTPResponse("OK", 200);
     }
     return $this->httpError(400, "You must provide a youtubeid parameter in the POST request");
 }
コード例 #4
0
 /**
  * Syncs the local sessions to remote. Deletes any local sessions that no longer exist on remote
  * @param  array $sessions The session data from the API	 
  */
 protected function deleteSessions($sessions)
 {
     $i = 0;
     foreach (VideoPresentation::get() as $existing) {
         $found = false;
         foreach ($sessions as $sessionData) {
             if ($sessionData['id'] == $existing->SchedID) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $this->writeOut("Presentation {$existing->Title} no longer exists on remote. Deleting.");
             $existing->delete();
             $i++;
         }
     }
     $this->writeOut("{$i} presentations deleted.");
 }
コード例 #5
0
 function doUpload($data, $form)
 {
     if (isset($data['UploadedMedia']['tmp_name'])) {
         if (!empty($data['UploadedMedia']['name'])) {
             // create new single file array from file uploads array
             $file = array();
             $file['name'] = $data['UploadedMedia']['name'];
             $file['type'] = $data['UploadedMedia']['type'];
             $file['tmp_name'] = $data['UploadedMedia']['tmp_name'];
             $file['error'] = $data['UploadedMedia']['error'];
             $file['size'] = $data['UploadedMedia']['size'];
             // create & write uploaded file in DB
             try {
                 $newfile = new File();
                 $upload = new Upload();
                 // get folder from form upload field
                 $folder = $form->Fields()->fieldByName('UploadedMedia')->getFolderName();
                 $upload->loadIntoFile($file, $newfile, $folder);
                 $fileObj = $upload->getFile();
                 $EventID = Session::get('UploadMedia.PresentationID');
                 if ($EventID) {
                     $Event = VideoPresentation::get()->byID($EventID);
                 }
                 if (isset($Event)) {
                     $Event->UploadedMediaID = $fileObj->ID;
                     $Event->MediaType = 'File';
                     $Event->write();
                     Session::set('UploadMedia.Success', TRUE);
                     Session::set('UploadMedia.FileName', $fileObj->Name);
                     Session::set('UploadMedia.Type', 'File');
                     Controller::curr()->redirect($form->controller()->link() . 'Success');
                 }
             } catch (ValidationException $e) {
                 $form->sessionMessage('Extension not allowed...', 'bad');
                 return $this->controller()->redirectBack();
             }
         }
     }
 }
コード例 #6
0
 function Success()
 {
     $data = NULL;
     if (Session::get('UploadMedia.Success') == TRUE && ($PresentationID = Session::get('UploadMedia.PresentationID')) && ($Presentation = VideoPresentation::get()->byID($PresentationID))) {
         $data["Presentation"] = $Presentation;
         $data["Filename"] = Session::get('UploadMedia.FileName');
         $data["PresentationURL"] = Session::get('UploadMedia.URL');
         if (Session::get('UploadMedia.Type') == 'File') {
             $data['IsFile'] = TRUE;
         } else {
             $data['IsURL'] = TRUE;
         }
         Session::clear('UploadMedia.Success');
         Session::clear('UploadMedia.FileName');
         Session::clear('UploadMedia.URL');
         Session::clear('UploadMedia.Type');
         return $this->Customise($data);
     } else {
         $this->redirect($this->link() . 'Presentations');
     }
 }
コード例 #7
0
 /**
  * Performs the migration
  */
 public function doUp()
 {
     // We're mocking some stuff, e.g. Summit, Presentation, and we need some forgiveness here
     Config::inst()->update('DataObject', 'validation_enabled', false);
     // Add the old SD / Portland summits
     $this->ensureLegacySummits();
     echo $this->br(2);
     // Presentations weren't always SummitEvents, so the tables are out of sync.
     // Get the higer of the two ID increments to run a counter and force the ID.
     $maxSummitEventID = DB::query("SELECT MAX(ID) FROM SummitEvent")->value();
     $maxPresentationID = DB::query("SELECT MAX(ID) FROM Presentation")->value();
     $idCounter = max($maxSummitEventID, $maxPresentationID);
     $idCounter++;
     $total = VideoPresentation::get()->count();
     $i = 0;
     echo "Migrating VideoPresentations..." . $this->br(3);
     $presentationLookup = [];
     // Finding a potential presentation for the video can only be done on fuzzy matching
     // the title. Special characters in the title can defeat that matching, so this
     // loop creates a lookup of alphnumeric skus of the title for easier matching later.
     foreach (Summit::get() as $s) {
         $presentationLookup[$s->ID] = [];
         foreach ($s->Presentations()->sort('Title ASC') as $p) {
             $presentationLookup[$s->ID][strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $p->Title))] = $p->ID;
         }
     }
     foreach (VideoPresentation::get()->filter('DisplayOnSite', true) as $v) {
         $i++;
         $created = 0;
         echo "{$i} / {$total} ....";
         if (!$v->YouTubeID) {
             echo "No YouTubeID. Skipping." . $this->br();
             $this->stats['Presentations skipped']++;
             continue;
         }
         $v = $this->ensureSummitID($v);
         // Attempt to match a Presentation of the same name as the video
         $lookup = $presentationLookup[$v->SummitID];
         $cleanTitle = strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $v->Name));
         $originalPresentation = false;
         if (isset($lookup[$cleanTitle])) {
             $originalPresentation = Presentation::get()->byID($lookup[$cleanTitle]);
         }
         // If no Presentation exists, create a shell.
         if (!$originalPresentation) {
             echo "********* {$v->Name} has no original presentation." . $this->br();
             $v = $this->normaliseDateTime($v, 'StartTime');
             $v = $this->normaliseDateTime($v, 'EndTime');
             $originalPresentation = $this->createLegacyPresentation($idCounter, $v);
             $originalPresentation->write(false, true);
             $idCounter++;
             echo "Created presentation {$v->ID} -> {$originalPresentation->ID}...";
             $originalPresentation = $this->addLegacySpeakers($originalPresentation, $v);
             $this->stats['Presentations created']++;
         } else {
             echo "*** Original presentation found: " . $originalPresentation->ID . $this->br();
         }
         $material = $this->createLegacyVideoMaterial($originalPresentation, $v);
         $material->write();
         DB::query(sprintf("UPDATE PresentationMaterial SET Created = '%s', LastEdited = '%s' WHERE ID = '%s'", $v->LastEdited, $v->LastEdited, $material->ID));
         echo "Created video with date uploaded {$material->DateUploaded}." . $this->br();
     }
     echo $this->br(3);
     echo "Migration complete!" . $this->br(3);
     if (!empty($this->errors)) {
         echo "Warnings:" . $this->br();
         foreach ($this->errors as $summitID => $errors) {
             echo Summit::get()->byID($summitID)->Title . " (" . sizeof($errors) . ")" . $this->br();
             echo "----------------------------";
             echo $this->br(2);
             foreach ($errors as $e) {
                 echo "\t{$e}" . $this->br();
             }
         }
     }
     if (!empty($this->stats)) {
         echo $this->br(3);
         echo "Stats" . $this->br();
         echo "---------------------" . $this->br();
         foreach ($this->stats as $title => $stat) {
             echo "{$title}: {$stat}" . $this->br();
         }
     }
 }
コード例 #8
0
 function PresentationsForThisSpeaker()
 {
     $Presentations = VideoPresentation::get()->filter('speakers:PartialMatch', $this->name)->filter('SummitID', 5)->filter('IsKeynote', 0);
     return $Presentations;
 }
コード例 #9
0
 public function IsASpeaker($SpeakerID)
 {
     if (is_numeric($SpeakerID)) {
         $Speaker = SchedSpeaker::get()->byID($SpeakerID);
         // Check to see if the speaker is listed on this event
         if ($Speaker && $Speaker->name && VideoPresentation::get()->filter('speakers:PartialMatch', $this->name)->filter('ID', $this->ID)->count()) {
             return TRUE;
         }
     }
 }