public function formAction() { // Get the document info from the session. $session = new Zend_Session_Namespace('Publish'); if (!isset($session, $session->depositConfirmDocumentId)) { throw new Application_Exception('Cannot find document Id to print form for.'); } // initialize document model $docId = $session->depositConfirmDocumentId; $documentModel = new Matheon_Model_Document($docId); $documentModel->requireServerState('unpublished'); $documentModel->requireSubmitterIsCurrentUser(); $this->view->docId = $docId; // Initialize form. $reviewerForm = new Matheon_Form_ChooseReviewer(); $reviewerForm->setMethod('POST')->setAction($this->_helper->url('form'))->setReviewerOptions($this->__fetchReviewers()); // Check data. $request = $this->getRequest(); if (!$request->isPost() or !$reviewerForm->isValid($request->getPost())) { $this->view->reviewerForm = $reviewerForm; return; } // Process query. $reviewerId = $reviewerForm->getReviewerId(); $documentModel->storeEnrichmentKeyValue('reviewer.user_id', $reviewerId); $documentModel->addReadFilePrivilege('reviewer'); $documentModel->store(); // Send publish notification. $reviewerAccount = new Opus_Account($reviewerId); $recipients = array_unique(array('admin', strtolower($reviewerAccount->getLogin()))); $this->getLogger()->debug('sending messages to users (' . implode(",", $recipients) . ')'); if ($this->__sendPublishNotification($documentModel, $recipients)) { $this->view->success = true; } return $this->render('confirm'); }
public function testRequireServerStateExceptionOnFail() { $mmd = new Matheon_Model_Document(1); $this->setExpectedException('Application_Exception'); $mmd->requireServerState('unpublished'); }