From f8f1e3fd73c5cde3d616c387e6f02a3f821eb489 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 24 Feb 2021 13:23:49 +0100 Subject: [PATCH] take over mandatory reviewers and approvers --- webdav/webdav.php | 62 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/webdav/webdav.php b/webdav/webdav.php index dd900621c..43d044a43 100644 --- a/webdav/webdav.php +++ b/webdav/webdav.php @@ -716,6 +716,20 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server if($this->logger) $this->logger->log('PUT: adding new version', PEAR_LOG_INFO); + $reviewers = array('i'=>[], 'g'=>[]); + $approvers = array('i'=>[], 'g'=>[]); + $workflow = null; + if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') { + if($settings->_workflowMode == 'traditional') { + $reviewers = getMandatoryReviewers($document->getFolder(), $this->user); + } + $approvers = getMandatoryApprovers($document->getFolder(), $this->user); + } elseif($settings->_workflowMode == 'advanced') { + if($workflows = $user->getMandatoryWorkflows()) { + $workflow = array_shift($workflows); + } + } + $controller = Controller::factory('UpdateDocument'); $controller->setParam('dms', $this->dms); $controller->setParam('user', $this->user); @@ -728,10 +742,10 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $controller->setParam('userfilename', $name); $controller->setParam('filetype', $fileType); $controller->setParam('userfiletype', $mimetype); - $controller->setParam('reviewers', array()); - $controller->setParam('approvers', array()); + $controller->setParam('reviewers', $reviewers); + $controller->setParam('approvers', $approvers); $controller->setParam('attributes', array()); - $controller->setParam('workflow', null); + $controller->setParam('workflow', $workflow); if(!$content = $controller->run()) { // if(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) { @@ -784,6 +798,20 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server } */ + $reviewers = array('i'=>[], 'g'=>[]); + $approvers = array('i'=>[], 'g'=>[]); + $workflow = null; + if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') { + if($settings->_workflowMode == 'traditional') { + $reviewers = getMandatoryReviewers($folder, $this->user); + } + $approvers = getMandatoryApprovers($folder, $this->user); + } elseif($settings->_workflowMode == 'advanced') { + if($workflows = $user->getMandatoryWorkflows()) { + $workflow = array_shift($workflows); + } + } + $controller = Controller::factory('AddDocument'); $controller->setParam('dms', $this->dms); $controller->setParam('user', $this->user); @@ -805,13 +833,13 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $controller->setParam('sequence', $minmax['min'] - 1); else $controller->setParam('sequence', $minmax['max'] + 1); - $controller->setParam('reviewers', array()); - $controller->setParam('approvers', array()); + $controller->setParam('reviewers', $reviewers); + $controller->setParam('approvers', $approvers); $controller->setParam('reqversion', 0); $controller->setParam('versioncomment', ''); $controller->setParam('attributes', array()); $controller->setParam('attributesversion', array()); - $controller->setParam('workflow', null); + $controller->setParam('workflow', $workflow); $controller->setParam('notificationgroups', array()); $controller->setParam('notificationusers', array()); $controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText); @@ -1343,7 +1371,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server return "204 No Content"; } elseif(get_class($objdest) == $this->dms->getClassname('folder')) { if($this->logger) - $this->logger->log('COPY: copy \''.$objdest->getName().'\' to folder '.$objdest->getName().'', PEAR_LOG_INFO); + $this->logger->log('COPY: copy \''.$objsource->getName().'\' to folder '.$objdest->getName().'', PEAR_LOG_INFO); /* Currently no support for copying folders */ if(get_class($objsource) == $this->dms->getClassname('folder')) { @@ -1365,6 +1393,20 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server } */ + $reviewers = array('i'=>[], 'g'=>[]); + $approvers = array('i'=>[], 'g'=>[]); + $workflow = null; + if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') { + if($settings->_workflowMode == 'traditional') { + $reviewers = getMandatoryReviewers($objdest, $this->user); + } + $approvers = getMandatoryApprovers($objdest, $this->user); + } elseif($settings->_workflowMode == 'advanced') { + if($workflows = $user->getMandatoryWorkflows()) { + $workflow = array_shift($workflows); + } + } + /* get the latest content of the source object */ $content = $objsource->getLatestContent(); $fspath = $this->dms->contentDir.'/'.$content->getPath(); @@ -1390,13 +1432,13 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $controller->setParam('sequence', $minmax['min'] - 1); else $controller->setParam('sequence', $minmax['max'] + 1); - $controller->setParam('reviewers', array()); - $controller->setParam('approvers', array()); + $controller->setParam('reviewers', $reviewers); + $controller->setParam('approvers', $approvers); $controller->setParam('reqversion', 0); $controller->setParam('versioncomment', ''); $controller->setParam('attributes', array()); $controller->setParam('attributesversion', array()); - $controller->setParam('workflow', null); + $controller->setParam('workflow', $workflow); $controller->setParam('notificationgroups', array()); $controller->setParam('notificationusers', array()); $controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText);