function action()
 {
     foreach ($this->_fields["EVENTS"] as $event) {
         $bOk = true;
         if (strlen($event["CONDITIONS"]) > 0) {
             $TriggerList = array();
             $arActionID = array();
             $TriggerActionList = array();
             $TrueEventCounter = 0;
             $NeedTrueEvent = 0;
             $bOk = false;
             $arConditions = unserialize($event["CONDITIONS"]);
             if (!empty($arConditions["CHILDREN"])) {
                 $NeedTrueEvent = count($arConditions["CHILDREN"]);
                 self::countTrueEvents($arConditions["CHILDREN"]);
                 $TrueEventCounter = self::getTrueEventCounter();
                 //echo $TrueEventCounter."@".$NeedTrueEvent;die;
                 $bOk = CFoodclubEventCompare::checkLogic($arConditions["DATA"], $TrueEventCounter, $NeedTrueEvent);
             }
             if ($bOk) {
                 //Получаем триггеры
                 CFoodclubEventDoAction::checkAction($event);
             }
         }
     }
 }
Example #2
0
 function checkAction($event)
 {
     $arActionID = array();
     $rsTriggers = CFTrigger::GetList($by = "s_today_hits", $order = "desc", array("EVENT_ID" => $event["ID"]));
     while ($arTrigger = $rsTriggers->GetNext()) {
         $TriggerList[] = $arTrigger;
         $returnValue = unserialize(base64_decode($arTrigger["ACTION_ID"]));
         if (is_array($returnValue)) {
             $arActionID = array_merge($returnValue, $arActionID);
         } else {
             $arActionID[] = $arTrigger["ACTION_ID"];
         }
         $TriggerActionList[$arTrigger["ID"]][] = $returnValue;
     }
     if (!empty($arActionID)) {
         $ActionTypesID = array();
         $rsActions = CFTriggerActions::GetList($order, $by, array("ID" => $arActionID));
         while ($arAction = $rsActions->GetNext()) {
             $ActionList[$arAction["ID"]] = $arAction;
         }
         $rsActionTypes = CFTriggerActionTypes::GetList();
         while ($arActionType = $rsActionTypes->GetNext()) {
             $arActionTypeList[$arActionType["ID"]] = $arActionType["CODE"];
         }
         if (!empty($ActionList)) {
             foreach ($TriggerActionList as $key => $triggerAction) {
                 foreach ($triggerAction as $actionID) {
                     if (is_array($actionID)) {
                         foreach ($actionID as $k => $value) {
                             if (intval($ActionList[$value]["ACTION_TYPE"]) > 0 && isset($arActionTypeList[$ActionList[$value]["ACTION_TYPE"]])) {
                                 //Проверяем и выполняем действие
                                 CFoodclubEventDoAction::doAction(array("ID" => $ActionList[$value]["ID"], "NAME" => $ActionList[$value]["NAME"], "ACTION_TYPE" => $ActionList[$value]["ACTION_TYPE"], "ACTION_CODE" => $arActionTypeList[$ActionList[$value]["ACTION_TYPE"]], "ADDITIONAL_PROPS" => $ActionList[$value]["ADDITIONAL_PROPS"], "BODY_PARAMS" => $ActionList[$value]["BODY_PARAMS"]));
                                 //Заносим в журнал
                                 CFTriggerLog::Add(array("NAME" => $ActionList[$value]["NAME"], "TRIGGER_ID" => $key, "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "CREATED_BY" => CUser::GetID()));
                             }
                         }
                     } else {
                         if (intval($ActionList[$actionID]["ACTION_TYPE"]) > 0 && isset($arActionTypeList[$ActionList[$actionID]["ACTION_TYPE"]])) {
                             //Проверяем и выполняем действие
                             CFoodclubEventDoAction::doAction(array("ID" => $ActionList[$actionID]["ID"], "NAME" => $ActionList[$actionID]["NAME"], "ACTION_TYPE" => $ActionList[$actionID]["ACTION_TYPE"], "ACTION_CODE" => $arActionTypeList[$ActionList[$actionID]["ACTION_TYPE"]], "ADDITIONAL_PROPS" => $ActionList[$actionID]["ADDITIONAL_PROPS"], "BODY_PARAMS" => $ActionList[$actionID]["BODY_PARAMS"]));
                             //Заносим в журнал
                             CFTriggerLog::Add(array("NAME" => $ActionList[$actionID]["NAME"], "TRIGGER_ID" => $key, "DATE_CREATE" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "CREATED_BY" => CUser::GetID()));
                         }
                     }
                 }
             }
         }
     }
 }