2015-06-01 12:01:56 +00:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Implementation of ReviseDocument controller
|
|
|
|
|
*
|
|
|
|
|
* @category DMS
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @license GPL 2
|
|
|
|
|
* @version @version@
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
|
* @version Release: @package_version@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class which does the busines logic for downloading a document
|
|
|
|
|
*
|
|
|
|
|
* @category DMS
|
|
|
|
|
* @package SeedDMS
|
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
|
* @version Release: @package_version@
|
|
|
|
|
*/
|
|
|
|
|
class SeedDMS_Controller_ReviseDocument extends SeedDMS_Controller_Common {
|
|
|
|
|
|
2024-04-04 11:56:14 +00:00
|
|
|
|
public $oldstatus;
|
|
|
|
|
|
|
|
|
|
public $newstatus;
|
|
|
|
|
|
2015-06-01 12:01:56 +00:00
|
|
|
|
public function run() {
|
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
|
$user = $this->params['user'];
|
|
|
|
|
$settings = $this->params['settings'];
|
|
|
|
|
$document = $this->params['document'];
|
|
|
|
|
$content = $this->params['content'];
|
|
|
|
|
$revisionstatus = $this->params['revisionstatus'];
|
|
|
|
|
$revisiontype = $this->params['revisiontype'];
|
|
|
|
|
$group = $this->params['group'];
|
|
|
|
|
$comment = $this->params['comment'];
|
2024-04-04 11:56:14 +00:00
|
|
|
|
$overallStatus = $content->getStatus();
|
|
|
|
|
$this->oldstatus = $overallStatus['status'];
|
|
|
|
|
$this->newstatus = $this->oldstatus;
|
2015-06-01 12:01:56 +00:00
|
|
|
|
|
2018-03-13 16:51:44 +00:00
|
|
|
|
/* if set to true, a single reject will reject the doc. If set to false
|
|
|
|
|
* all revisions will be collected first and afterwards the doc is rejected
|
|
|
|
|
* if one has rejected it. So in the very end the doc is rejected, but
|
|
|
|
|
* doc remainѕ in S_IN_REVISION until all have revised the doc
|
|
|
|
|
*/
|
2019-10-18 05:23:20 +00:00
|
|
|
|
$onevotereject = $this->params['onevotereject'];
|
2018-03-13 16:51:44 +00:00
|
|
|
|
|
2015-06-01 12:01:56 +00:00
|
|
|
|
/* Get the document id and name before removing the document */
|
|
|
|
|
$docname = $document->getName();
|
|
|
|
|
$documentid = $document->getID();
|
|
|
|
|
|
2015-06-01 15:34:52 +00:00
|
|
|
|
if(!$this->callHook('preReviseDocument', $content)) {
|
2015-06-01 12:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 15:34:52 +00:00
|
|
|
|
$result = $this->callHook('reviseDocument', $content);
|
2015-06-01 12:01:56 +00:00
|
|
|
|
if($result === null) {
|
|
|
|
|
|
|
|
|
|
if ($revisiontype == "ind") {
|
|
|
|
|
if(0 > $content->setRevision($user, $user, $revisionstatus, $comment)) {
|
|
|
|
|
$this->error = 1;
|
|
|
|
|
$this->errormsg = "revision_update_failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} elseif ($revisiontype == "grp") {
|
|
|
|
|
if(0 > $content->setRevision($group, $user, $revisionstatus, $comment)) {
|
|
|
|
|
$this->error = 1;
|
2017-01-25 13:51:38 +00:00
|
|
|
|
$this->errormsg = $ll."revision_update_failed";
|
2015-06-01 12:01:56 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check to see if the overall status for the document version needs to be
|
|
|
|
|
* updated.
|
|
|
|
|
*/
|
2015-06-01 15:34:52 +00:00
|
|
|
|
$result = $this->callHook('reviseUpdateDocumentStatus', $content);
|
2015-06-01 12:01:56 +00:00
|
|
|
|
if($result === null) {
|
2018-03-13 16:51:44 +00:00
|
|
|
|
if ($onevotereject && $revisionstatus == -1){
|
2024-04-04 11:56:14 +00:00
|
|
|
|
$this->newstatus = S_NEEDS_CORRECTION;
|
2018-01-30 18:19:40 +00:00
|
|
|
|
if(!$content->setStatus(S_NEEDS_CORRECTION,$comment,$user)) {
|
2015-06-01 12:01:56 +00:00
|
|
|
|
$this->error = 1;
|
|
|
|
|
$this->errormsg = "revision_update_failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$docRevisionStatus = $content->getRevisionStatus();
|
|
|
|
|
if (is_bool($docRevisionStatus) && !$docRevisionStatus) {
|
|
|
|
|
$this->error = 1;
|
|
|
|
|
$this->errormsg = "cannot_retrieve_revision_snapshot";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-03-13 16:51:44 +00:00
|
|
|
|
$revisionok = 0;
|
|
|
|
|
$revisionnotok = 0;
|
2015-06-01 12:01:56 +00:00
|
|
|
|
$revisionTotal = 0;
|
|
|
|
|
foreach ($docRevisionStatus as $drstat) {
|
|
|
|
|
if ($drstat["status"] == 1) {
|
2018-03-13 16:51:44 +00:00
|
|
|
|
$revisionok++;
|
|
|
|
|
}
|
|
|
|
|
if ($drstat["status"] == -1) {
|
|
|
|
|
$revisionnotok++;
|
2015-06-01 12:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
if ($drstat["status"] != -2) {
|
|
|
|
|
$revisionTotal++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-13 16:51:44 +00:00
|
|
|
|
// If all revisions have been done and there are no rejections,
|
|
|
|
|
// then release the document. If all revisions have been done but some
|
|
|
|
|
// of them were rejections then documents needs correction.
|
|
|
|
|
// Otherwise put it back into revision workflow
|
|
|
|
|
if ($revisionok == $revisionTotal) {
|
2024-04-04 11:56:14 +00:00
|
|
|
|
$this->newstatus=S_RELEASED;
|
|
|
|
|
if ($content->finishRevision($user, $this->newstatus, 'Finished revision workflow', getMLText("automatic_status_update"))) {
|
2017-01-24 13:20:10 +00:00
|
|
|
|
if(!$this->callHook('finishReviseDocument', $content)) {
|
|
|
|
|
}
|
2015-06-01 12:01:56 +00:00
|
|
|
|
}
|
2018-03-13 16:51:44 +00:00
|
|
|
|
} elseif (($revisionok + $revisionnotok) == $revisionTotal) {
|
2024-04-04 11:56:14 +00:00
|
|
|
|
$this->newstatus=S_NEEDS_CORRECTION;
|
|
|
|
|
// if ($content->finishRevision($user, $this->newstatus, 'Finished revision workflow', getMLText("automatic_status_update"))) {
|
|
|
|
|
if(!$content->setStatus($this->newstatus,$comment,$user)) {
|
2018-03-13 16:51:44 +00:00
|
|
|
|
$this->error = 1;
|
|
|
|
|
$this->errormsg = "revision_update_failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-06-01 12:01:56 +00:00
|
|
|
|
} else {
|
2024-04-04 11:56:14 +00:00
|
|
|
|
$this->newstatus=S_IN_REVISION;
|
|
|
|
|
if(!$content->setStatus($this->newstatus,$comment,$user)) {
|
2015-06-01 12:01:56 +00:00
|
|
|
|
$this->error = 1;
|
|
|
|
|
$this->errormsg = "revision_update_failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-01 15:34:52 +00:00
|
|
|
|
if(!$this->callHook('postReviseDocument', $content)) {
|
2015-06-01 12:01:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|