mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 13:06:14 +00:00
make list of workflow status distinct, add [g|s]etMandatoryWorkflows()
This commit is contained in:
parent
2e620fa622
commit
a935a635c8
|
@ -1016,7 +1016,7 @@ class SeedDMS_Core_User {
|
||||||
function getWorkflowStatus($documentID=null, $version=null) { /* {{{ */
|
function getWorkflowStatus($documentID=null, $version=null) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$queryStr = 'SELECT d.*, c.userid FROM tblWorkflowTransitions a LEFT JOIN tblWorkflows b ON a.workflow=b.id LEFT JOIN tblWorkflowTransitionUsers c ON a.id=c.transition LEFT JOIN tblWorkflowDocumentContent d ON b.id=d.workflow WHERE d.document IS NOT NULL AND a.state=d.state AND c.userid='.$this->_id;
|
$queryStr = 'SELECT DISTINCT d.*, c.userid FROM tblWorkflowTransitions a LEFT JOIN tblWorkflows b ON a.workflow=b.id LEFT JOIN tblWorkflowTransitionUsers c ON a.id=c.transition LEFT JOIN tblWorkflowDocumentContent d ON b.id=d.workflow WHERE d.document IS NOT NULL AND a.state=d.state AND c.userid='.$this->_id;
|
||||||
if($documentID) {
|
if($documentID) {
|
||||||
$queryStr .= ' AND d.document='.(int) $documentID;
|
$queryStr .= ' AND d.document='.(int) $documentID;
|
||||||
if($version)
|
if($version)
|
||||||
|
@ -1032,7 +1032,7 @@ class SeedDMS_Core_User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$queryStr = 'select d.*, c.groupid from tblWorkflowTransitions a left join tblWorkflows b on a.workflow=b.id left join tblWorkflowTransitionGroups c on a.id=c.transition left join tblWorkflowDocumentContent d on b.id=d.workflow left join tblGroupMembers e on c.groupid = e.groupID where d.document is not null and a.state=d.state and e.userID='.$this->_id;
|
$queryStr = 'select distinct d.*, c.groupid from tblWorkflowTransitions a left join tblWorkflows b on a.workflow=b.id left join tblWorkflowTransitionGroups c on a.id=c.transition left join tblWorkflowDocumentContent d on b.id=d.workflow left join tblGroupMembers e on c.groupid = e.groupID where d.document is not null and a.state=d.state and e.userID='.$this->_id;
|
||||||
if($documentID) {
|
if($documentID) {
|
||||||
$queryStr .= ' AND d.document='.(int) $documentID;
|
$queryStr .= ' AND d.document='.(int) $documentID;
|
||||||
if($version)
|
if($version)
|
||||||
|
@ -1108,6 +1108,32 @@ class SeedDMS_Core_User {
|
||||||
return $workflow;
|
return $workflow;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mandatory workflows
|
||||||
|
* A user which isn't trusted completely may have assigned mandatory
|
||||||
|
* workflow
|
||||||
|
* Whenever the user inserts a new document the mandatory workflow is
|
||||||
|
* filled in as the workflow.
|
||||||
|
*
|
||||||
|
* @return object workflow
|
||||||
|
*/
|
||||||
|
function getMandatoryWorkflows() { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
$queryStr = "SELECT * FROM tblWorkflowMandatoryWorkflow WHERE userid = " . $this->_id;
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && !$resArr) return false;
|
||||||
|
|
||||||
|
if(!$resArr)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
$workflows = array();
|
||||||
|
foreach($resArr as $res) {
|
||||||
|
$workflows[] = $this->_dms->getWorkflow($res['workflow']);
|
||||||
|
}
|
||||||
|
return $workflows;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a mandatory reviewer
|
* Set a mandatory reviewer
|
||||||
* This function sets a mandatory reviewer if it isn't already set.
|
* This function sets a mandatory reviewer if it isn't already set.
|
||||||
|
@ -1194,6 +1220,36 @@ class SeedDMS_Core_User {
|
||||||
if (is_bool($resArr) && !$resArr) return false;
|
if (is_bool($resArr) && !$resArr) return false;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a mandatory workflows
|
||||||
|
* This function sets a list of mandatory workflows.
|
||||||
|
*
|
||||||
|
* @param array $workflows list of workflow objects
|
||||||
|
* @return boolean true on success, otherwise false
|
||||||
|
*/
|
||||||
|
function setMandatoryWorkflows($workflows) { /* {{{ */
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
$db->startTransaction();
|
||||||
|
$queryStr = "DELETE FROM tblWorkflowMandatoryWorkflow WHERE userid = " . $this->_id;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($workflows as $workflow) {
|
||||||
|
$queryStr = "INSERT INTO tblWorkflowMandatoryWorkflow (userid, workflow) VALUES (" . $this->_id . ", " . $workflow->getID() .")";
|
||||||
|
$resArr = $db->getResult($queryStr);
|
||||||
|
if (is_bool($resArr) && !$resArr) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->commitTransaction();
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all mandatory reviewers
|
* Deletes all mandatory reviewers
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user