[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 ************************************************************************************/ 10 require_once ('include/events/SqlResultIterator.inc'); 11 require_once ('VTWorkflowManager.inc'); 12 require_once ('VTEntityCache.inc'); 13 14 require_once 'include/Webservices/Utils.php'; 15 require_once ("modules/Users/Users.php"); 16 require_once ("include/Webservices/VtigerCRMObject.php"); 17 require_once ("include/Webservices/VtigerCRMObjectMeta.php"); 18 require_once ("include/Webservices/DataTransform.php"); 19 require_once ("include/Webservices/WebServiceError.php"); 20 require_once 'include/utils/utils.php'; 21 require_once 'include/Webservices/ModuleTypes.php'; 22 require_once ('include/Webservices/Retrieve.php'); 23 require_once ('include/Webservices/Update.php'); 24 require_once 'include/Webservices/WebserviceField.php'; 25 require_once 'include/Webservices/EntityMeta.php'; 26 require_once 'include/Webservices/VtigerWebserviceObject.php'; 27 require_once ('VTWorkflowUtils.php'); 28 29 /* 30 * VTEventHandler 31 */ 32 33 class VTWorkflowEventHandler extends VTEventHandler { 34 35 /** 36 * Push tasks to the task queue if the conditions are true 37 * @param $entityData A VTEntityData object representing the entity. 38 */ 39 function handleEvent($eventName, $entityData, $entityCache = false) { 40 $util = new VTWorkflowUtils(); 41 $user = $util->adminUser(); 42 global $adb; 43 $isNew = $entityData->isNew(); 44 45 if (!$entityCache) { 46 $entityCache = new VTEntityCache($user); 47 } 48 49 $wsModuleName = $util->toWSModuleName($entityData); 50 $wsId = vtws_getWebserviceEntityId($wsModuleName, 51 $entityData->getId()); 52 $entityData = $entityCache->forId($wsId); 53 54 /* 55 * Customer - Feature #10254 Configuring all Email notifications including Ticket notifications 56 * workflows are intialised from ModCommentsHandler.php 57 * While adding a comment on any record which are supporting Comments ModCommentsHandler will trigger 58 */ 59 if (!is_array($this->workflows)) { 60 $wfs = new VTWorkflowManager($adb); 61 $this->workflows = $wfs->getWorkflowsForModule($entityData->getModuleName()); 62 } 63 $workflows = $this->workflows; 64 65 foreach ($workflows as $workflow) { 66 if (!is_a($workflow, 'Workflow')) 67 continue; 68 switch ($workflow->executionCondition) { 69 case VTWorkflowManager::$ON_FIRST_SAVE: { 70 if ($isNew) { 71 $doEvaluate = true; 72 } else { 73 $doEvaluate = false; 74 } 75 break; 76 } 77 case VTWorkflowManager::$ONCE: { 78 $entity_id = vtws_getIdComponents($entityData->getId()); 79 $entity_id = $entity_id[1]; 80 if ($workflow->isCompletedForRecord($entity_id)) { 81 $doEvaluate = false; 82 } else { 83 $doEvaluate = true; 84 } 85 break; 86 } 87 case VTWorkflowManager::$ON_EVERY_SAVE: { 88 $doEvaluate = true; 89 break; 90 } 91 case VTWorkflowManager::$ON_MODIFY: { 92 $doEvaluate = !($isNew); 93 break; 94 } 95 case VTWorkflowManager::$MANUAL: { 96 $doEvaluate = false; 97 break; 98 } 99 case VTWorkflowManager::$ON_SCHEDULE:{ 100 $doEvaluate = false; 101 break; 102 } 103 default: { 104 throw new Exception("Should never come here! Execution Condition:" . $workflow->executionCondition); 105 } 106 } 107 if ($doEvaluate && $workflow->evaluate($entityCache, $entityData->getId())) { 108 if (VTWorkflowManager::$ONCE == $workflow->executionCondition) { 109 $entity_id = vtws_getIdComponents($entityData->getId()); 110 $entity_id = $entity_id[1]; 111 $workflow->markAsCompletedForRecord($entity_id); 112 } 113 114 $workflow->performTasks($entityData); 115 } 116 } 117 $util->revertUser(); 118 } 119 120 } 121 122 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |