Commit bc4529610cfa4dc5014394b6f632c684a4e106ca
1 parent
ca0fe63f
Add workflow control over the actions available in documents.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3734 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
35 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/administration/workflow/workflows.php
| ... | ... | @@ -38,6 +38,8 @@ class KTWorkflowDispatcher extends KTStandardDispatcher { |
| 38 | 38 | 'aStates' => KTWorkflowState::getByWorkflow($oWorkflow), |
| 39 | 39 | 'aTransitions' => KTWorkflowTransition::getByWorkflow($oWorkflow), |
| 40 | 40 | 'aPermissions' => KTPermission::getList(), |
| 41 | + 'aActions' => KTDocumentActionUtil::getAllDocumentActions(), | |
| 42 | + 'aActionsSelected' => KTWorkflowUtil::getControlledActionsForWorkflow($oWorkflow), | |
| 41 | 43 | )); |
| 42 | 44 | return $oTemplate; |
| 43 | 45 | } |
| ... | ... | @@ -48,6 +50,11 @@ class KTWorkflowDispatcher extends KTStandardDispatcher { |
| 48 | 50 | $oWorkflow =& KTDispatcherValidation::validateWorkflow($this, $_REQUEST['fWorkflowId']); |
| 49 | 51 | $oWorkflow->setName($_REQUEST['fName']); |
| 50 | 52 | $oWorkflow->setHumanName($_REQUEST['fName']); |
| 53 | + if (!empty($_REQUEST['fStartStateId'])) { | |
| 54 | + $oWorkflow->setStartStateId($_REQUEST['fStartStateId']); | |
| 55 | + } else { | |
| 56 | + $oWorkflow->setStartStateId(null); | |
| 57 | + } | |
| 51 | 58 | $res = $oWorkflow->update(); |
| 52 | 59 | KTDispatcherValidation::notErrorFalse($this, $res, array( |
| 53 | 60 | 'redirect_to' => array('editWorkflow', 'fWorkflowId=' . $oWorkflow->getId()), |
| ... | ... | @@ -73,6 +80,19 @@ class KTWorkflowDispatcher extends KTStandardDispatcher { |
| 73 | 80 | } |
| 74 | 81 | // }}} |
| 75 | 82 | |
| 83 | + // {{{ do_setWorkflowActions | |
| 84 | + function do_setWorkflowActions() { | |
| 85 | + $oWorkflow =& KTDispatcherValidation::validateWorkflow($this, $_REQUEST['fWorkflowId']); | |
| 86 | + $res = KTWorkflowUtil::setControlledActionsForWorkflow($oWorkflow, $_REQUEST['fActions']); | |
| 87 | + KTDispatcherValidation::notErrorFalse($this, $res, array( | |
| 88 | + 'redirect_to' => array('editWorkflow', 'fWorkflowId=' . $oWorkflow->getId()), | |
| 89 | + 'message' => 'Error saving workflow controlled actions', | |
| 90 | + )); | |
| 91 | + $this->successRedirectTo('editWorkflow', 'Changes saved', 'fWorkflowId=' . $oWorkflow->getId()); | |
| 92 | + exit(0); | |
| 93 | + } | |
| 94 | + // }}} | |
| 95 | + | |
| 76 | 96 | // }}} |
| 77 | 97 | |
| 78 | 98 | // {{{ STATE HANDLING |
| ... | ... | @@ -118,6 +138,8 @@ class KTWorkflowDispatcher extends KTStandardDispatcher { |
| 118 | 138 | 'aTransitionsTo' => $aTransitionsTo, |
| 119 | 139 | 'aTransitions' => $aTransitions, |
| 120 | 140 | 'aTransitionsSelected' => $aTransitionsSelected, |
| 141 | + 'aActions' => KTDocumentActionUtil::getDocumentActionsByNames(KTWorkflowUtil::getControlledActionsForWorkflow($oWorkflow)), | |
| 142 | + 'aActionsSelected' => KTWorkflowUtil::getEnabledActionsForState($oState), | |
| 121 | 143 | )); |
| 122 | 144 | return $oTemplate; |
| 123 | 145 | } |
| ... | ... | @@ -153,6 +175,19 @@ class KTWorkflowDispatcher extends KTStandardDispatcher { |
| 153 | 175 | } |
| 154 | 176 | // }}} |
| 155 | 177 | |
| 178 | + // {{{ do_setStateActions | |
| 179 | + function do_setStateActions() { | |
| 180 | + $oWorkflow =& KTDispatcherValidation::validateWorkflow($this, $_REQUEST['fWorkflowId']); | |
| 181 | + $oState =& KTDispatcherValidation::validateWorkflowState($this, $_REQUEST['fStateId']); | |
| 182 | + $res = KTWorkflowUtil::setEnabledActionsForState($oState, $_REQUEST['fActions']); | |
| 183 | + KTDispatcherValidation::notErrorFalse($this, $res, array( | |
| 184 | + 'redirect_to' => array('editState', 'fWorkflowId=' . $oWorkflow->getId(), '&fStateId=' . $oState->getId()), | |
| 185 | + 'message' => 'Error saving state enabled actions', | |
| 186 | + )); | |
| 187 | + $this->successRedirectTo('editState', 'Actions set', 'fWorkflowId=' . $oWorkflow->getId() . '&fStateId=' . $oState->getId()); | |
| 188 | + exit(0); | |
| 189 | + } | |
| 190 | + // }}} | |
| 156 | 191 | // }}} |
| 157 | 192 | |
| 158 | 193 | // {{{ TRANSITION HANDLING | ... | ... |