/** * Download a paper */ function downloadAction() { // The paper id should be a param $idPaper = $this->getRequest()->getParam('id_paper'); $paper = new Paper(); $paperRow = $paper->find($idPaper)->current(); // The file id should be here as well $idFile = $this->getRequest()->getParam('id_file'); $requiredFileTbl = new RequiredFile(); $requiredFileRow = $requiredFileTbl->find($idFile)->current(); if (!is_object($paperRow) or !is_object($requiredFileRow)) { // Raise an exception throw new Zmax_Exception("Author::download. Invalid call: ({$idPaper}, {$idFile})"); } if (!$paperRow->getAuthorByEmail($this->user->email) and !$paperRow->getReview($this->user->id) and !$this->user->isAdmin()) { throw new Zmax_Exception("Author::download. No access right ({$idPaper}, {$idFile})"); } $paperRow->download($requiredFileRow); }