function generateWorkflowTriggers()
 {
     require_once KT_LIB_DIR . '/workflow/workflowutil.inc.php';
     // get all the transitions, and add a trigger to the util with the appropriate settings.
     $KTWFTriggerReg =& KTWorkflowTriggerRegistry::getSingleton();
     $aTransitions = KTWorkflowTransition::getList();
     foreach ($aTransitions as $oTransition) {
         // guard perm
         $iGuardPerm = $oTransition->getGuardPermissionId();
         if (!is_null($iGuardPerm)) {
             $sNamespace = 'ktcore.workflowtriggers.permissionguard';
             $oPerm = KTPermission::get($iGuardPerm);
             $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
             $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array('transitionid' => KTUtil::getId($oTransition), 'namespace' => $sNamespace, 'config' => array('perms' => array($oPerm->getName()))));
         }
         // guard group
         $iGuardGroup = $oTransition->getGuardGroupId();
         if (!is_null($iGuardGroup)) {
             $sNamespace = 'ktcore.workflowtriggers.groupguard';
             $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
             $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array('transitionid' => KTUtil::getId($oTransition), 'namespace' => $sNamespace, 'config' => array('group_id' => $iGuardGroup)));
         }
         // guard role
         $iGuardRole = $oTransition->getGuardRoleId();
         if (!is_null($iGuardRole)) {
             $sNamespace = 'ktcore.workflowtriggers.roleguard';
             $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
             $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array('transitionid' => KTUtil::getId($oTransition), 'namespace' => $sNamespace, 'config' => array('role_id' => $iGuardRole)));
         }
         // guard condition
         $iGuardCondition = $oTransition->getGuardConditionId();
         if (!is_null($iGuardCondition)) {
             $sNamespace = 'ktcore.workflowtriggers.conditionguard';
             $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($sNamespace);
             $oTriggerConfig = KTWorkflowTriggerInstance::createFromArray(array('transitionid' => KTUtil::getId($oTransition), 'namespace' => $sNamespace, 'config' => array('condition_id' => $iGuardCondition)));
         }
     }
 }
 function getTriggersForTransition($oTransition)
 {
     $oKTWorkflowTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
     $aTriggers = array();
     $aTriggerInstances = KTWorkflowTriggerInstance::getByTransition($oTransition);
     foreach ($aTriggerInstances as $oTriggerInstance) {
         $oTrigger = $oKTWorkflowTriggerRegistry->getWorkflowTrigger($oTriggerInstance->getNamespace());
         if (PEAR::isError($oTrigger)) {
             return $oTrigger;
         }
         $oTrigger->loadConfig($oTriggerInstance);
         $aTriggers[] = $oTrigger;
     }
     return $aTriggers;
 }
Esempio n. 3
0
 /**
  * Load the plugins into the global space
  *
  * @param array $aPlugins
  */
 function load($aPlugins)
 {
     require_once KT_LIB_DIR . '/actions/actionregistry.inc.php';
     require_once KT_LIB_DIR . '/actions/portletregistry.inc.php';
     require_once KT_LIB_DIR . '/triggers/triggerregistry.inc.php';
     require_once KT_LIB_DIR . '/plugins/pageregistry.inc.php';
     require_once KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php';
     require_once KT_LIB_DIR . "/plugins/KTAdminNavigation.php";
     require_once KT_LIB_DIR . "/dashboard/dashletregistry.inc.php";
     require_once KT_LIB_DIR . "/i18n/i18nregistry.inc.php";
     require_once KT_LIB_DIR . "/help/help.inc.php";
     require_once KT_LIB_DIR . "/workflow/workflowutil.inc.php";
     require_once KT_LIB_DIR . "/widgets/widgetfactory.inc.php";
     require_once KT_LIB_DIR . "/validation/validatorfactory.inc.php";
     require_once KT_LIB_DIR . "/browse/columnregistry.inc.php";
     require_once KT_LIB_DIR . "/browse/criteriaregistry.php";
     require_once KT_LIB_DIR . "/authentication/interceptorregistry.inc.php";
     $oPRegistry =& KTPortletRegistry::getSingleton();
     $oTRegistry =& KTTriggerRegistry::getSingleton();
     $oARegistry =& KTActionRegistry::getSingleton();
     $oPageRegistry =& KTPageRegistry::getSingleton();
     $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
     $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
     $oDashletRegistry =& KTDashletRegistry::getSingleton();
     $oi18nRegistry =& KTi18nRegistry::getSingleton();
     $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
     $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
     $oColumnRegistry =& KTColumnRegistry::getSingleton();
     $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
     $oTemplating =& KTTemplating::getSingleton();
     $oWidgetFactory =& KTWidgetFactory::getSingleton();
     $oValidatorFactory =& KTValidatorFactory::getSingleton();
     $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
     $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
     $oKTPluginRegistry =& KTPluginRegistry::getSingleton();
     // Loop through the loaded plugins and register them for access
     foreach ($aPlugins as $plugin) {
         $sName = $plugin['namespace'];
         $sParams = $plugin['object'];
         $aParams = explode('|', $sParams);
         $sClassType = $plugin['classtype'];
         switch ($sClassType) {
             case 'portlet':
                 $aLocation = unserialize($aParams[0]);
                 if ($aLocation != false) {
                     $aParams[0] = $aLocation;
                 }
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $aParams);
                 break;
             case 'trigger':
                 if (isset($aParams[4])) {
                     $aParams[4] = KTPluginUtil::getFullPath($aParams[4]);
                 }
                 call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $aParams);
                 break;
             case 'action':
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 call_user_func_array(array(&$oARegistry, 'registerAction'), $aParams);
                 break;
             case 'page':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oPageRegistry, 'registerPage'), $aParams);
                 break;
             case 'authentication_provider':
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 $aParams[0] = _kt($aParams[0]);
                 call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $aParams);
                 break;
             case 'admin_category':
                 $aParams[1] = _kt($aParams[1]);
                 $aParams[2] = _kt($aParams[2]);
                 call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $aParams);
                 break;
             case 'admin_page':
                 if (isset($aParams[5])) {
                     $aParams[5] = KTPluginUtil::getFullPath($aParams[5]);
                 }
                 $aParams[3] = _kt($aParams[3]);
                 $aParams[4] = _kt($aParams[4]);
                 call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $aParams);
                 break;
             case 'dashlet':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $aParams);
                 break;
             case 'i18nlang':
                 if (isset($aParams[2]) && $aParams[2] != 'default') {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $aParams);
             case 'i18n':
                 if (isset($aParams[2])) {
                     $aParams[1] = $aParams[2];
                     unset($aParams[2]);
                 } else {
                     $aParams[1] = KTPluginUtil::getFullPath($aParams[1]);
                 }
                 call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $aParams);
                 break;
             case 'language':
                 call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $aParams);
                 break;
             case 'help_language':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $aParams);
                 break;
             case 'workflow_trigger':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $aParams);
                 break;
             case 'column':
                 if (isset($aParams[3])) {
                     $aParams[3] = KTPluginUtil::getFullPath($aParams[3]);
                 }
                 $aParams[0] = _kt($aParams[0]);
                 call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $aParams);
                 break;
             case 'view':
                 $aParams[0] = _kt($aParams[0]);
                 call_user_func_array(array(&$oColumnRegistry, 'registerView'), $aParams);
                 break;
             case 'notification_handler':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $aParams);
                 break;
             case 'template_location':
                 if (isset($aParams[1])) {
                     $aParams[1] = KTPluginUtil::getFullPath($aParams[1]);
                 }
                 call_user_func_array(array(&$oTemplating, 'addLocation2'), $aParams);
                 break;
             case 'criterion':
                 $aInit = unserialize($aParams[3]);
                 if ($aInit != false) {
                     $aParams[3] = $aInit;
                 }
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $aParams);
                 break;
             case 'widget':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $aParams);
                 break;
             case 'validator':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $aParams);
                 break;
             case 'interceptor':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $aParams);
                 break;
             case 'plugin':
                 if (isset($aParams[2])) {
                     $aParams[2] = KTPluginUtil::getFullPath($aParams[2]);
                 }
                 $oKTPluginRegistry->_aPluginDetails[$sName] = $aParams;
                 break;
         }
     }
 }
Esempio n. 4
0
 /**
  * Original load function for the plugins
  * @deprecated
  */
 function load2()
 {
     if (!$this->isRegistered()) {
         return;
     }
     $this->setup();
     require_once KT_LIB_DIR . '/actions/actionregistry.inc.php';
     require_once KT_LIB_DIR . '/actions/portletregistry.inc.php';
     require_once KT_LIB_DIR . '/triggers/triggerregistry.inc.php';
     require_once KT_LIB_DIR . '/plugins/pageregistry.inc.php';
     require_once KT_LIB_DIR . '/authentication/authenticationproviderregistry.inc.php';
     require_once KT_LIB_DIR . "/plugins/KTAdminNavigation.php";
     require_once KT_LIB_DIR . "/dashboard/dashletregistry.inc.php";
     require_once KT_LIB_DIR . "/i18n/i18nregistry.inc.php";
     require_once KT_LIB_DIR . "/help/help.inc.php";
     require_once KT_LIB_DIR . "/workflow/workflowutil.inc.php";
     require_once KT_LIB_DIR . "/widgets/widgetfactory.inc.php";
     require_once KT_LIB_DIR . "/validation/validatorfactory.inc.php";
     require_once KT_LIB_DIR . "/browse/columnregistry.inc.php";
     require_once KT_LIB_DIR . "/browse/criteriaregistry.php";
     require_once KT_LIB_DIR . "/authentication/interceptorregistry.inc.php";
     $oPRegistry =& KTPortletRegistry::getSingleton();
     $oTRegistry =& KTTriggerRegistry::getSingleton();
     $oARegistry =& KTActionRegistry::getSingleton();
     $oPageRegistry =& KTPageRegistry::getSingleton();
     $oAPRegistry =& KTAuthenticationProviderRegistry::getSingleton();
     $oAdminRegistry =& KTAdminNavigationRegistry::getSingleton();
     $oDashletRegistry =& KTDashletRegistry::getSingleton();
     $oi18nRegistry =& KTi18nRegistry::getSingleton();
     $oKTHelpRegistry =& KTHelpRegistry::getSingleton();
     $oWFTriggerRegistry =& KTWorkflowTriggerRegistry::getSingleton();
     $oColumnRegistry =& KTColumnRegistry::getSingleton();
     $oNotificationHandlerRegistry =& KTNotificationRegistry::getSingleton();
     $oTemplating =& KTTemplating::getSingleton();
     $oWidgetFactory =& KTWidgetFactory::getSingleton();
     $oValidatorFactory =& KTValidatorFactory::getSingleton();
     $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton();
     $oInterceptorRegistry =& KTInterceptorRegistry::getSingleton();
     foreach ($this->_aPortlets as $k => $v) {
         call_user_func_array(array(&$oPRegistry, 'registerPortlet'), $v);
     }
     foreach ($this->_aTriggers as $k => $v) {
         call_user_func_array(array(&$oTRegistry, 'registerTrigger'), $v);
     }
     foreach ($this->_aActions as $k => $v) {
         call_user_func_array(array(&$oARegistry, 'registerAction'), $v);
     }
     foreach ($this->_aPages as $k => $v) {
         call_user_func_array(array(&$oPageRegistry, 'registerPage'), $v);
     }
     foreach ($this->_aAuthenticationProviders as $k => $v) {
         call_user_func_array(array(&$oAPRegistry, 'registerAuthenticationProvider'), $v);
     }
     foreach ($this->_aAdminCategories as $k => $v) {
         call_user_func_array(array(&$oAdminRegistry, 'registerCategory'), $v);
     }
     foreach ($this->_aAdminPages as $k => $v) {
         call_user_func_array(array(&$oAdminRegistry, 'registerLocation'), $v);
     }
     foreach ($this->_aDashlets as $k => $v) {
         call_user_func_array(array(&$oDashletRegistry, 'registerDashlet'), $v);
     }
     foreach ($this->_ai18n as $k => $v) {
         call_user_func_array(array(&$oi18nRegistry, 'registeri18n'), $v);
     }
     foreach ($this->_ai18nLang as $k => $v) {
         call_user_func_array(array(&$oi18nRegistry, 'registeri18nLang'), $v);
     }
     foreach ($this->_aLanguage as $k => $v) {
         call_user_func_array(array(&$oi18nRegistry, 'registerLanguage'), $v);
     }
     foreach ($this->_aHelpLanguage as $k => $v) {
         call_user_func_array(array(&$oKTHelpRegistry, 'registerHelp'), $v);
     }
     foreach ($this->_aWFTriggers as $k => $v) {
         call_user_func_array(array(&$oWFTriggerRegistry, 'registerWorkflowTrigger'), $v);
     }
     foreach ($this->_aColumns as $k => $v) {
         call_user_func_array(array(&$oColumnRegistry, 'registerColumn'), $v);
     }
     foreach ($this->_aViews as $k => $v) {
         call_user_func_array(array(&$oColumnRegistry, 'registerView'), $v);
     }
     foreach ($this->_aNotificationHandlers as $k => $v) {
         call_user_func_array(array(&$oNotificationHandlerRegistry, 'registerNotificationHandler'), $v);
     }
     foreach ($this->_aTemplateLocations as $k => $v) {
         call_user_func_array(array(&$oTemplating, 'addLocation'), $v);
     }
     foreach ($this->_aCriteria as $k => $v) {
         call_user_func_array(array(&$oCriteriaRegistry, 'registerCriterion'), $v);
     }
     foreach ($this->_aWidgets as $k => $v) {
         call_user_func_array(array(&$oWidgetFactory, 'registerWidget'), $v);
     }
     foreach ($this->_aValidators as $k => $v) {
         call_user_func_array(array(&$oValidatorFactory, 'registerValidator'), $v);
     }
     foreach ($this->_aInterceptors as $k => $v) {
         call_user_func_array(array(&$oInterceptorRegistry, 'registerInterceptor'), $v);
     }
 }
Esempio n. 5
0
 function do_deleteactiontrigger()
 {
     $oTriggerInstance =& KTWorkflowTriggerInstance::get($_REQUEST['fTriggerInstanceId']);
     if (PEAR::isError($oTriggerInstance)) {
         return $this->errorRedirectTo('managetransitionactions', _kt('Unable to load trigger.'));
     }
     // grab the transition ns from the request.
     $KTWFTriggerReg =& KTWorkflowTriggerRegistry::getSingleton();
     $this->startTransaction();
     $oTrigger = $KTWFTriggerReg->getWorkflowTrigger($oTriggerInstance->getNamespace());
     if (PEAR::isError($oTrigger)) {
         $this->errorRedirectTo('managetransitionactions', _kt('Unable to load trigger.'));
         exit(0);
     }
     $oTrigger->loadConfig($oTriggerInstance);
     $res = $oTriggerInstance->delete();
     if (PEAR::isError($res)) {
         $this->errorRedirectTo('managetransitionactions', _kt('Unable to delete trigger: ') . $res->getMessage(), 'fWorkflowId=' . $oWorkflow->getId() . '&fTransitionId=' . $oTransition->getId());
         exit(0);
     }
     $this->successRedirectTo('managetransitionactions', _kt('Trigger deleted.'));
     exit(0);
 }