/**
  * Hand off presentation CRUD to a sub controller. Ensure the user
  * can write to the presentation first
  * @param   $r SS_HTTPRequest
  * @return  RequestHandler
  */
 public function handleManage(SS_HTTPRequest $r)
 {
     $summit = $this->Summit();
     if (is_null($summit) || $summit->ID == 0 || !$summit->isPresentationEditionAllowed()) {
         return $this->httpError(403, 'Call for speaker closed!');
     }
     if ($r->param('PresentationID') === 'new') {
         if (Member::currentUser()->getSpeakerProfile()->hasReachPresentationLimitBy($summit->ID)) {
             return $this->httpError(403, "You reached presentations submissions limit");
         }
         $presentation = Presentation::create();
         $presentation->SummitID = $summit->ID;
         $presentation->CreatorID = Member::currentUserID();
         $presentation->write();
         return $this->redirect($presentation->EditLink());
     } else {
         $presentation = Presentation::get()->byID($r->param('PresentationID'));
     }
     if (!$presentation) {
         return $this->httpError(404);
     }
     if ($presentation->isInDB() && !$presentation->canEdit()) {
         return $this->httpError(403, "You can't edit this presentation");
     }
     if (!$presentation->isInDB() && !$presentation->canCreate()) {
         return $this->httpError(403);
     }
     $request = PresentationPage_ManageRequest::create($presentation, $this);
     return $request->handleRequest($r, DataModel::inst());
 }
 /**
  * Hand off presentation CRUD to a sub controller. Ensure the user
  * can write to the presentation first
  * 
  * @param   $r SS_HTTPRequest
  * @return  RequestHandler
  */
 public function handleManage(SS_HTTPRequest $r)
 {
     if ($r->param('PresentationID') === 'new') {
         $presentation = Presentation::create();
         $presentation->CreatorID = Member::currentUserID();
         $presentation->write();
         return $this->redirect($presentation->EditLink());
     } else {
         $presentation = Presentation::get()->byID($r->param('PresentationID'));
     }
     if (!$presentation) {
         return $this->httpError(404);
     }
     if ($presentation->isInDB() && !$presentation->canEdit()) {
         return $this->httpError(403, "You can't edit this presentation");
     }
     if (!$presentation->isInDB() && !$presentation->canCreate()) {
         return $this->httpError(403);
     }
     $request = PresentationPage_ManageRequest::create($presentation, $this);
     return $request->handleRequest($r, DataModel::inst());
 }
 /**
  * Hand off presentation CRUD to a sub controller. Ensure the user
  * can write to the presentation first
  * @param   $r SS_HTTPRequest
  * @return  RequestHandler
  */
 public function handleManage(SS_HTTPRequest $r)
 {
     $summit = $this->Summit();
     if (is_null($summit) || !$summit->exists() || !$this->presentation_manager->isPresentationEditionAllowed(Member::currentUser(), $summit)) {
         $r->setUrl($this->Link());
         //clean up dir parts so we could redirect without 404
         return $this->redirect($this->Link(), 301);
     }
     $presentation_id = Convert::raw2sql($r->param('PresentationID'));
     $presentation = $presentation_id === 'new' ? Presentation::create() : Presentation::get()->byID($presentation_id);
     if (!$presentation) {
         return $this->httpError(404);
     }
     if ($presentation->isInDB() && !$this->canEditPresentation($presentation->ID)) {
         return $this->httpError(403, "You can't edit this presentation");
     }
     if (!$presentation->isInDB() && !$presentation->canCreate()) {
         return $this->httpError(403);
     }
     $request = PresentationPage_ManageRequest::create($presentation, $this);
     return $request->handleRequest($r, DataModel::inst());
 }