Commit 64a4e3194da2bc9d7174d1ed6a4cd4dd862130a6

Authored by bshuttle
1 parent 2d60dffd

workflow trigger upgrade.



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5632 c91229c3-7414-0410-bfa2-8a42b809f60b
docs/VERSION.txt
1   -3.0.3.2
  1 +3.0.3.3
... ...
lib/upgrades/UpgradeFunctions.inc.php
... ... @@ -39,6 +39,7 @@ class UpgradeFunctions {
39 39 "3.0.1.4" => array('createWorkflowPermission'),
40 40 "3.0.2" => array("fixDocumentRoleAllocation"),
41 41 "3.0.3.2" => array("createFolderDetailsPermission"),
  42 + "3.0.3.3" => array("generateWorkflowTriggers"),
42 43 );
43 44  
44 45 var $descriptions = array(
... ... @@ -54,6 +55,7 @@ class UpgradeFunctions {
54 55 'createWorkflowPermission' => 'Create the Core: Manage Workflow',
55 56 'fixDocumentRoleAllocation' => 'Fix the document role allocation upgrade from 3.0.1',
56 57 'createFolderDetailsPermission' => 'Create the Core: Folder Details permission',
  58 + 'generateWorkflowTriggers' => 'Migrate old in-transition guards to triggers',
57 59 );
58 60 var $phases = array(
59 61 "setPermissionFolder" => 1,
... ... @@ -690,6 +692,74 @@ class UpgradeFunctions {
690 692 DBUtil::commit();
691 693 }
692 694 // }}}
  695 +
  696 +
  697 + function generateWorkflowTriggers() {
  698 +
  699 + require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php');
  700 +
  701 + // get all the transitions, and add a trigger to the util with the appropriate settings.
  702 + $KTWFTriggerReg =& KTWorkflowTriggerRegistry::getSingleton();
  703 + $aTransitions = KTWorkflowTransition::getList();
  704 + foreach ($aTransitions as $oTransition) {
  705 +
  706 + // guard perm
  707 + $iGuardPerm = $oTransition->getGuardPermissionId();
  708 + if (!is_null($iGuardPerm)) {
  709 +
  710 + $sNamespace = 'ktcore.workflowtriggers.permissionguard';
  711 + $oPerm = KTPermission::get($iGuardPerm);
  712 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
  713 + $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
  714 + 'transitionid' => KTUtil::getId($oTransition),
  715 + 'namespace' => $sNamespace,
  716 + 'config' => array('perms' => array($oPerm->getName())),
  717 + ));
  718 +
  719 + }
  720 + // guard group
  721 + $iGuardGroup = $oTransition->getGuardGroupId();
  722 + if (!is_null($iGuardGroup)) {
  723 +
  724 + $sNamespace = 'ktcore.workflowtriggers.groupguard';
  725 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
  726 + $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
  727 + 'transitionid' => KTUtil::getId($oTransition),
  728 + 'namespace' => $sNamespace,
  729 + 'config' => array('group_id' => $iGuardGroup),
  730 + ));
  731 +
  732 + }
  733 + // guard role
  734 + $iGuardRole = $oTransition->getGuardRoleId();
  735 + if (!is_null($iGuardRole)) {
  736 +
  737 + $sNamespace = 'ktcore.workflowtriggers.roleguard';
  738 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
  739 + $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
  740 + 'transitionid' => KTUtil::getId($oTransition),
  741 + 'namespace' => $sNamespace,
  742 + 'config' => array('role_id' => $iGuardRole),
  743 + ));
  744 +
  745 + }
  746 + // guard condition
  747 + $iGuardCondition = $oTransition->getGuardConditionId();
  748 + if (!is_null($iGuardCondition)) {
  749 +
  750 + $sNamespace = 'ktcore.workflowtriggers.conditionguard';
  751 + $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
  752 + $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array(
  753 + 'transitionid' => KTUtil::getId($oTransition),
  754 + 'namespace' => $sNamespace,
  755 + 'config' => array('condition_id' => $iGuardCondition),
  756 + ));
  757 +
  758 + }
  759 + }
  760 +
  761 + }
  762 +
693 763 }
694 764  
695 765 ?>
... ...