add optional parameter to getWorkflow() to retrieve data from tblWorkflowDocumentContent

This commit is contained in:
Uwe Steinmann 2022-04-06 19:54:46 +02:00
parent d80d1be9de
commit f8ac9090fb
2 changed files with 12 additions and 6 deletions

View File

@ -6323,19 +6323,21 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* id from table tblWorkflowDocumentContent which is used to
* get log entries for this workflow.
* This method will only get a currently running workflow in
* a state. Once
* a state. Once a
* workflow has ended, the current state of the workflow was
* set to null.
*
* @param bool $full return not just workflow but the data from
* tblWorkflowDocumentContent too
* @return object/boolean an object of class SeedDMS_Core_Workflow
* or false in case of error, e.g. the version has not a workflow
*/
function getWorkflow() { /* {{{ */
function getWorkflow($full = false) { /* {{{ */
$db = $this->_document->getDMS()->getDB();
if (!$this->_workflow) {
$queryStr=
"SELECT a.`id` as `wdcid`, a.`parent`, b.* FROM `tblWorkflowDocumentContent` a LEFT JOIN `tblWorkflows` b ON a.`workflow` = b.`id` WHERE a.`version`='".$this->_version
"SELECT a.`id` as `wdcid`, a.`parent`, a.`date`, b.* FROM `tblWorkflowDocumentContent` a LEFT JOIN `tblWorkflows` b ON a.`workflow` = b.`id` WHERE a.`version`='".$this->_version
."' AND a.`document` = '". $this->_document->getID() ."' "
." AND a.`state` IS NOT NULL"
." ORDER BY `date` DESC LIMIT 1";
@ -6344,10 +6346,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return false;
if(!$recs)
return false;
$this->_workflow = array('id'=>(int)$recs[0]['wdcid'], 'parent'=>(int)$recs[0]['parent'], 'workflow'=>new SeedDMS_Core_Workflow($recs[0]['id'], $recs[0]['name'], $this->_document->getDMS()->getWorkflowState($recs[0]['initstate']), $recs[0]["layoutdata"]));
$this->_workflow = array('id'=>(int)$recs[0]['wdcid'], 'parent'=>(int)$recs[0]['parent'], 'date'=>$recs[0]['date'], 'workflow'=>new SeedDMS_Core_Workflow($recs[0]['id'], $recs[0]['name'], $this->_document->getDMS()->getWorkflowState($recs[0]['initstate']), $recs[0]["layoutdata"]));
$this->_workflow['workflow']->setDMS($this->_document->getDMS());
}
return $this->_workflow['workflow'];
if($full)
return $this->_workflow;
else
return $this->_workflow['workflow'];
} /* }}} */
/**

View File

@ -12,7 +12,7 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2022-02-18</date>
<date>2022-04-06</date>
<time>13:44:55</time>
<version>
<release>6.0.18</release>
@ -30,6 +30,7 @@
- add SeedDMS_Core_File::fileExtension()
- add callbacks on onPostUpdateAttribute, onPostRemoveAttribute, onPostAddAttribute
- fix searching for document content with a custom attribute having a value set
- SeedDMS_Core_DocumentContent::getWorkflow() has optional parameter to return data from table tblWorkflowDocumentContent
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">