Dropdown::importExternal PHP Method

importExternal() static public method

This import a new dropdown if it doesn't exist - Play dictionnary if needed
static public importExternal ( $itemtype, $value, $entities_id, $external_params = [], $comment = '', $add = true ) : integer
$itemtype string name of the class
$value string Value of the new dropdown. (need to be addslashes)
$entities_id integer entity in case of specific dropdown (default -1)
$external_params array (need to be addslashes)
$comment (default '') (need to be addslashes)
$add if true, add it if not found. if false, just check if exists (true by default)
return integer : dropdown id.
    static function importExternal($itemtype, $value, $entities_id = -1, $external_params = array(), $comment = '', $add = true)
    {
        if (!($item = getItemForItemtype($itemtype))) {
            return false;
        }
        return $item->importExternal($value, $entities_id, $external_params, $comment, $add);
    }

Usage Example

 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 "regex_result":
                     //Regex result : assign value from the regex
                     $res = "";
                     if (isset($this->regex_results[0])) {
                         $res .= RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $res .= $action->fields["value"];
                     }
                     if ($res != '' && ($action->fields["field"] != 'user' && $action->fields["field"] != 'otherserial' && $action->fields["field"] != 'software' && $action->fields["field"] != 'softwareversion')) {
                         $res = Dropdown::importExternal(getItemTypeForTable(getTableNameForForeignKeyField($action->fields['field'])), $res);
                     }
                     $output[$action->fields["field"]] = $res;
                     break;
                 default:
                     //plugins actions
                     $executeaction = clone $this;
                     $ouput = $executeaction->executePluginsActions($action, $output, $params);
                     break;
             }
         }
     }
     return $output;
 }
All Usage Examples Of Dropdown::importExternal