add method getTransitions() to class SeedDMS_Core_Workflow[Action|State]

This commit is contained in:
Uwe Steinmann 2016-11-02 17:57:23 +01:00
parent f36ffb1032
commit 6c3a9c6734

View File

@ -488,6 +488,29 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
/**
* Return workflow transitions the status is being used in
*
* @return array/boolean array of workflow transitions or false in case of an error
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM tblWorkflowTransitions WHERE state=".$this->_id. " OR nextstate=".$this->_id;
$resArr = $db->getResultArray($queryStr);
if (is_array($resArr) && count($resArr) == 0)
return false;
$wkftransitions = array();
for ($i = 0; $i < count($resArr); $i++) {
$wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this->_dms->getWorkflow($resArr[$i]["workflow"]), $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]);
$wkftransition->setDMS($this->_dms);
$wkftransitions[$resArr[$i]["id"]] = $wkftransition;
}
return $wkftransitions;
} /* }}} */
/**
* Remove the workflow state
*
@ -588,6 +611,29 @@ class SeedDMS_Core_Workflow_Action { /* {{{ */
return true;
} /* }}} */
/**
* Return workflow transitions the action is being used in
*
* @return array/boolean array of workflow transitions or false in case of an error
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM tblWorkflowTransitions WHERE action=".$this->_id;
$resArr = $db->getResultArray($queryStr);
if (is_array($resArr) && count($resArr) == 0)
return false;
$wkftransitions = array();
for ($i = 0; $i < count($resArr); $i++) {
$wkftransition = new SeedDMS_Core_Workflow_Transition($resArr[$i]["id"], $this->_dms->getWorkflow($resArr[$i]["workflow"]), $this->_dms->getWorkflowState($resArr[$i]["state"]), $this->_dms->getWorkflowAction($resArr[$i]["action"]), $this->_dms->getWorkflowState($resArr[$i]["nextstate"]), $resArr[$i]["maxtime"]);
$wkftransition->setDMS($this->_dms);
$wkftransitions[$resArr[$i]["id"]] = $wkftransition;
}
return $wkftransitions;
} /* }}} */
/**
* Remove the workflow action
*