initial version of removeProcessWithoutUserGroup()

This commit is contained in:
Uwe Steinmann 2017-08-03 21:41:03 +02:00
parent 0e6bd00f96
commit c5a67c2aeb

View File

@ -2219,6 +2219,41 @@ class SeedDMS_Core_DMS {
return $this->db->getResultArray($queryStr);
} /* }}} */
/**
* Removes all reviews, approvals which are not linked
* to a user, group anymore
*
* This method is for removing all reviews or approvals whose user
* or group was deleted and not just removed from the process.
* If the optional parameter $id is set, only this user/group id is removed.
*/
function removeProcessWithoutUserGroup($process, $usergroup, $id=0) { /* {{{ */
switch($process) {
case 'review':
$queryStr = "DELETE FROM tblDocumentReviewers";
break;
case 'approval':
$queryStr = "DELETE FROM tblDocumentApprovers";
break;
}
$queryStr .= " WHERE";
switch($usergroup) {
case 'user':
$queryStr .= " type=0 AND";
if($id)
$queryStr .= " required=".((int) $id)." AND";
$queryStr .= " required NOT IN (SELECT id FROM tblUsers)";
break;
case 'group':
$queryStr .= " type=1 AND";
if($id)
$queryStr .= " required=".((int) $id)." AND";
$queryStr .= " required NOT IN (SELECT id FROM tblGroups)";
break;
}
return $this->db->getResultArray($queryStr);
} /* }}} */
/**
* Returns statitical information
*