當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Opus_Document::getServerState方法代碼示例

本文整理匯總了PHP中Opus_Document::getServerState方法的典型用法代碼示例。如果您正苦於以下問題:PHP Opus_Document::getServerState方法的具體用法?PHP Opus_Document::getServerState怎麽用?PHP Opus_Document::getServerState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Opus_Document的用法示例。


在下文中一共展示了Opus_Document::getServerState方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkPermission

 /**
  * @return boolean
  */
 private function checkPermission()
 {
     if ($this->_document->getServerState() === 'published') {
         return true;
     }
     $accessControl = Zend_Controller_Action_HelperBroker::getStaticHelper('accessControl');
     return Opus_Security_Realm::getInstance()->checkDocument($this->_document->getId()) || $accessControl->accessAllowed('documents');
 }
開發者ID:belapp,項目名稱:opus4-application,代碼行數:11,代碼來源:Document.php

示例2: requireServerState

 /**
  * Fail on wrong server state.
  *
  * @param string $state
  * @return Matheon_Model_Document Fluent interface.
  *
  * @throws Application_Exception
  */
 public function requireServerState($state)
 {
     $docState = $this->_document->getServerState();
     if ($docState !== $state) {
         $error = "Document (id:{$this->getId()}) has wrong state (state:{$docState}).";
         $this->_log->err($error);
         throw new Application_Exception($error);
     }
     return $this;
 }
開發者ID:KOBV,項目名稱:opus4-matheon,代碼行數:18,代碼來源:Document.php

示例3: loadDocument

 /**
  * Load initialized document object (and check document status).
  *
  * @param type $documentId
  * @return Opus_Document
  * @throws Publish_Model_Exception 
  */
 public function loadDocument($documentId)
 {
     if (!isset($documentId) or !preg_match('/^\\d+$/', $documentId)) {
         throw new Publish_Model_Exception('Invalid document ID given');
     }
     $this->document = new Opus_Document($documentId);
     if ($this->document->getServerState() !== self::DOCUMENT_STATE) {
         throw new Publish_Model_Exception('Document->ServerState mismatch!');
     }
     return $this->document;
 }
開發者ID:alexukua,項目名稱:opus4,代碼行數:18,代碼來源:DocumentWorkflow.php

示例4: checkDocumentApplicableForFileDownload

 public function checkDocumentApplicableForFileDownload($realm)
 {
     if (!$this->isDocumentAccessAllowed($this->_doc->getId(), $realm)) {
         switch ($this->_doc->getServerState()) {
             case self::SERVER_STATE_DELETED:
                 throw new Frontdoor_Model_DocumentDeletedException();
                 break;
             case self::SERVER_STATE_PUBLISHED:
                 // do nothing if in published state - access is granted!
                 break;
             default:
                 // Dateien dürfen bei Nutzer mit Zugriff auf "documents" heruntergeladen werden
                 throw new Frontdoor_Model_DocumentAccessNotAllowedException();
         }
     }
 }
開發者ID:KOBV,項目名稱:opus4-matheon,代碼行數:16,代碼來源:File.php

示例5: getDocState

 /**
  * Returns the document state.
  * @return string
  */
 public function getDocState()
 {
     try {
         return $this->document->getServerState();
     } catch (Exception $e) {
         return 'undefined';
     }
 }
開發者ID:alexukua,項目名稱:opus4,代碼行數:12,代碼來源:DocumentAdapter.php

示例6: postStore

 /**
  * Post-store hook will be called right after the document has been stored
  * to the database.  If set to synchronous, update index.  Otherwise add
  * job to worker-queue.
  *
  * If document state is set to something != published, remove document.
  *
  * @see {Opus_Model_Plugin_Interface::postStore}
  */
 public function postStore(Opus_Model_AbstractDb $model)
 {
     // only index Opus_Document instances
     if (false === $model instanceof Opus_Document) {
         return;
     }
     // Skip indexing if document has not been published yet.  First we need
     // to reload the document, just to make sure the object is new,
     // unmodified and clean...
     // TODO: Write unit test.
     $model = new Opus_Document($model->getId());
     if ($model->getServerState() !== 'published') {
         if ($model->getServerState() !== 'temporary') {
             $this->removeDocumentFromIndex($model->getId());
         }
         return;
     }
     $this->addDocumentToIndex($model);
 }
開發者ID:alexukua,項目名稱:opus4,代碼行數:28,代碼來源:Index.php

示例7: getAccessibleFiles

 /**
  * Returns all associated Opus_File objects that are visible in OAI and accessible by user
  * @return array Accessible Opus_File objects
  *
  * TODO check embargo date
  * TODO merge access checks with code for deliver controller
  */
 public function getAccessibleFiles()
 {
     $realm = Opus_Security_Realm::getInstance();
     // admins sollen immer durchgelassen werden, nutzer nur wenn das doc im publizierten Zustand ist
     if (!$realm->skipSecurityChecks()) {
         // kein administrator
         // PUBLISHED Dokumente sind immer verfügbar (Zugriff auf Modul kann eingeschränkt sein)
         if ($this->_doc->getServerState() !== 'published') {
             // Dokument nicht published
             if (!$realm->checkDocument($this->_docId)) {
                 // Dokument ist nicht verfügbar für aktuellen Nutzer
                 $this->logErrorMessage('document id =' . $this->_docId . ' is not published and access is not allowed for current user');
                 throw new Oai_Model_Exception('access to requested document is forbidden');
             }
         }
         if ($this->_doc->hasEmbargoPassed() === false) {
             if (!$realm->checkDocument($this->_docId)) {
                 // Dokument ist nicht verfügbar für aktuellen Nutzer
                 $this->logErrorMessage('document id =' . $this->_docId . ' is not embargoed and access is not allowed for current user');
                 throw new Oai_Model_Exception('access to requested document files is embargoed');
             }
         }
     }
     $files = array();
     $filesToCheck = $this->_doc->getFile();
     /* @var $file Opus_File */
     foreach ($filesToCheck as $file) {
         $filename = $this->_appConfig->getFilesPath() . $this->_docId . DIRECTORY_SEPARATOR . $file->getPathName();
         if (is_readable($filename)) {
             array_push($files, $file);
         } else {
             $this->logErrorMessage("skip non-readable file {$filename}");
         }
     }
     if (empty($files)) {
         $this->logErrorMessage('document with id ' . $this->_docId . ' does not have any associated files');
         throw new Oai_Model_Exception('requested document does not have any associated readable files');
     }
     $containerFiles = array();
     /* @var $file Opus_File */
     foreach ($files as $file) {
         if ($file->getVisibleInOai() && $realm->checkFile($file->getId())) {
             array_push($containerFiles, $file);
         }
     }
     if (empty($containerFiles)) {
         $this->logErrorMessage('document with id ' . $this->_docId . ' does not have associated files that are accessible');
         throw new Oai_Model_Exception('access denied on all files that are associated to the requested document');
     }
     return $containerFiles;
 }
開發者ID:KOBV,項目名稱:opus4-matheon,代碼行數:58,代碼來源:Container.php

示例8: getAllowedTargetStatesForDocument

 /**
  * Returns all allowed target states for a document.
  * @param Opus_Document $document
  * @return array of strings - Possible target states for document
  */
 public function getAllowedTargetStatesForDocument($document)
 {
     $logger = Zend_Registry::get('Zend_Log');
     $currentState = $document->getServerState();
     $targetStates = self::getTargetStates($currentState);
     $acl = $this->getAcl();
     if (!is_null($acl)) {
         $logger->debug("ACL: got instance");
         if (!is_null($acl)) {
             $allowedTargetStates = array();
             foreach ($targetStates as $targetState) {
                 $resource = 'workflow_' . $currentState . '_' . $targetState;
                 if (!$acl->has(new Zend_Acl_Resource($resource)) || $acl->isAllowed(Application_Security_AclProvider::ACTIVE_ROLE, $resource)) {
                     $allowedTargetStates[] = $targetState;
                 } else {
                     $logger->debug("ACL: {$resource} not allowed");
                 }
             }
             return $allowedTargetStates;
         }
     }
     return $targetStates;
 }
開發者ID:alexukua,項目名稱:opus4,代碼行數:28,代碼來源:Workflow.php

示例9: testRejectActionWithOneDocumentConfirmed

 public function testRejectActionWithOneDocumentConfirmed()
 {
     $this->request->setMethod('POST')->setPost(array('selected' => $this->documentId, 'sureyes' => 'yes'));
     $this->dispatch('/review/index/reject');
     $this->assertResponseCode(200);
     $this->assertModule('review');
     $this->assertController('index');
     $this->assertAction('reject');
     $response = $this->getResponse();
     $this->assertNotContains('sureyes', $response->getBody());
     $this->assertNotContains('sureno', $response->getBody());
     $document = new Opus_Document($this->documentId);
     $this->assertEquals('deleted', $document->getServerState());
 }
開發者ID:belapp,項目名稱:opus4-application,代碼行數:14,代碼來源:IndexControllerTest.php

示例10: foreach

            $numOfTitles++;
        }
    }
    $numOfAbstracts = 0;
    foreach ($doc->getTitleAbstract() as $abstract) {
        if ($abstract->getLanguage() === $doc->getLanguage()) {
            $numOfAbstracts++;
        }
    }
    if ($numOfTitles > 1 || $numOfAbstracts > 1) {
        $msg = "document #{$docId} (";
        $opusThreeId = $doc->getIdentifierOpus3();
        if (count($opusThreeId) > 0) {
            $msg .= 'opus3id #' . $opusThreeId[0]->getValue() . ' ';
        }
        $msg .= 'server_state: ' . $doc->getServerState() . ') needs to be updated manually: has';
        if ($numOfTitles > 1) {
            $msg .= " {$numOfTitles} titles";
        }
        if ($numOfAbstracts > 1) {
            $msg .= " {$numOfAbstracts} abstracts";
        }
        echo $msg . "\n";
        $updateRequired++;
    }
}
if ($updateRequired == 0) {
    echo "all docs were checked -- nothing to do!\n";
} else {
    echo "{$updateRequired} docs need to be updated manually!\n";
}
開發者ID:belapp,項目名稱:opus4-application,代碼行數:31,代碼來源:find_docs_with_multiple_titles_or_abstracts.php

示例11: getDocumentXmlDomNode

 /**
  *
  * @param Opus_Document $document
  * @return DOMNode
  * @throws Exception
  */
 private function getDocumentXmlDomNode($document)
 {
     if (!in_array($document->getServerState(), $this->_deliveringDocumentStates)) {
         $message = 'Trying to get a document in server state "' . $document->getServerState() . '"';
         Zend_Registry::get('Zend_Log')->err($message);
         throw new Exception($message);
     }
     $xmlModel = new Opus_Model_Xml();
     $xmlModel->setModel($document);
     $xmlModel->excludeEmptyFields();
     $xmlModel->setStrategy(new Opus_Model_Xml_Version1());
     $xmlModel->setXmlCache(new Opus_Model_Xml_Cache());
     return $xmlModel->getDomDocument()->getElementsByTagName('Opus_Document')->item(0);
 }
開發者ID:belapp,項目名稱:opus4-application,代碼行數:20,代碼來源:IndexController.php

示例12: testConfirmationDisabled

 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();
 }
開發者ID:belapp,項目名稱:opus4-application,代碼行數:12,代碼來源:WorkflowControllerTest.php

示例13: testChangeStateToUnpublished

 /**
  * TODO unit test must be modified as soon as 'unpublish' is forbidden
  */
 public function testChangeStateToUnpublished()
 {
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->store();
     $docId = $doc->getId();
     $this->__workflowHelper->changeState($doc, 'unpublished');
     $doc = new Opus_Document($docId);
     $this->assertEquals('unpublished', $doc->getServerState());
 }
開發者ID:belapp,項目名稱:opus4-application,代碼行數:13,代碼來源:WorkflowTest.php

示例14: dirname

 * OPUS is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the Licence, or any later version.
 * OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details. You should have received a copy of the GNU General Public License 
 * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * @category    Application
 * @author      Thoralf Klein <thoralf.klein@zib.de>
 * @copyright   Copyright (c) 2011, OPUS 4 development team
 * @license     http://www.gnu.org/licenses/gpl.html General Public License
 * @version     $Id$
 */
// Bootstrapping
require_once dirname(__FILE__) . '/../common/bootstrap.php';
$date = new DateTime();
$dateString = $date->sub(new DateInterval('P2D'))->format('Y-m-d');
$f = new Opus_DocumentFinder();
$f->setServerState('temporary')->setServerDateModifiedBefore($dateString);
foreach ($f->ids() as $id) {
    $d = new Opus_Document($id);
    if ($d->getServerState() == 'temporary') {
        echo "deleting document: {$id}\n";
        $d->deletePermanent();
    } else {
        echo "NOT deleting document: {$id} because it has server state " . $d->getServerState();
    }
}
開發者ID:belapp,項目名稱:opus4-application,代碼行數:31,代碼來源:cron-db-clean-temporary.php

示例15: indexAction

 /**
  * Displays the metadata of a document.
  * @return void
  */
 public function indexAction()
 {
     // call export index-action, if parameter is set
     if (!is_null($this->getRequest()->getParam('export'))) {
         $params = $this->getRequest()->getParams();
         // export module ignores pagination parameters
         unset($params['rows']);
         unset($params['start']);
         $params['searchtype'] = 'id';
         return $this->_redirectToAndExit('index', null, 'index', 'export', $params);
     }
     $this->view->title = $this->view->translate('frontdoor_title');
     $request = $this->getRequest();
     $docId = $request->getParam('docId', '');
     $this->view->docId = $docId;
     $baseUrl = $request->getBaseUrl();
     if ($docId == '') {
         $this->printDocumentError("frontdoor_doc_id_missing", 404);
         return;
     }
     $document = null;
     try {
         $document = new Opus_Document($docId);
     } catch (Opus_Model_NotFoundException $e) {
         $this->printDocumentError("frontdoor_doc_id_not_found", 404);
         return;
     }
     $documentXml = null;
     try {
         $documentXml = new Util_Document($document);
     } catch (Application_Exception $e) {
         switch ($document->getServerState()) {
             case self::SERVER_STATE_DELETED:
                 $this->printDocumentError("frontdoor_doc_deleted", 410);
                 return;
             case self::SERVER_STATE_UNPUBLISHED:
                 $this->printDocumentError("frontdoor_doc_unpublished", 403);
                 return;
         }
         $this->printDocumentError("frontdoor_doc_access_denied", 403);
         return;
     }
     $documentNode = $documentXml->getNode();
     /* XSLT transformation. */
     $docBuilder = new Frontdoor_Model_DocumentBuilder();
     $xslt = $docBuilder->buildDomDocument($this->view->getScriptPath('index') . DIRECTORY_SEPARATOR . 'index');
     $proc = new XSLTProcessor();
     $proc->registerPHPFunctions(self::TRANSLATE_FUNCTION);
     $proc->registerPHPFunctions(self::TRANSLATE_DEFAULT_FUNCTION);
     $proc->registerPHPFunctions(self::FILE_ACCESS_FUNCTION);
     $proc->registerPHPFunctions(self::FORMAT_DATE_FUNCTION);
     $proc->registerPHPFunctions(self::EMBARGO_ACCESS_FUNCTION);
     $proc->registerPHPFunctions(self::SORT_ORDER_FUNCTION);
     $proc->registerPHPFunctions(self::CHECK_LANGUAGE_FILE_FUNCTION);
     $proc->registerPHPFunctions(self::GET_STYLESHEET_FUNCTION);
     $proc->registerPHPFunctions('urlencode');
     $proc->importStyleSheet($xslt);
     $config = Zend_Registry::getInstance()->get('Zend_Config');
     $layoutPath = 'layouts/' . (isset($config, $config->theme) ? $config->theme : '');
     $numOfShortAbstractChars = isset($config, $config->frontdoor->numOfShortAbstractChars) ? $config->frontdoor->numOfShortAbstractChars : '0';
     $proc->setParameter('', 'baseUrlServer', $this->view->fullUrl());
     $proc->setParameter('', 'baseUrl', $baseUrl);
     $proc->setParameter('', 'layoutPath', $baseUrl . '/' . $layoutPath);
     $proc->setParameter('', 'isMailPossible', $this->isMailPossible($document));
     $proc->setParameter('', 'numOfShortAbstractChars', $numOfShortAbstractChars);
     /* print on demand config */
     $printOnDemandEnabled = false;
     $podConfig = $config->get('printOnDemand', false);
     if ($podConfig !== false) {
         $printOnDemandEnabled = true;
         $proc->setParameter('', 'printOnDemandUrl', $podConfig->get('url', ''));
         $proc->setParameter('', 'printOnDemandButton', $podConfig->get('button', ''));
     }
     $proc->setParameter('', 'printOnDemandEnabled', $printOnDemandEnabled);
     $frontdoorContent = $proc->transformToXML($documentNode);
     /* Setup view. */
     $this->view->frontdoor = $frontdoorContent;
     $this->view->baseUrl = $baseUrl;
     $this->view->doctype('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">');
     $dateModified = $document->getServerDateModified();
     if (!is_null($dateModified)) {
         $this->view->headMeta()->appendHttpEquiv('Last-Modified', $dateModified->getDateTime()->format(DateTime::RFC1123));
     }
     $this->addMetaTagsForDocument($document);
     $this->view->title = $this->getFrontdoorTitle($document);
     $this->incrementStatisticsCounter($docId);
     $actionbox = new Admin_Form_ActionBox();
     $actionbox->prepareRenderingAsView();
     $actionbox->populateFromModel($document);
     $this->view->adminform = $actionbox;
 }
開發者ID:alexukua,項目名稱:opus4,代碼行數:95,代碼來源:IndexController.php


注:本文中的Opus_Document::getServerState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。