a list of mandatory workflows can be set

This commit is contained in:
Uwe Steinmann 2016-01-27 16:20:12 +01:00
parent a68954725e
commit 380c916c66
2 changed files with 19 additions and 12 deletions

View File

@ -94,10 +94,13 @@ if ($action == "adduser") {
} }
else UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); else UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
if(isset($_POST["workflow"])) { if(isset($_POST["workflows"]) && $_POST["workflows"]) {
$workflow = $dms->getWorkflow($_POST["workflow"]); $workflows = array();
if($workflow) foreach($_POST["workflows"] as $workflowid)
$newUser->setMandatoryWorkflow($workflow); if($tmp = $dms->getWorkflow($workflowid))
$workflows[] = $tmp;
if($workflows)
$newUser->setMandatoryWorkflows($workflows);
} }
if (isset($_POST["usrReviewers"])){ if (isset($_POST["usrReviewers"])){
@ -245,13 +248,14 @@ else if ($action == "edituser") {
if(!$isDisabled) if(!$isDisabled)
$editedUser->clearLoginFailures(); $editedUser->clearLoginFailures();
} }
if(isset($_POST["workflow"]) && $_POST["workflow"]) { if(isset($_POST["workflows"]) && $_POST["workflows"]) {
$currworkflow = $editedUser->getMandatoryWorkflow(); $workflows = array();
if (!$currworkflow || ($currworkflow->getID() != $_POST["workflow"])) { foreach($_POST["workflows"] as $workflowid) {
$workflow = $dms->getWorkflow($_POST["workflow"]); if($tmp = $dms->getWorkflow($workflowid))
if($workflow) $workflows[] = $tmp;
$editedUser->setMandatoryWorkflow($workflow);
} }
if($workflows)
$editedUser->setMandatoryWorkflows($workflows);
} else { } else {
$editedUser->delMandatoryWorkflow(); $editedUser->delMandatoryWorkflow();
} }

View File

@ -374,12 +374,15 @@ $(document).ready( function() {
<div class="cbSelectTitle"><?php printMLText("workflow");?>:</div> <div class="cbSelectTitle"><?php printMLText("workflow");?>:</div>
</td> </td>
<td> <td>
<select name="workflow" data-placeholder="<?php printMLText('select_workflow'); ?>"> <select class="chzn-select" name="workflows[]" multiple="multiple" data-placeholder="<?php printMLText('select_workflow'); ?>">
<?php <?php
print "<option value=\"\">"."</option>"; print "<option value=\"\">"."</option>";
$mandatoryworkflows = $currUser ? $currUser->getMandatoryWorkflows() : array();
foreach ($workflows as $workflow) { foreach ($workflows as $workflow) {
print "<option value=\"".$workflow->getID()."\""; print "<option value=\"".$workflow->getID()."\"";
if($currUser && $currUser->getMandatoryWorkflow() && $currUser->getMandatoryWorkflow()->getID() == $workflow->getID()) $checked = false;
foreach($mandatoryworkflows as $mw) if($mw->getID() == $workflow->getID()) $checked = true;
if($checked)
echo " selected=\"selected\""; echo " selected=\"selected\"";
print ">". htmlspecialchars($workflow->getName())."</option>"; print ">". htmlspecialchars($workflow->getName())."</option>";
} }