コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
ファイル: AbstractCollection.php プロジェクト: alexukua/opus4
 /**
  * make sure documents related to Collection[Role|]s in subtree are updated 
  * (XML-Cache and server_date_published)
  *
  * @param Opus_Collection Starting point for recursive update to documents
  */
 protected function updateDocuments($model)
 {
     if (is_null($model) || is_null($model->getId())) {
         // TODO explain why this is right
         return;
     }
     $collections = Opus_Db_TableGateway::getInstance('Opus_Db_Collections');
     $collectionIdSelect = $collections->selectSubtreeById($model->getId(), 'id');
     $documentFinder = new Opus_DocumentFinder();
     $documentFinder->setCollectionId($collectionIdSelect);
     // clear affected documents from cache
     $xmlCache = new Opus_Model_Xml_Cache();
     $xmlCache->removeAllEntriesWhereSubSelect($documentFinder->getSelectIds());
     // update ServerDateModified for affected documents
     $date = new Opus_Date();
     $date->setNow();
     Opus_Document::setServerDateModifiedByIds($date, $documentFinder->ids());
 }
コード例 #3
0
 public function showAction()
 {
     $selectedYear = $this->getRequest()->getParam('selectedYear', null);
     if (is_null($selectedYear) || !in_array($selectedYear, $this->_statisticsModel->getYears())) {
         return $this->_redirectToAndExit('index');
     }
     $this->view->languageSelectorDisabled = true;
     $date = new Opus_Date();
     $date->setYear($selectedYear)->setMonth(12)->setDay(31);
     $this->view->dateThreshold = $this->getHelper('Dates')->getDateString($date);
     $this->view->selectedYear = $selectedYear;
     $this->view->sumDocsUntil = $this->_statisticsModel->getNumDocsUntil($selectedYear);
     $monthStat = $this->_statisticsModel->getMonthStatistics($selectedYear);
     $this->view->totalNumber = array_sum($monthStat);
     $this->view->title = $this->view->translate('Statistic_Controller') . ' ' . $selectedYear;
     $this->view->monthStat = $monthStat;
     $this->view->typeStat = $this->_statisticsModel->getTypeStatistics($selectedYear);
     $this->view->instStat = $this->_statisticsModel->getInstituteStatistics($selectedYear);
     $this->_breadcrumbs->setLabelFor('admin_statistic_show', $selectedYear);
 }
コード例 #4
0
 protected function invalidateDocumentCacheFor(Opus_Model_AbstractDb $model)
 {
     $documentFinder = new Opus_DocumentFinder();
     $documentFinder->setDependentModel($model);
     $select = $documentFinder->getSelectIds();
     $ids = $documentFinder->Ids();
     $xmlCache = new Opus_Model_Xml_Cache();
     $xmlCache->removeAllEntriesWhereSubSelect($select);
     $date = new Opus_Date();
     $date->setNow();
     Opus_Document::setServerDateModifiedByIds($date, $ids);
 }
コード例 #5
0
ファイル: FileTest.php プロジェクト: KOBV/opus4-matheon
 public function testGetFileObjectForUnpublishedFileForDocumentsAdmin()
 {
     $this->loginUser('security8', 'security8pwd');
     $file = $this->createTestFile('test.pdf');
     $doc = $this->createTestDocument();
     $doc->setServerState('unpublished');
     $doc->addFile($file);
     $date = new Opus_Date();
     $date->setYear('2100')->setMonth('00')->setDay('01');
     $doc->setEmbargoDate($date);
     $docId = $doc->store();
     $model = new Frontdoor_Model_File($docId, "test.pdf");
     $realm = new MockRealm(true, true);
     $opusFile = $model->getFileObject($realm);
     $this->assertEquals("test.pdf", $opusFile->getPathName());
 }
コード例 #6
0
ファイル: FileTest.php プロジェクト: belapp/opus4-application
 /**
  * Dateien dürfen vom Admin heruntergeladen werden, auch wenn das Embargo-Datum nicht vergangen ist.
  * Regressiontest for OPUSVIER-3313.
  */
 public function testAccessForEmbargoedDocumentForAdmin()
 {
     $this->loginUser('admin', 'adminadmin');
     $file = $this->createTestFile('test.pdf');
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->addFile($file);
     $date = new Opus_Date();
     $date->setYear('2100')->setMonth('00')->setDay('01');
     $doc->setEmbargoDate($date);
     $docId = $doc->store();
     $model = new Frontdoor_Model_File($docId, "test.pdf");
     $realm = new MockRealm(true, true);
     $file = $model->getFileObject($realm);
     $this->assertEquals('test.pdf', $file->getPathName());
 }
コード例 #7
0
 * @copyright   Copyright (c) 2008-2011, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
/**
 * script to create 10000 documents, e.g., for performance testing
 */
for ($i = 1; $i < 10000; $i++) {
    $d = new Opus_Document();
    $d->setServerState('published');
    $d->setType('preprint');
    $d->setLanguage('deu');
    $title = $d->addTitleMain();
    $title->setLanguage('deu');
    $title->setValue('title-' . rand());
    $date = new Opus_Date();
    $date->setNow();
    $date->setYear(1990 + $i % 23);
    $d->setPublishedDate($date);
    $p = new Opus_Person();
    $p->setFirstName("foo-" . $i % 7);
    $p->setLastName("bar-" . $i % 5);
    $p = $d->addPersonAuthor($p);
    $c = new Opus_Collection(15990 + $i % 103);
    $d->addCollection($c);
    $s = $d->addSubject()->setType('ddc');
    $s->setValue($i % 97);
    $docId = $d->store();
    echo "docId: {$docId}\n";
}
exit;
コード例 #8
0
ファイル: ContainerTest.php プロジェクト: KOBV/opus4-matheon
 /**
  * @expectedException Oai_Model_Exception
  * @expectedExceptionMessage access to requested document files is embargoed
  */
 public function testGetAccessibleFilesForEmbargoedDocument()
 {
     $this->enableSecurity();
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     // set embargo date to tomorrow
     $date = new Opus_Date();
     $date->setDateTime(new DateTime('tomorrow'));
     $doc->setEmbargoDate($date);
     // add a file visible in OAI
     $file = $this->createTestFile('foo.pdf');
     $file->setVisibleInOai(true);
     $doc->addFile($file);
     $doc->store();
     $this->assertFalse($doc->hasEmbargoPassed());
     // not yet passed
     $container = new Oai_Model_Container($doc->getId());
     $files = $container->getAccessibleFiles();
     $this->assertCount(1, $files);
 }
コード例 #9
0
ファイル: Document.php プロジェクト: alexukua/opus4
 /**
  * Compares EmbargoDate with parameter or system time.
  *
  * @param Opus_Date $now
  * @return bool true - if embargo date has passed; false - if not
  */
 public function hasEmbargoPassed($now = null)
 {
     $embargoDate = $this->getEmbargoDate();
     if (is_null($embargoDate)) {
         return true;
     }
     if (is_null($now)) {
         $now = new Opus_Date();
         $now->setNow();
     }
     // Embargo has passed on the day after the specified date
     $embargoDate->setHour(23);
     $embargoDate->setMinute(59);
     $embargoDate->setSecond(59);
     return $embargoDate < $now;
 }
コード例 #10
0
 /**
  * Tests, that the sortfields in browsing are still working.
  * see Opusvier-3334.
  */
 public function testSortOrderOfDocumentsInBrowsingWithSortfield()
 {
     $olderDoc = $this->createTestDocument();
     $olderDoc->setServerState('published');
     $olderDoc->setLanguage('eng');
     $date = new Opus_Date();
     $date->setNow();
     $date->setDay($date->getDay() - 1);
     $olderDoc->setServerDatePublished($date);
     $olderDoc->setType('article');
     $title = new Opus_Title();
     $title->setValue('zzzOlderDoc');
     // 'zzz' to show the document at the first page
     $title->setLanguage('eng');
     $olderDoc->addTitleMain($title);
     $olderDocId = $olderDoc->store();
     $newerDoc = $this->createTestDocument();
     $newerDoc->setServerState('published');
     $newerDoc->setLanguage('eng');
     $newerDoc->setType('article');
     $title = new Opus_Title();
     $title->setValue('zzzNewerDoc');
     $title->setLanguage('eng');
     $newerDoc->addTitleMain($title);
     $newerDocId = $newerDoc->store();
     $this->dispatch('/solrsearch/index/search/searchtype/simple/query/*%3A*/browsing/true/doctypefq/article/sortfield/title/sortorder/desc');
     $responseBody = $this->getResponse()->getBody();
     preg_match("\$/frontdoor/index/index.*/docId/{$olderDocId}\$", $responseBody, $matches, PREG_OFFSET_CAPTURE);
     $this->assertNotEmpty($matches, "Document {$olderDocId} not found!");
     $olderDocPosition = $matches[0][1];
     preg_match("\$/frontdoor/index/index.*/docId/{$newerDocId}\$", $responseBody, $matches, PREG_OFFSET_CAPTURE);
     $this->assertNotEmpty($matches, "Document {$newerDocId} not found!");
     $newerDocPosition = $matches[0][1];
     $this->assertTrue($newerDocPosition > $olderDocPosition, "Documents are not sorted by sortfield (title).");
 }
コード例 #11
0
 public function testGetDateStringForInvalidDate()
 {
     $this->useGerman();
     $date = new Opus_Date('2005');
     $this->assertFalse($date->isValid());
     $this->assertEquals(null, $this->__datesHelper->getDateString($date));
 }
コード例 #12
0
 /**
  * Prüft ob das Upload-Datum der Datei bei der Erstellung gesetzt wird.
  */
 public function testFileUploadDate()
 {
     $this->useGerman();
     $file = $this->createTestFile('foo.pdf');
     $file->setVisibleInOai(false);
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->addFile($file);
     $docId = $doc->store();
     $dateNow = new Opus_Date();
     $dateNow->setNow();
     $this->dispatch('admin/filemanager/index/id/' . $docId);
     $this->assertQueryContentContains('//label', 'Datum des Hochladens');
     $this->assertQueryContentContains('//div', $dateNow->getDay() . '.' . $dateNow->getMonth() . '.' . $dateNow->getYear());
 }
コード例 #13
0
 *
 * @category    Application
 * @author      Sascha Szott <szott@zib.de>
 * @copyright   Copyright (c) 2008-2011, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
/**
 * Releases all documents in server state unpublished.
 */
$docFinder = new Opus_DocumentFinder();
$docFinder->setServerState('unpublished');
foreach ($docFinder->ids() as $id) {
    $d = null;
    try {
        $d = new Opus_Document($id);
    } catch (Opus_Model_NotFoundException $e) {
        // document with id $id does not exist
        continue;
    }
    if (!is_null($d)) {
        $date = new Opus_Date();
        $date->setNow();
        $d->setServerState('published');
        $d->setServerDatePublished($date);
        $d->store();
        echo "publishing of document with id {$id} was successful\n";
    }
}
echo "done.\n";
exit;
コード例 #14
0
 /**
  * Test für OPUSVIER-3275.
  */
 public function testEmbargoDateHasNotPassed()
 {
     $this->useEnglish();
     $file = $this->createTestFile('foo.pdf');
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->addFile($file);
     $date = new Opus_Date();
     $date->setYear('2100')->setMonth('00')->setDay('01');
     $doc->setEmbargoDate($date);
     $docId = $doc->store();
     $this->dispatch('frontdoor/index/index/docId/' . $docId);
     $this->assertNotQueryContentContains('//*', '/files/' . $docId . '/foo.pdf');
     $this->assertQueryContentContains('//*', 'This document is embargoed until:');
 }
コード例 #15
0
ファイル: File.php プロジェクト: alexukua/opus4
 /**
  * Copy the uploaded file to it's final destination.
  *
  * Moves or copies uploaded file depending on whether it has been
  * uploaded by PHP process or was privided via filesystem directly.
  *
  * Determine and set file mime type.
  *
  * @see Opus_Model_AbstractDb::_preStore()
  */
 protected function _preStore()
 {
     $result = parent::_preStore();
     if (isset($result)) {
         return $result;
     }
     $target = $this->getPathName();
     $tempFile = $this->getTempFile();
     if (false === empty($tempFile)) {
         $this->getStorage()->createSubdirectory();
         $this->getStorage()->copyExternalFile($tempFile, $target);
         // set file size
         $file_size = $this->getStorage()->getFileSize($target);
         $this->setFileSize($file_size);
         // set mime type
         $mimetype = $this->getStorage()->getFileMimeEncoding($target);
         $this->setMimeType($mimetype);
         // create and append hash values
         $this->_createHashValues();
     }
     // Rename file, if the stored name changed on existing record.  Rename
     // only already stored files.
     // TODO: Move rename logic to _storePathName() method.
     if (false === $this->isNewRecord() && $this->getField('PathName')->isModified()) {
         $storedFileName = $this->_primaryTableRow->path_name;
         if (!empty($storedFileName)) {
             // $oldName = $this->getStorage()->getWorkingDirectory() . $storedFileName;
             $result = $this->getStorage()->renameFile($storedFileName, $target);
         }
     }
     if ($this->isNewRecord()) {
         $dateNow = new Opus_Date();
         $dateNow->setNow();
         $this->setServerDateSubmitted($dateNow);
     }
     return;
 }