/** * Triggers Ajax Request HAndler * * @author Erik A.O. <erik@colosa.com, aortiz.erik@gmail.com> * @date Apr 29th, 2010 */ $request = isset($_POST['request']) ? $_POST['request'] : ''; switch ($request) { case 'verifyDependencies': require_once 'classes/model/Triggers.php'; if (!isset($_POST['TRI_UID'])) { throw new Exception('Missing trigger ID for the request [verifyDependencies]'); exit(0); } $oTrigger = new Triggers(); $oResult = $oTrigger->verifyDependecies($_POST['TRI_UID']); $oResult->passed = false; if ($oResult->code == 0) { $oResult->passed = true; $oResult->message = G::LoadTranslation('ID_TRIGGERS_VALIDATION'); //"No Dependencies were found for this trigger in Events definitions\n"; } else { $oResult->message = ''; foreach ($oResult->dependencies as $Object => $aDeps) { $nDeps = count($aDeps); $message = str_replace('{N}', $nDeps, G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR2')); $message = str_replace('{Object}', $Object, $message); $oResult->message .= $message . "\n"; foreach ($aDeps as $dep) { if (substr($Object, -1) == 's') { $Object = substr($Object, 0, strlen($Object) - 1);
/** * Delete Trigger * @var string $sTriggerUID. Uid for Trigger * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return void */ public function deleteTrigger($sTriggerUID = '') { $oTrigger = new \Triggers(); $oTrigger->load($sTriggerUID); $res = $oTrigger->verifyDependecies($sTriggerUID); $messageEnd = ''; if ($res->code != 0) { foreach ($res->dependencies as $Object => $aDeps) { $nDeps = count($aDeps); $message = str_replace('{N}', $nDeps, \G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR2')); $message = str_replace('{Object}', $Object, $message); $messageEnd .= $message . "\n"; foreach ($aDeps as $dep) { if (substr($Object, -1) == 's') { $Object = substr($Object, 0, strlen($Object) - 1); } $message = str_replace('{Object}', $Object, \G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR3')); $message = str_replace('{Description}', '"' . $dep['DESCRIPTION'] . '"', $message); $messageEnd .= $message . "\n"; } $messageEnd .= "\n"; } throw new \Exception($messageEnd); } $oTrigger->remove($sTriggerUID); $oStepTrigger = new \StepTrigger(); $oStepTrigger->removeTrigger($sTriggerUID); }