adminUser(); global $adb; $isNew = $entityData->isNew(); if (!$entityCache) { $entityCache = new VTEntityCache($user); } $wsModuleName = $util->toWSModuleName($entityData); $wsId = vtws_getWebserviceEntityId($wsModuleName, $entityData->getId()); $entityData = $entityCache->forId($wsId); /* * Customer - Feature #10254 Configuring all Email notifications including Ticket notifications * workflows are intialised from ModCommentsHandler.php * While adding a comment on any record which are supporting Comments ModCommentsHandler will trigger */ if (!is_array($this->workflows)) { $wfs = new VTWorkflowManager($adb); $this->workflows = $wfs->getWorkflowsForModule($entityData->getModuleName()); } $workflows = $this->workflows; foreach ($workflows as $workflow) { if (!is_a($workflow, 'Workflow')) continue; switch ($workflow->executionCondition) { case VTWorkflowManager::$ON_FIRST_SAVE: { if ($isNew) { $doEvaluate = true; } else { $doEvaluate = false; } break; } case VTWorkflowManager::$ONCE: { $entity_id = vtws_getIdComponents($entityData->getId()); $entity_id = $entity_id[1]; if ($workflow->isCompletedForRecord($entity_id)) { $doEvaluate = false; } else { $doEvaluate = true; } break; } case VTWorkflowManager::$ON_EVERY_SAVE: { $doEvaluate = true; break; } case VTWorkflowManager::$ON_MODIFY: { $doEvaluate = !($isNew); break; } case VTWorkflowManager::$MANUAL: { $doEvaluate = false; break; } case VTWorkflowManager::$ON_SCHEDULE:{ $doEvaluate = false; break; } default: { throw new Exception("Should never come here! Execution Condition:" . $workflow->executionCondition); } } if ($doEvaluate && $workflow->evaluate($entityCache, $entityData->getId())) { if (VTWorkflowManager::$ONCE == $workflow->executionCondition) { $entity_id = vtws_getIdComponents($entityData->getId()); $entity_id = $entity_id[1]; $workflow->markAsCompletedForRecord($entity_id); } $workflow->performTasks($entityData); } } $util->revertUser(); } } ?>