diff --git a/op/op.AddDocument.php b/op/op.AddDocument.php index 966eedc75..375494c75 100644 --- a/op/op.AddDocument.php +++ b/op/op.AddDocument.php @@ -206,11 +206,19 @@ if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'tra } } } elseif($settings->_workflowMode == 'advanced') { - if(!$workflow = $user->getMandatoryWorkflow()) { + if(!$workflows = $user->getMandatoryWorkflows()) { if(isset($_POST["workflow"])) $workflow = $dms->getWorkflow($_POST["workflow"]); else $workflow = null; + } else { + /* If there is excactly 1 mandatory workflow, then set no matter what has + * been posted in 'workflow', otherwise check if the posted workflow is in the + * list of mandatory workflows. If not, then take the first one. + */ + $workflow = array_shift($workflows); + foreach($workflows as $mw) + if($mw->getID() == $_POST['workflow']) {$workflow = $mw; break;} } } diff --git a/op/op.UpdateDocument.php b/op/op.UpdateDocument.php index 5ce4dba94..0aa0cd557 100644 --- a/op/op.UpdateDocument.php +++ b/op/op.UpdateDocument.php @@ -185,11 +185,19 @@ if ($_FILES['userfile']['error'] == 0) { } } } elseif($settings->_workflowMode == 'advanced') { - if(!$workflow = $user->getMandatoryWorkflow()) { + if(!$workflows = $user->getMandatoryWorkflows()) { if(isset($_POST["workflow"])) $workflow = $dms->getWorkflow($_POST["workflow"]); else $workflow = null; + } else { + /* If there is excactly 1 mandatory workflow, then set no matter what has + * been posted in 'workflow', otherwise check if the posted workflow is in the + * list of mandatory workflows. If not, then take the first one. + */ + $workflow = array_shift($workflows); + foreach($workflows as $mw) + if($mw->getID() == $_POST['workflow']) {$workflow = $mw; break;} } }