run decorators, new method isType(), do not access variable _dms anymore

This commit is contained in:
Uwe Steinmann 2019-08-08 08:42:02 +02:00
parent cebf0e3796
commit f9eabdb252

View File

@ -222,6 +222,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_content = null;
} /* }}} */
/**
* Check if this object is of type 'document'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'document';
} /* }}} */
/**
* Return an array of database fields which used for searching
* a term entered in the database search form
@ -291,9 +300,27 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/** @var SeedDMS_Core_Document $document */
$document = new $classname($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $lock, $resArr["keywords"], $resArr["sequence"]);
$document->setDMS($dms);
$document = $document->applyDecorators();
return $document;
} /* }}} */
/**
* Apply decorators
*
* @return object final object after all decorators has been applied
*/
function applyDecorators() { /* {{{ */
if($decorators = $this->_dms->getDecorators('document')) {
$s = $this;
foreach($decorators as $decorator) {
$s = new $decorator($s);
}
return $s;
} else {
return $this;
}
} /* }}} */
/**
* Return the directory of the document in the file system relativ
* to the contentDir
@ -441,7 +468,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db = $this->_dms->getDB();
if(!$this->_categories)
self::getCategories();
$this->getCategories();
$catids = array();
foreach($this->_categories as $cat)
@ -543,7 +570,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* @return SeedDMS_Core_Folder parent folder
*/
function getParent() { /* {{{ */
return self::getFolder();
return $this->getFolder();
} /* }}} */
function getFolder() { /* {{{ */
@ -650,7 +677,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_defaultAccess = $mode;
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -684,7 +711,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_inheritAccess = ($inheritAccess ? "1" : "0");
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -861,7 +888,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
unset($this->_accessList);
if(!$noclean)
self::cleanNotifyList();
$this->cleanNotifyList();
return true;
} /* }}} */
@ -1461,6 +1488,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db->rollbackTransaction();
return false;
}
echo $tmpFile;
if($this->_dms->forceRename)
$err = SeedDMS_Core_File::renameFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType);
else
@ -2792,7 +2820,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$this->_orgFileName = $orgFileName;
$this->_fileType = $fileType;
$this->_mimeType = $mimeType;
$this->_dms = $document->_dms;
$this->_dms = $document->getDMS();
if(!$fileSize) {
$this->_fileSize = SeedDMS_Core_File::fileSize($this->_dms->contentDir . $this->getPath());
} else {
@ -2803,6 +2831,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$this->_workflowState = null;
} /* }}} */
/**
* Check if this object is of type 'documentcontent'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'documentcontent';
} /* }}} */
function getVersion() { return $this->_version; }
function getComment() { return $this->_comment; }
function getDate() { return $this->_date; }
@ -4847,11 +4884,11 @@ class SeedDMS_Core_DocumentLink { /* {{{ */
* @return int either M_NONE or M_READ
*/
function getAccessMode($u, $source, $target) { /* {{{ */
$dms = $this->_document->_dms;
$dms = $this->_document->getDMS();
/* Check if 'onCheckAccessDocumentLink' callback is set */
if(isset($this->_dms->callbacks['onCheckAccessDocumentLink'])) {
foreach($this->_dms->callbacks['onCheckAccessDocumentLink'] as $callback) {
if(isset($dms->callbacks['onCheckAccessDocumentLink'])) {
foreach($dms->callbacks['onCheckAccessDocumentLink'] as $callback) {
if(($ret = call_user_func($callback[0], $callback[1], $this, $u, $source, $target)) > 0) {
return $ret;
}