/** * @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); }