/**
  * Initialize custom document fields.
  *
  * @return void
  */
 protected function initializeDocument()
 {
     $loggedUserModel = new Publish_Model_LoggedUser();
     $userId = trim($loggedUserModel->getUserId());
     if (empty($userId)) {
         $logger = Zend_Registry::get('Zend_Log');
         $logger->debug("No user logged in.  Skipping enrichment.");
         return;
     }
     $this->getDocument()->addEnrichment()->setKeyName('submitter.user_id')->setValue($userId);
 }
 /**
  * Simple test.  Return NON-NULL if valid logged in.
  */
 public function testCreatePersonValidUser()
 {
     $accountName = 'foo-' . rand();
     $accountPassword = '******' . rand();
     $this->setZendAuthIdentity($accountName);
     $account = new Opus_Account();
     $account->setLogin($accountName)->setPassword($accountPassword)->store();
     $model = new Publish_Model_LoggedUser();
     $this->assertNotNull($model->getUserId());
     $person = $model->createPerson();
     $this->assertNotNull($person);
     $this->assertEquals($account->getId(), $model->getUserId());
 }
 public function testFormWithValidDocumentIdSubmitSetsReviewerRole()
 {
     $this->loginUser('referee', 'refereereferee');
     $loggedUserModel = new Publish_Model_LoggedUser();
     $loggedUserId = $loggedUserModel->getUserId();
     $docId = $this->createValidDocument($loggedUserId);
     $session = new Zend_Session_Namespace('Publish');
     $session->depositConfirmDocumentId = $docId;
     $this->request->setMethod('POST')->setPost(array('reviewerid' => $loggedUserId, 'submit' => 'Send'));
     $this->dispatch('/matheon/select-reviewer/form');
     $this->assertResponseCode(200);
     // Check, that right privilege has been set.
     $reviewer = Opus_UserRole::fetchByName('reviewer');
     $this->assertContains($docId, $reviewer->listAccessDocuments());
 }
 /**
  * Prepare document finder.
  *
  * @return Opus_DocumentFinder
  */
 protected function _prepareDocumentFinder()
 {
     $finder = new Opus_DocumentFinder();
     $finder->setServerState(self::$_reviewServerState);
     $logger = $this->getLogger();
     $userId = $this->_loggedUser->getUserId();
     $onlyReviewerByUserId = false;
     // Add constraint for reviewer, if current user is *not* admin.
     if (Opus_Security_Realm::getInstance()->checkModule('admin')) {
         $message = "Review: Showing all unpublished documents to admin";
         $logger->debug($message . " (user_id: {$userId})");
     } elseif (Opus_Security_Realm::getInstance()->checkModule('review')) {
         if ($onlyReviewerByUserId) {
             $message = "Review: Showing only documents belonging to reviewer";
             $finder->setEnrichmentKeyValue('reviewer.user_id', $userId);
         } else {
             $message = "Review: Showing all unpublished documents to reviewer";
         }
         $logger->debug($message . " (user_id: {$userId})");
     } else {
         $message = 'Review: Access to unpublished documents denied.';
         $logger->err($message . " (user_id: {$userId})");
         throw new Application_Exception($message);
     }
     return $finder;
 }
Esempio n. 5
0
 /**
  * Render body of notification mail.
  *
  * @param string $baseUrlServer
  * @param string $baseUrlFiles
  * @return string
  */
 public function renderPublishMailBody($baseUrlServer, $baseUrlFiles)
 {
     $baseUrlServer = preg_replace('/[\\/]+$/', '', $baseUrlServer);
     $baseUrlFiles = preg_replace('/[\\/]+$/', '', $baseUrlFiles);
     $loggedUserModel = new Publish_Model_LoggedUser();
     $person = $loggedUserModel->createPerson();
     $submitterString = '';
     if (!is_null($person) and $person->isValid()) {
         $submitterString = trim($person->getFirstName() . " " . $person->getLastName());
     }
     $titleModels = $this->_document->getTitleMain();
     $titleString = '';
     if (count($titleModels) > 0) {
         $titleString = trim($titleModels[0]->getValue());
     }
     $abstractModels = $this->_document->getTitleAbstract();
     $abstractString = '';
     if (count($abstractModels) > 0) {
         $abstractString = trim($abstractModels[0]->getValue());
     }
     $template = new Matheon_Model_Template();
     $template->template = APPLICATION_PATH . '/modules/matheon/models/confirmation-mail.template';
     return $template->render(array('baseUrlServer' => $baseUrlServer, 'baseUrlFiles' => $baseUrlFiles, 'docId' => $this->getId(), 'submitterString' => $submitterString, 'titleString' => $titleString, 'abstractString' => $abstractString, 'files' => $this->_document->getFile()));
 }
 public function debugAction()
 {
     $this->requirePrivilege('admin');
     $docId = $this->_getParam('docId');
     $document = new Opus_Document($docId);
     $document->setServerState('unpublished');
     $loggedUserModel = new Publish_Model_LoggedUser();
     $loggedUserId = $loggedUserModel->getUserId();
     $document->addEnrichment()->setKeyName('submitter.user_id')->setValue($loggedUserId);
     $document->store();
     $session = new Zend_Session_Namespace('Publish');
     $session->depositConfirmDocumentId = $docId;
 }