Example #1
0
 /**
  * Execute the actions as defined in the rule
  *
  * @param $output the fields to manipulate
  * @param $params parameters
  *
  * @return the $output array modified
  **/
 function executeActions($output, $params)
 {
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             switch ($action->fields["action_type"]) {
                 case "assign":
                     $output[$action->fields["field"]] = $action->fields["value"];
                     break;
                 case "append":
                     $actions = $this->getActions();
                     $value = $action->fields["value"];
                     if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) {
                         $value = $actions[$action->fields["field"]]["appendtoarray"];
                         $value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"];
                     }
                     $output[$actions[$action->fields["field"]]["appendto"]][] = $value;
                     break;
                 case "regex_result":
                 case "append_regex_result":
                     //Regex result : assign value from the regex
                     //Append regex result : append result from a regex
                     if ($action->fields["action_type"] == "append_regex_result") {
                         $res = isset($params[$action->fields["field"]]) ? $params[$action->fields["field"]] : "";
                     } else {
                         $res = "";
                     }
                     if (isset($this->regex_results[0])) {
                         $res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $res .= $action->fields["value"];
                     }
                     $output[$action->fields["field"]] = $res;
                     break;
                 default:
                     //plugins actions
                     $executeaction = new self();
                     $ouput = $executeaction->executePluginsActions($action, $output, $params);
                     break;
             }
         }
     }
     return $output;
 }
 /**
  * Execute the actions as defined in the rule
  *
  * @see Rule::executeActions()
  *
  * @param $output the fields to manipulate
  * @param $params parameters
  *
  * @return the $output array modified
  **/
 function executeActions($output, $params)
 {
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             $executeaction = new self();
             $ruleoutput = $executeaction->executePluginsActions($action, $output, $params);
             foreach ($ruleoutput as $key => $value) {
                 $output[$key] = $value;
             }
         }
     }
     return $output;
 }