コード例 #1
0
ファイル: hook.php プロジェクト: publik1974/fields
function plugin_fields_rule_matched($params)
{
    global $DB;
    $container = new PluginFieldsContainer();
    switch ($params['sub_type']) {
        case "PluginFusioninventoryTaskpostactionRule":
            $agent = new PluginFusioninventoryAgent();
            if (isset($params['input']['plugin_fusioninventory_agents_id'])) {
                foreach ($params['output'] as $field => $value) {
                    // check if current field is in a tab container
                    $query = "SELECT c.id\n                         FROM glpi_plugin_fields_fields f\n                         LEFT JOIN glpi_plugin_fields_containers c\n                            ON c.id = f.plugin_fields_containers_id\n                         WHERE f.name = '{$field}'";
                    $res = $DB->query($query);
                    if ($DB->numrows($res) > 0) {
                        $data = $DB->fetch_assoc($res);
                        //retrieve computer
                        $agents_id = $params['input']['plugin_fusioninventory_agents_id'];
                        $agent->getFromDB($agents_id);
                        // update current field
                        $container->updateFieldsValues(array('plugin_fields_containers_id' => $data['id'], $field => $value, 'items_id' => $agent->fields['computers_id']));
                    }
                }
            }
            break;
    }
}
コード例 #2
0
ファイル: container.form.php プロジェクト: publik1974/fields
<?php

include "../../../inc/includes.php";
if (empty($_GET["id"])) {
    $_GET["id"] = "";
}
$container = new PluginFieldsContainer();
if (isset($_POST["add"])) {
    $container->check(-1, CREATE, $_POST);
    $newID = $container->add($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/fields/front/container.form.php?id={$newID}");
} elseif (isset($_POST["delete"])) {
    $container->check($_POST['id'], DELETE);
    $ok = $container->delete($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/fields/front/container.php");
} elseif (isset($_REQUEST["purge"])) {
    $container->check($_REQUEST['id'], PURGE);
    $container->delete($_REQUEST, 1);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/fields/front/container.php");
} elseif (isset($_POST["update"])) {
    $container->check($_POST['id'], UPDATE);
    $container->update($_POST);
    Html::back();
} elseif (isset($_POST["update_fields_values"])) {
    $container->updateFieldsValues($_REQUEST);
    Html::back();
} else {
    Html::header(__("Additionnal fields", "fields"), $_SERVER['PHP_SELF'], "config", "pluginfieldsmenu", "fieldscontainer");
    $container->display(array('id' => $_GET["id"]));
    Html::footer();
}
コード例 #3
0
ファイル: container.form.php プロジェクト: pluginsGLPI/fields
    $container->check(-1, CREATE, $_POST);
    $newID = $container->add($_POST);
    Html::redirect($CFG_GLPI["root_doc"] . "/plugins/fields/front/container.form.php?id={$newID}");
} else {
    if (isset($_POST["delete"])) {
        $container->check($_POST['id'], DELETE);
        $ok = $container->delete($_POST);
        Html::redirect($CFG_GLPI["root_doc"] . "/plugins/fields/front/container.php");
    } else {
        if (isset($_REQUEST["purge"])) {
            $container->check($_REQUEST['id'], PURGE);
            $container->delete($_REQUEST, 1);
            Html::redirect($CFG_GLPI["root_doc"] . "/plugins/fields/front/container.php");
        } else {
            if (isset($_POST["update"])) {
                $container->check($_POST['id'], UPDATE);
                $container->update($_POST);
                Html::back();
            } else {
                if (isset($_POST["update_fields_values"])) {
                    $container->updateFieldsValues($_REQUEST, false, $_REQUEST['itemtype']);
                    Html::back();
                } else {
                    Html::header(__("Additionnal fields", "fields"), $_SERVER['PHP_SELF'], "config", "pluginfieldsmenu", "fieldscontainer");
                    $container->display(array('id' => $_GET["id"]));
                    Html::footer();
                }
            }
        }
    }
}