Data_injection plugin hooks

Data_injection allows plugins datas to be injected into GLPI.
The hook is 'data_injection'
For example :

$PLUGIN_HOOKS['data_injection']['applicatifs'] = "plugin_applicatifs_data_injection_variables";

You need to implement, in your plugin, a function which defines all the fields that can be imported.
For example, in the '''applicatifs''' plugin :

if (!in_array(PLUGIN_APPLICATIFS_TYPE, $IMPORT_PRIMARY_TYPES)) {

            //Add types of objects to be injected by data_injection plugin
            array_push($IMPORT_PRIMARY_TYPES, PLUGIN_APPLICATIFS_TYPE);

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['name']['table'] = 'glpi_plugin_applicatifs';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['name']['field'] = 'name';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['name']['name'] = $LANG['plugin_applicatifs'][8];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['name']['type'] = "text";

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['type']['table'] = 'glpi_dropdown_plugin_applicatifs_type';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['type']['field'] = 'name';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['type']['linkfield'] = 'type';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['type']['name'] = $LANG['plugin_applicatifs'][20];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['type']['type'] = "text";
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['type']['table_type'] = "dropdown";

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_users']['table'] = 'glpi_users';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_users']['field'] = 'name';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_users']['linkfield'] = 'FK_users';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_users']['name'] = $LANG['plugin_applicatifs'][21];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_users']['type'] = "text";
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_users']['table_type'] = "user";

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_groups']['table'] = 'glpi_groups';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_groups']['field'] = 'name';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_groups']['linkfield'] = 'FK_groups';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_groups']['name'] = $LANG['common'][35];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_groups']['type'] = "text";
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['FK_groups']['table_type'] = "single";

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['location']['table'] = 'glpi_dropdown_locations';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['location']['field'] = 'completename';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['location']['linkfield'] = 'location';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['location']['name'] = $LANG['plugin_applicatifs'][2];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['location']['type'] = "text";
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['location']['table_type'] = "dropdown";

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['comments']['table'] = 'glpi_plugin_applicatifs';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['comments']['field'] = 'comments';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['comments']['name'] = $LANG['plugin_applicatifs'][12];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['comments']['type'] = "text";

            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['recursive']['table'] = 'glpi_plugin_applicatifs';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['recursive']['field'] = 'recursive';
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['recursive']['name'] = $LANG["entity"][9];
            $DATA_INJECTION_MAPPING[PLUGIN_APPLICATIFS_TYPE]['recursive']['type'] = 'integer';
    }

Limitations :

  • you can only import fields for a specific type : no link, currently, can be made to other tables