mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 12:41:30 +00:00
run decorators, new method isType(), do not access variable _dms anymore
This commit is contained in:
parent
cebf0e3796
commit
f9eabdb252
|
@ -222,6 +222,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_content = null;
|
$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
|
* Return an array of database fields which used for searching
|
||||||
* a term entered in the database search form
|
* 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 */
|
/** @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 = 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->setDMS($dms);
|
||||||
|
$document = $document->applyDecorators();
|
||||||
return $document;
|
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
|
* Return the directory of the document in the file system relativ
|
||||||
* to the contentDir
|
* to the contentDir
|
||||||
|
@ -441,7 +468,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if(!$this->_categories)
|
if(!$this->_categories)
|
||||||
self::getCategories();
|
$this->getCategories();
|
||||||
|
|
||||||
$catids = array();
|
$catids = array();
|
||||||
foreach($this->_categories as $cat)
|
foreach($this->_categories as $cat)
|
||||||
|
@ -543,7 +570,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* @return SeedDMS_Core_Folder parent folder
|
* @return SeedDMS_Core_Folder parent folder
|
||||||
*/
|
*/
|
||||||
function getParent() { /* {{{ */
|
function getParent() { /* {{{ */
|
||||||
return self::getFolder();
|
return $this->getFolder();
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function getFolder() { /* {{{ */
|
function getFolder() { /* {{{ */
|
||||||
|
@ -650,7 +677,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_defaultAccess = $mode;
|
$this->_defaultAccess = $mode;
|
||||||
|
|
||||||
if(!$noclean)
|
if(!$noclean)
|
||||||
self::cleanNotifyList();
|
$this->cleanNotifyList();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -684,7 +711,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_inheritAccess = ($inheritAccess ? "1" : "0");
|
$this->_inheritAccess = ($inheritAccess ? "1" : "0");
|
||||||
|
|
||||||
if(!$noclean)
|
if(!$noclean)
|
||||||
self::cleanNotifyList();
|
$this->cleanNotifyList();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -861,7 +888,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
unset($this->_accessList);
|
unset($this->_accessList);
|
||||||
|
|
||||||
if(!$noclean)
|
if(!$noclean)
|
||||||
self::cleanNotifyList();
|
$this->cleanNotifyList();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -1461,6 +1488,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
echo $tmpFile;
|
||||||
if($this->_dms->forceRename)
|
if($this->_dms->forceRename)
|
||||||
$err = SeedDMS_Core_File::renameFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType);
|
$err = SeedDMS_Core_File::renameFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType);
|
||||||
else
|
else
|
||||||
|
@ -2792,7 +2820,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_orgFileName = $orgFileName;
|
$this->_orgFileName = $orgFileName;
|
||||||
$this->_fileType = $fileType;
|
$this->_fileType = $fileType;
|
||||||
$this->_mimeType = $mimeType;
|
$this->_mimeType = $mimeType;
|
||||||
$this->_dms = $document->_dms;
|
$this->_dms = $document->getDMS();
|
||||||
if(!$fileSize) {
|
if(!$fileSize) {
|
||||||
$this->_fileSize = SeedDMS_Core_File::fileSize($this->_dms->contentDir . $this->getPath());
|
$this->_fileSize = SeedDMS_Core_File::fileSize($this->_dms->contentDir . $this->getPath());
|
||||||
} else {
|
} else {
|
||||||
|
@ -2803,6 +2831,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_workflowState = null;
|
$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 getVersion() { return $this->_version; }
|
||||||
function getComment() { return $this->_comment; }
|
function getComment() { return $this->_comment; }
|
||||||
function getDate() { return $this->_date; }
|
function getDate() { return $this->_date; }
|
||||||
|
@ -4847,11 +4884,11 @@ class SeedDMS_Core_DocumentLink { /* {{{ */
|
||||||
* @return int either M_NONE or M_READ
|
* @return int either M_NONE or M_READ
|
||||||
*/
|
*/
|
||||||
function getAccessMode($u, $source, $target) { /* {{{ */
|
function getAccessMode($u, $source, $target) { /* {{{ */
|
||||||
$dms = $this->_document->_dms;
|
$dms = $this->_document->getDMS();
|
||||||
|
|
||||||
/* Check if 'onCheckAccessDocumentLink' callback is set */
|
/* Check if 'onCheckAccessDocumentLink' callback is set */
|
||||||
if(isset($this->_dms->callbacks['onCheckAccessDocumentLink'])) {
|
if(isset($dms->callbacks['onCheckAccessDocumentLink'])) {
|
||||||
foreach($this->_dms->callbacks['onCheckAccessDocumentLink'] as $callback) {
|
foreach($dms->callbacks['onCheckAccessDocumentLink'] as $callback) {
|
||||||
if(($ret = call_user_func($callback[0], $callback[1], $this, $u, $source, $target)) > 0) {
|
if(($ret = call_user_func($callback[0], $callback[1], $this, $u, $source, $target)) > 0) {
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user