/** * Create a PresentationVideo object for a presentation from a VideoPresentation * @param Presentation $p * @param VideoPresentation $v * @return PresentationVideo */ private function createLegacyVideoMaterial(Presentation $p, VideoPresentation $v) { return PresentationVideo::create(['PresentationID' => $p->ID, 'Name' => $v->Name, 'DisplayOnSite' => $v->DisplayOnSite, 'YouTubeID' => trim($v->YouTubeID), 'Featured' => $v->Featured, 'Created' => $v->LastEdited, 'LastEdited' => $v->LastEdited, 'DateUploaded' => $p->StartDate ?: $p->Summit()->SummitBeginDate]); }
public function handleApplyVideo(SS_HTTPRequest $r) { if (!Permission::check('VIDEO_UPLOADER')) { return $this->httpError(403, 'You do not have permission to use this method'); } // Only allow one writeable property here if ($youTube = $r->postVar('youtubeid')) { $video = $this->presentation->Materials()->filter('ClassName', 'PresentationVideo')->first(); if (!$video) { $video = PresentationVideo::create(); } $dateUTC = $this->presentation->Summit()->convertDateFromTimeZone2UTC(SS_DateTime::now()->Rfc2822()); $video->PresentationID = $this->presentation->ID; $video->DateUploaded = $dateUTC; $video->Name = $this->presentation->Title; $video->DisplayOnSite = true; $video->YouTubeID = $youTube; $video->write(); return new SS_HTTPResponse("OK", 200); } return $this->httpError(400, "You must provide a youtubeid parameter in the POST request"); }