1<?php
2
3/*
4   ------------------------------------------------------------------------
5   FusionInventory
6   Copyright (C) 2010-2016 by the FusionInventory Development Team.
7
8   http://www.fusioninventory.org/   http://forge.fusioninventory.org/
9   ------------------------------------------------------------------------
10
11   LICENSE
12
13   This file is part of FusionInventory project.
14
15   FusionInventory is free software: you can redistribute it and/or modify
16   it under the terms of the GNU Affero General Public License as published by
17   the Free Software Foundation, either version 3 of the License, or
18   (at your option) any later version.
19
20   FusionInventory is distributed in the hope that it will be useful,
21   but WITHOUT ANY WARRANTY; without even the implied warranty of
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23   GNU Affero General Public License for more details.
24
25   You should have received a copy of the GNU Affero General Public License
26   along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
27
28   ------------------------------------------------------------------------
29
30   @package   FusionInventory
31   @author    Walid Nouh
32   @co-author
33   @copyright Copyright (c) 2010-2016 FusionInventory team
34   @license   AGPL License 3.0 or (at your option) any later version
35              http://www.gnu.org/licenses/agpl-3.0-standalone.html
36   @link      http://www.fusioninventory.org/
37   @link      http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
38   @since     2010
39
40   ------------------------------------------------------------------------
41 */
42
43if (!defined('GLPI_ROOT')) {
44   include ("../../../inc/includes.php");
45}
46
47Session::checkLoginUser();
48$sub_type = 0;
49if (isset($_POST["sub_type"])) {
50   $sub_type = $_POST["sub_type"];
51} else if (isset($_GET["sub_type"])) {
52   $sub_type = $_GET["sub_type"];
53}
54
55$rules_id = 0;
56if (isset($_POST["rules_id"])) {
57   $rules_id = $_POST["rules_id"];
58} else if (isset($_GET["rules_id"])) {
59   $rules_id = $_GET["rules_id"];
60}
61
62$rule = new $sub_type();
63$rule->checkGlobal(READ);
64
65$test_rule_output = NULL;
66
67if (!strpos($_SERVER['PHP_SELF'], "popup")) {
68   Html::header(__('Setup'), $_SERVER['PHP_SELF'], "config", "display");
69}
70
71$rule->showRulePreviewCriteriasForm($_SERVER['PHP_SELF'], $rules_id);
72
73if (isset($_POST["test_rule"])) {
74   $params = array();
75   //Unset values that must not be processed by the rule
76   unset($_POST["test_rule"]);
77   unset($_POST["rules_id"]);
78   unset($_POST["sub_type"]);
79   $rule->getRuleWithCriteriasAndActions($rules_id, 1, 1);
80
81   // Need for RuleEngines
82   foreach ($_POST as $key => $val) {
83      $_POST[$key] = stripslashes($_POST[$key]);
84   }
85   //Add rules specific POST fields to the param array
86   $params = $rule->addSpecificParamsForPreview($params);
87
88   $input = $rule->prepareInputDataForProcess($_POST, $params);
89   //$rule->regex_results = array();
90   echo "<br>";
91   $rule->showRulePreviewResultsForm($_SERVER['PHP_SELF'], $input, $params);
92}
93
94if (!strpos($_SERVER['PHP_SELF'], "popup")) {
95   Html::footer();
96}
97
98?>
99