/** * Create and initialize document object. * * @param type $documentType * @return Opus_Document */ public function createDocument($documentType) { $this->document = new Opus_Document(); $this->document->setServerState(self::DOCUMENT_STATE)->setType($documentType); $this->initializeDocument(); return $this->document; }
/** * Publishes documents and adds the given Person as referee. * * @param array $docIds * @param mixed $userId * @param Opus_Person $person * * FIXME capture success or failure for display afterwards */ public function clear(array $docIds = null, $userId = null, $person = null) { $logger = Zend_Registry::get('Zend_Log'); foreach ($docIds as $docId) { $logger->debug('Change state to "published" for document: ' . $docId); $document = new Opus_Document($docId); $document->setServerState('published'); $date = new Opus_Date(); $date->setNow(); $document->setServerDatePublished($date); $document->setPublishedDate($date); $guest_role = Opus_UserRole::fetchByName('guest'); foreach ($document->getFile() as $file) { $guest_role->appendAccessFile($file->getId()); } if (isset($person)) { $document->addPersonReferee($person); } $enrichment = $document->addEnrichment(); $enrichment->setKeyName('review.accepted_by')->setValue($userId); // TODO: Put into same transaction... $document->store(); $guest_role->store(); } return; }
public function testIndexActionOnTemporary() { $this->_document->setServerState('temporary')->store(); $doc_id = $this->_document->getId(); $this->dispatch('/frontdoor/index/index/docId/' . $doc_id); $this->assertResponseCode(403); $this->assertController('index'); $this->assertAction('index'); $response = $this->getResponse(); $this->assertContains('<div class="frontdoor-error">', $response->getBody()); }
return str_replace('STRING', $counter, $template); } // error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { echo "WARNING: myErrorHandler({$errno}, '{$errstr}', '{$errfile}', {$errline})\n"; return true; } // set to the user defined error handler $oldErrorHandler = set_error_handler("myErrorHandler"); // // Creating document, filling static fields. // $doc = new Opus_Document(); $doc->setType(randString($counter++)); $doc->setServerState('published'); $doc->setServerDatePublished('01.01.1900'); $doc->setLanguage('deu' . randString($counter++)); $doc->setThesisDateAccepted('01.02.2003'); $doc->setPublishedYear('2010'); $doc->setPublishedDate('28.09.2010'); $doc->setCompletedYear('2010'); $doc->setCompletedDate('27.09.2010'); $doc->setPublisherName(randString($counter++)); $doc->setPublisherPlace(randString($counter++)); $doc->setPageNumber(randString($counter++)); $doc->setPageFirst(randString($counter++)); $doc->setPageLast(randString($counter++)); $doc->setVolume(randString($counter++)); $doc->setIssue(randString($counter++)); $doc->setCreatingCorporation(randString($counter++));
private function processRow($row) { $doc = new Opus_Document(); $oldId = $row[self::OLD_ID]; try { $doc->setLanguage(trim($row[self::LANGUAGE])); // Dokumenttyp muss kleingeschrieben werden (bei Fromm aber groß) $doc->setType(lcfirst(trim($row[self::TYPE]))); $doc->setServerState(trim($row[self::SERVER_STATE])); $doc->setVolume(trim($row[self::VOL_ID])); // speichere die oldId als Identifier old ab, so dass später nach dieser gesucht werden kann // und die Verbindung zwischen Ausgangsdatensatz und importiertem Datensatz erhalten bleibt $this->addIdentifier($doc, 'old', $oldId); $this->processTitlesAndAbstract($row, $doc, $oldId); $this->processDate($row, $doc, $oldId); $this->processIdentifier($row, $doc, $oldId); $this->processNote($row, $doc, $oldId); $this->processCollections($row, $doc); $this->processLicence($row, $doc, $oldId); $this->processSeries($row, $doc); $this->processEnrichmentKindofpublication($row, $doc, $oldId); // TODO Fromm verwendet aktuell sieben Enrichments (muss noch generalisiert werden) $enrichementkeys = array(self::ENRICHMENT_AVAILABILITY, self::ENRICHMENT_FORMAT, self::ENRICHMENT_KINDOFPUBLICATION, self::ENRICHMENT_IDNO, self::ENRICHMENT_COPYRIGHTPRINT, self::ENRICHMENT_COPYRIGHTEBOOK, self::ENRICHMENT_RELEVANCE); foreach ($enrichementkeys as $enrichmentkey) { $this->processEnrichment($enrichmentkey, $row, $doc); } $file = $this->processFile($row, $doc, $oldId); $doc->store(); if (!is_null($file) && $file instanceof Opus_File && !is_null($this->_guestRole)) { $this->_guestRole->appendAccessFile($file->getId()); $this->_guestRole->store(); } } catch (Exception $e) { echo "import of document " . $oldId . " was not successful: " . $e->getMessage() . "\n"; } try { $this->processPersons($row, $doc, $oldId); $doc->store(); return true; } catch (Exception $e) { echo "import of person(s) for document " . $oldId . " was not successful: " . $e->getMessage() . "\n"; } return false; }
public function testGuestAccessToFileRegression3281() { $this->enableSecurity(); // test document access as user without access rights $doc = $this->createTestDocument(); $doc->setServerState('published'); $docId = $doc->store(); $this->tryAccessForDocument($docId, true); $doc = new Opus_Document($docId); $doc->setServerState('unpublished'); $docId = $doc->store(); $this->tryAccessForDocument($docId, false); }
/** * Performs state change on document. * @param Opus_Document $document * @param string $targetState * * TODO enforcing permissions and throwing exceptions (OPUSVIER-1959) */ public function changeState($document, $targetState) { switch ($targetState) { case 'deleted': $document->delete(); break; case 'removed': $document->deletePermanent(); break; default: $document->setServerState($targetState); $document->store(); break; } }
public function testDownloadActionWithUnpublishedDocument() { $doc = new Opus_Document($this->documentId); $doc->setServerState('unpublished'); $doc->store(); $this->dispatch('/citationExport/index/download/output/foo/docId/' . $this->documentId); $this->assertResponseCode(400); }
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; }
public function testConfirmationDisabled() { $config = Zend_Registry::get('Zend_Config'); $config->merge(new Zend_Config(array('confirmation' => array('document' => array('statechange' => array('enabled' => '0')))))); $this->dispatch('/admin/workflow/changestate/docId/102/targetState/deleted'); $this->assertRedirectTo('/admin/document/index/id/102'); // Änderung wird sofort durchgefuehrt $doc = new Opus_Document(102); $this->assertEquals('deleted', $doc->getServerState()); $doc->setServerState('unpublished'); $doc->store(); }
/** * Check if non-admin user has access to unpublished documents. * @expectedException Application_Exception * @expectedExceptionMessage not allowed */ public function testGetDocumentUnpublished() { $this->enableSecurity(); $this->loginUser('security7', 'security7pwd'); $document = new Opus_Document($this->_documentId); $document->setServerState('unpublished'); $document->store(); $request = $this->getRequest(); $request->setParam('docId', $this->_documentId); $document = $this->_helper->getDocument($request); $this->assertNotNull($document); $this->assertEquals($this->_documentId, $document->getId()); }