示例#1
0
 public function testStoreEnrichmentKeyValueSkipDuplicate()
 {
     $doc = $this->createTestDocument();
     $docId = $doc->store();
     $this->assertEquals(0, count($doc->getEnrichment()));
     $mmd = new Matheon_Model_Document($docId);
     $mmd->storeEnrichmentKeyValue('reviewer.user_id', 123);
     $mmd->storeEnrichmentKeyValue('reviewer.user_id', 124);
     $mmd->storeEnrichmentKeyValue('reviewer.user_id', 123);
     $mmd->store();
     $doc = new Opus_Document($docId);
     $this->assertEquals(2, count($doc->getEnrichment()));
 }
 /**
  *
  * @param Matheon_Model_Document $document
  * @param array $recipient
  * @return void
  */
 private function __sendPublishNotification($document, $recipient)
 {
     $config = $this->getConfig();
     $baseUrlFiles = $this->view->serverUrl() . '/opus4-matheon/files';
     $job = new Opus_Job();
     $job->setLabel(Opus_Job_Worker_MailNotification::LABEL);
     $job->setData(array('subject' => $document->renderPublishMailSubject(), 'message' => $document->renderPublishMailBody($this->view->fullUrl(), $baseUrlFiles), 'users' => $recipient));
     //throw new Exception(var_export($job, true));
     if (isset($config->runjobs->asynchronous) && $config->runjobs->asynchronous) {
         // Queue job (execute asynchronously)
         // skip creating job if equal job already exists
         if (true === $job->isUniqueInQueue()) {
             $job->store();
         }
         return true;
     }
     // Execute job immediately (synchronously)
     try {
         $mail = new Opus_Job_Worker_MailNotification($this->getLogger());
         $mail->work($job);
     } catch (Exception $exc) {
         $this->getLogger()->err($exc);
     }
     return true;
 }