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 * id from table tblWorkflowDocumentContent which is used to
* get log entries for this workflow. * get log entries for this workflow.
* This method will only get a currently running workflow in * 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 * workflow has ended, the current state of the workflow was
* set to null. * 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 * @return object/boolean an object of class SeedDMS_Core_Workflow
* or false in case of error, e.g. the version has not a 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(); $db = $this->_document->getDMS()->getDB();
if (!$this->_workflow) { if (!$this->_workflow) {
$queryStr= $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.`document` = '". $this->_document->getID() ."' "
." AND a.`state` IS NOT NULL" ." AND a.`state` IS NOT NULL"
." ORDER BY `date` DESC LIMIT 1"; ." ORDER BY `date` DESC LIMIT 1";
@ -6344,10 +6346,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return false; return false;
if(!$recs) if(!$recs)
return false; 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()); $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> <email>uwe@steinmann.cx</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2022-02-18</date> <date>2022-04-06</date>
<time>13:44:55</time> <time>13:44:55</time>
<version> <version>
<release>6.0.18</release> <release>6.0.18</release>
@ -30,6 +30,7 @@
- add SeedDMS_Core_File::fileExtension() - add SeedDMS_Core_File::fileExtension()
- add callbacks on onPostUpdateAttribute, onPostRemoveAttribute, onPostAddAttribute - add callbacks on onPostUpdateAttribute, onPostRemoveAttribute, onPostAddAttribute
- fix searching for document content with a custom attribute having a value set - 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> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">