Commit a46e0c7dafa26d5b8e08dea4308431286e8d718e
1 parent
7b3e1cd5
KTS-4145: Copied Workflows contain Workflow Effects of original
Committed by: Jarrett Jordaan Reviewed by: Megan Watson
Showing
2 changed files
with
34 additions
and
5 deletions
lib/workflow/workflowtriggerinstance.inc.php
| @@ -70,8 +70,11 @@ class KTWorkflowTriggerInstance extends KTEntity { | @@ -70,8 +70,11 @@ class KTWorkflowTriggerInstance extends KTEntity { | ||
| 70 | 70 | ||
| 71 | // STATIC | 71 | // STATIC |
| 72 | function &get($iId) { return KTEntityUtil::get('KTWorkflowTriggerInstance', $iId); } | 72 | function &get($iId) { return KTEntityUtil::get('KTWorkflowTriggerInstance', $iId); } |
| 73 | - function &createFromArray($aOptions) { | ||
| 74 | - $aOptions['configarraytext'] = serialize($aOptions['config']); | 73 | + |
| 74 | + function &createFromArray($aOptions) { | ||
| 75 | + // Modified : Jarrett Jordaan | ||
| 76 | + // Removed Serialize, since the original is serialized already | ||
| 77 | + $aOptions['configarraytext'] = $aOptions['config']; | ||
| 75 | unset($aOptions['config']); | 78 | unset($aOptions['config']); |
| 76 | return KTEntityUtil::createFromArray('KTWorkflowTriggerInstance', $aOptions); | 79 | return KTEntityUtil::createFromArray('KTWorkflowTriggerInstance', $aOptions); |
| 77 | } | 80 | } |
plugins/ktcore/admin/workflowsv2.php
| @@ -195,6 +195,26 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | @@ -195,6 +195,26 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | ||
| 195 | return $oTemplate; | 195 | return $oTemplate; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | + /* | ||
| 199 | + * Copies state notifications | ||
| 200 | + * | ||
| 201 | + * @params KTWorkflowState $oldState to copy from | ||
| 202 | + * KTWorkflowState $newState to copy to | ||
| 203 | + * | ||
| 204 | + * @return true on success or PEAR error | ||
| 205 | + */ | ||
| 206 | + function copyStateNotifications ($oldState, $newState) { | ||
| 207 | + // we need the old one | ||
| 208 | + $aAllowed = KTWorkflowUtil::getInformedForState($oldState); | ||
| 209 | + // FIXME check that these are all users. | ||
| 210 | + $res = KTWorkflowUtil::setInformedForState($newState, $aAllowed); | ||
| 211 | + if (PEAR::isError($res)) { | ||
| 212 | + return $oForm->handleError($res->getMessage()); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + return true; | ||
| 216 | + } | ||
| 217 | + | ||
| 198 | function do_confirmCopy(){ | 218 | function do_confirmCopy(){ |
| 199 | $oSelWorkflow = KTWorkflow::get(KTUtil::arrayGet($_REQUEST, 'workflowId' , array())); | 219 | $oSelWorkflow = KTWorkflow::get(KTUtil::arrayGet($_REQUEST, 'workflowId' , array())); |
| 200 | $sWorkflowName = KTUtil::arrayGet($_REQUEST, 'workflowName' , array()); | 220 | $sWorkflowName = KTUtil::arrayGet($_REQUEST, 'workflowName' , array()); |
| @@ -232,7 +252,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | @@ -232,7 +252,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | ||
| 232 | $oForm->errorRedirectToMain(sprintf(_kt("Unexpected failure cloning state: %s"), $oNewState->getMessage())); | 252 | $oForm->errorRedirectToMain(sprintf(_kt("Unexpected failure cloning state: %s"), $oNewState->getMessage())); |
| 233 | } | 253 | } |
| 234 | 254 | ||
| 235 | - // Get all state permission assignments for old workflow transitions and copy for copied workflow state permission assignments | 255 | + // Get all state permission assignments for old workflow transitions |
| 256 | + // and copy for copied workflow state permission assignments | ||
| 236 | $aPermissionAssignments = KTWorkflowStatePermissionAssignment::getByState($oOldState); | 257 | $aPermissionAssignments = KTWorkflowStatePermissionAssignment::getByState($oOldState); |
| 237 | if(count($aPermissionAssignments) > 0){ | 258 | if(count($aPermissionAssignments) > 0){ |
| 238 | foreach ($aPermissionAssignments as $oPermAssign) { | 259 | foreach ($aPermissionAssignments as $oPermAssign) { |
| @@ -265,6 +286,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | @@ -265,6 +286,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | ||
| 265 | if (PEAR::isError($res)) { | 286 | if (PEAR::isError($res)) { |
| 266 | return $this->errorRedirectToMain(sprintf(_kt("Unable to copy disabled state actions: %s"), $res->getMessage())); | 287 | return $this->errorRedirectToMain(sprintf(_kt("Unable to copy disabled state actions: %s"), $res->getMessage())); |
| 267 | } | 288 | } |
| 289 | + | ||
| 290 | + $this->copyStateNotifications ($oOldState, $oNewState); | ||
| 268 | } | 291 | } |
| 269 | 292 | ||
| 270 | // update workflow and set initial state | 293 | // update workflow and set initial state |
| @@ -332,7 +355,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | @@ -332,7 +355,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | ||
| 332 | $this->errorRedirectToMain(sprintf(_kt("Failed to set transition origins: %s"), $res->getMessage())); | 355 | $this->errorRedirectToMain(sprintf(_kt("Failed to set transition origins: %s"), $res->getMessage())); |
| 333 | } | 356 | } |
| 334 | 357 | ||
| 335 | - // Get all triggers for old workflow transitions and copy for copied workflow transitions | 358 | + // Get all triggers for old workflow transitions and |
| 359 | + // copy for copied workflow transitions | ||
| 336 | $aTriggers = KTWorkflowTriggerInstance::getByTransition($oOldTransition); | 360 | $aTriggers = KTWorkflowTriggerInstance::getByTransition($oOldTransition); |
| 337 | if(count($aTriggers) > 0){ | 361 | if(count($aTriggers) > 0){ |
| 338 | foreach ($aTriggers as $oTrigger) { | 362 | foreach ($aTriggers as $oTrigger) { |
| @@ -354,6 +378,7 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | @@ -354,6 +378,7 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | ||
| 354 | } | 378 | } |
| 355 | } | 379 | } |
| 356 | } | 380 | } |
| 381 | + | ||
| 357 | return $this->successRedirectToMain(sprintf(_kt("%s successfully copied as %s"), $oSelWorkflow->getName(), $oNewWorkflow->getName())); | 382 | return $this->successRedirectToMain(sprintf(_kt("%s successfully copied as %s"), $oSelWorkflow->getName(), $oNewWorkflow->getName())); |
| 358 | } | 383 | } |
| 359 | 384 | ||
| @@ -2340,7 +2365,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | @@ -2340,7 +2365,8 @@ class KTWorkflowAdminV2 extends KTAdminDispatcher { | ||
| 2340 | 2365 | ||
| 2341 | if (!empty($sFilter)) { | 2366 | if (!empty($sFilter)) { |
| 2342 | $allowed = array(); | 2367 | $allowed = array(); |
| 2343 | - $q = sprintf('name like "%%%s%%"', DBUtil::escapeSimple($sFilter)); | 2368 | + // Modified Jarrett Jordaan Only notify enabled users |
| 2369 | + $q = sprintf('name like "%%%s%%" AND disabled = 0', DBUtil::escapeSimple($sFilter)); | ||
| 2344 | 2370 | ||
| 2345 | $aUsers = User::getList($q); | 2371 | $aUsers = User::getList($q); |
| 2346 | $aGroups = Group::getList($q); | 2372 | $aGroups = Group::getList($q); |