/** * Post-store hook will be called right after the document has been stored * to the database. * * @see {Opus_Model_Plugin_Interface::postStore} */ public function postStore(Opus_Model_AbstractDb $model) { // only index Opus_File instances if (false === $model instanceof Opus_File) { $this->getLogger()->err(__METHOD__ . '#1 argument must be instance of Opus_File'); return; } // only new Opus_File instances if (true !== $model->isNewRecord()) { return; } $config = Zend_Registry::get('Zend_Config'); if (!is_null($config) && isset($config->securityPolicy->files->defaultAccessRole)) { $roleName = $config->securityPolicy->files->defaultAccessRole; // Empty name -> don't set any role for access if (strlen(trim($roleName)) > 0) { $accessRole = Opus_UserRole::fetchByName($roleName); if (is_null($accessRole)) { $this->getLogger()->err(__METHOD__ . ": Failed to add role '{$roleName}' to file " . $model->getId() . "; '{$roleName}' role does not exist!"); return; } $accessRole->appendAccessFile($model->getId()); $accessRole->store(); } } }
public function preDelete(Opus_Model_AbstractDb $model) { if ($model->isNewRecord()) { return; } $this->updateDocuments($model); $collections = Opus_Db_TableGateway::getInstance('Opus_Db_Collections'); $collections->deleteSubTree($model->getId()); }
/** * Updates documents and deletes collections of CollectionRole. * @param Opus_Model_AbstractDb $model */ public function preDelete(Opus_Model_AbstractDb $model) { if ($model->isNewRecord()) { return; } // Update documents, incl. ServerDateModified if ($model instanceof Opus_CollectionRole) { $rootCollection = $model->getRootCollection(); if (!is_null($rootCollection)) { $this->updateDocuments($rootCollection); } } // Delete collections belonging to CollectionRole $collections = Opus_Db_TableGateway::getInstance('Opus_Db_Collections'); $collections->deleteTree($model->getId()); }
/** * @see {Opus_Model_Plugin_Interface::preDelete} * * Run plugin for documents depending on to-be-deleted model. * If model is not persistent (i. e. modelId is not set and /or model states to be a new record) * preDelete operation is skipped. */ public function preDelete(Opus_Model_AbstractDb $model) { $modelId = $model->getId(); if (!$model->isNewRecord() && !empty($modelId)) { $this->invalidateDocumentCacheFor($model); } }