예제 #1
0
 /**
  * Allows a user access to download a document from a workshop
  *
  */
 public function downloadDocumentAction()
 {
     $get = Zend_Registry::get('getFilter');
     if (!isset($get->workshopDocumentId)) {
         throw new Ot_Exception_Input('msg-error-workshopIdsNotSet');
     }
     $document = new Workshop_Document();
     $thisDocument = $document->find($get->workshopDocumentId);
     if (is_null($thisDocument)) {
         throw new Ot_Exception_Data('msg-error-noDocument');
     }
     $config = Zend_Registry::get('config');
     if (!is_readable($config->user->fileUploadPathWorkshop->val)) {
         throw new Ot_Exception_Data('msg-error-targetDirNotReadable');
     }
     $target = $config->user->fileUploadPathWorkshop->val . '/' . $thisDocument->workshopId . '/' . $thisDocument->name;
     if (!is_file($target)) {
         throw new Ot_Exception_Data('msg-error-fileNotFound');
     }
     $this->_helper->viewRenderer->setNeverRender();
     $this->view->layout()->disableLayout();
     header('Content-Type: application/octetstream');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; ' . 'filename="' . $thisDocument->name . '"');
     readfile($target);
 }