mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 12:41:30 +00:00
if documents are paѕsed to __removeFromProcesses(), only the latest version will be updated
This commit is contained in:
parent
05092f6943
commit
70114bbd30
|
@ -692,10 +692,11 @@ class SeedDMS_Core_User { /* {{{ */
|
||||||
* @param array $states remove user only from reviews/approvals in one of the states
|
* @param array $states remove user only from reviews/approvals in one of the states
|
||||||
* e.g. if passing array('review'=>array(0)), the method will operate on
|
* e.g. if passing array('review'=>array(0)), the method will operate on
|
||||||
* reviews which has not been touched yet.
|
* reviews which has not been touched yet.
|
||||||
* @param object user who takes over the processes
|
* @param object $newuser user who takes over the processes
|
||||||
|
* @param array $docs remove only processes from docs with the given document ids
|
||||||
* @return boolean true on success or false in case of an error
|
* @return boolean true on success or false in case of an error
|
||||||
*/
|
*/
|
||||||
private function __removeFromProcesses($user, $states = array(), $newuser=null) { /* {{{ */
|
private function __removeFromProcesses($user, $states = array(), $newuser=null, $docs=null) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
/* Get a list of all reviews, even those of older document versions */
|
/* Get a list of all reviews, even those of older document versions */
|
||||||
|
@ -704,6 +705,12 @@ class SeedDMS_Core_User { /* {{{ */
|
||||||
foreach ($reviewStatus["indstatus"] as $ri) {
|
foreach ($reviewStatus["indstatus"] as $ri) {
|
||||||
if(!($doc = $this->_dms->getDocument($ri['documentID'])))
|
if(!($doc = $this->_dms->getDocument($ri['documentID'])))
|
||||||
continue;
|
continue;
|
||||||
|
if($docs) {
|
||||||
|
if(!in_array($doc->getID(), $docs))
|
||||||
|
continue;
|
||||||
|
if(!$doc->isLatestContent($ri['version']))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if($newuser && $doc->getAccessMode($newuser) < M_READ)
|
if($newuser && $doc->getAccessMode($newuser) < M_READ)
|
||||||
continue;
|
continue;
|
||||||
if($ri['status'] != -2 && (!isset($states['review']) || in_array($ri['status'], $states['review']))) {
|
if($ri['status'] != -2 && (!isset($states['review']) || in_array($ri['status'], $states['review']))) {
|
||||||
|
@ -716,14 +723,12 @@ class SeedDMS_Core_User { /* {{{ */
|
||||||
}
|
}
|
||||||
/* Only reviews not done already can be transferred to a new user */
|
/* Only reviews not done already can be transferred to a new user */
|
||||||
if($newuser && $ri['status'] == 0) {
|
if($newuser && $ri['status'] == 0) {
|
||||||
if($doc = $this->_dms->getDocument($ri['documentID'])) {
|
if($version = $doc->getContentByVersion($ri['version'])) {
|
||||||
if($version = $doc->getContentByVersion($ri['version'])) {
|
$ret = $version->addIndReviewer($newuser, $user);
|
||||||
$ret = $version->addIndReviewer($newuser, $user);
|
/* returns -3 if the user is already a reviewer */
|
||||||
/* returns -3 if the user is already a reviewer */
|
if($ret === false || ($ret < 0 && $ret != -3)) {
|
||||||
if($ret === false || ($ret < 0 && $ret != -3)) {
|
$db->rollbackTransaction();
|
||||||
$db->rollbackTransaction();
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,6 +742,12 @@ class SeedDMS_Core_User { /* {{{ */
|
||||||
foreach ($approvalStatus["indstatus"] as $ai) {
|
foreach ($approvalStatus["indstatus"] as $ai) {
|
||||||
if(!($doc = $this->_dms->getDocument($ai['documentID'])))
|
if(!($doc = $this->_dms->getDocument($ai['documentID'])))
|
||||||
continue;
|
continue;
|
||||||
|
if($docs) {
|
||||||
|
if(!in_array($doc->getID(), $docs))
|
||||||
|
continue;
|
||||||
|
if(!$doc->isLatestContent($ai['version']))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if($newuser && $doc->getAccessMode($newuser) < M_READ)
|
if($newuser && $doc->getAccessMode($newuser) < M_READ)
|
||||||
continue;
|
continue;
|
||||||
if($ai['status'] != -2 && (!isset($states['approval']) || in_array($ai['status'], $states['approval']))) {
|
if($ai['status'] != -2 && (!isset($states['approval']) || in_array($ai['status'], $states['approval']))) {
|
||||||
|
@ -749,14 +760,12 @@ class SeedDMS_Core_User { /* {{{ */
|
||||||
}
|
}
|
||||||
/* Only approvals not done already can be transferred to a new user */
|
/* Only approvals not done already can be transferred to a new user */
|
||||||
if($newuser && $ai['status'] == 0) {
|
if($newuser && $ai['status'] == 0) {
|
||||||
if($doc = $this->_dms->getDocument($ai['documentID'])) {
|
if($version = $doc->getContentByVersion($ai['version'])) {
|
||||||
if($version = $doc->getContentByVersion($ai['version'])) {
|
$ret = $version->addIndReviewer($newuser, $user);
|
||||||
$ret = $version->addIndReviewer($newuser, $user);
|
/* returns -3 if the user is already a reviewer */
|
||||||
/* returns -3 if the user is already a reviewer */
|
if($ret === false || ($ret < 0 && $ret != -3)) {
|
||||||
if($ret === false || ($ret < 0 && $ret != -3)) {
|
$db->rollbackTransaction();
|
||||||
$db->rollbackTransaction();
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -775,14 +784,14 @@ class SeedDMS_Core_User { /* {{{ */
|
||||||
* @param object $user the user doing the removal (needed for entry in
|
* @param object $user the user doing the removal (needed for entry in
|
||||||
* review and approve log).
|
* review and approve log).
|
||||||
* @param array $states remove user only from reviews/approvals in one of the states
|
* @param array $states remove user only from reviews/approvals in one of the states
|
||||||
* @param object user who takes over the processes
|
* @param object $newuser user who takes over the processes
|
||||||
* @return boolean true on success or false in case of an error
|
* @return boolean true on success or false in case of an error
|
||||||
*/
|
*/
|
||||||
public function removeFromProcesses($user, $states=array(), $newuser=null) { /* {{{ */
|
public function removeFromProcesses($user, $states=array(), $newuser=null, $docs=null) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
if(!$this->__removeFromProcesses($user, $states, $newuser)) {
|
if(!$this->__removeFromProcesses($user, $states, $newuser, $docs)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user