Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / rule.common.form.php @ b67d8923

Historique | Voir | Annoter | Télécharger (4,42 ko)

1
<?php
2
/*
3
 * @version $Id: rule.common.form.php 7763 2009-01-06 18:44:50Z moyo $
4
 -------------------------------------------------------------------------
5
 GLPI - Gestionnaire Libre de Parc Informatique
6
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
7

8
 http://indepnet.net/   http://glpi-project.org
9
 -------------------------------------------------------------------------
10

11
 LICENSE
12

13
 This file is part of GLPI.
14

15
 GLPI is free software; you can redistribute it and/or modify
16
 it under the terms of the GNU General Public License as published by
17
 the Free Software Foundation; either version 2 of the License, or
18
 (at your option) any later version.
19

20
 GLPI 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 General Public License for more details.
24

25
 You should have received a copy of the GNU General Public License
26
 along with GLPI; if not, write to the Free Software
27
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 --------------------------------------------------------------------------
29
 */
30

    
31
// ----------------------------------------------------------------------
32
// Original Author of file: Walid Nouh
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36
if (!defined('GLPI_ROOT')){
37
        die("Sorry. You can't access directly to this file");
38
        }
39

    
40

    
41
$rule = $rulecollection->getRuleClass();
42

    
43
checkRight($rule->right,"r");
44

    
45
if(!isset($_GET["ID"])) $_GET["ID"] = "";
46

    
47
if (!isset($_SESSION['glpi_onglet'])) $_SESSION['glpi_onglet']=1;
48
if (isset($_GET['onglet'])) {
49
        $_SESSION['glpi_onglet']=$_GET['onglet'];
50
}        
51

    
52
$rulecriteria = new RuleCriteria();
53
$ruleaction = new RuleAction();
54
                
55
if (isset($_POST["delete_criteria"]))
56
{
57
        checkRight($rule->right,"w");
58

    
59
        if (count($_POST["item"]))
60
                foreach ($_POST["item"] as $key => $val)
61
                {
62
                        $input["ID"]=$key;
63
                        $rulecriteria->delete($input);
64
                }
65
        
66
        // Is a cached Rule ?
67
        if(method_exists($rule,'deleteCacheByRuleId')){
68
                $rule->deleteCacheByRuleId($_POST["rule_id"]);
69
        }
70
                
71
        glpi_header($_SERVER['HTTP_REFERER']);
72
}
73
if (isset($_POST["delete_action"]))
74
{
75
        checkRight($rule->right,"w");
76

    
77
        if (count($_POST["item"]))
78
                foreach ($_POST["item"] as $key => $val)
79
                {
80
                        $input["ID"]=$key;
81
                        $ruleaction->delete($input);
82
                }
83

    
84
        // Is a cached Rule ?
85
        if(method_exists($rule,'deleteCacheByRuleId')){
86
                $rule->deleteCacheByRuleId($_POST["rule_id"]);
87
        }
88
        
89
        glpi_header($_SERVER['HTTP_REFERER']);
90
}
91
elseif (isset($_POST["add_criteria"]))
92
{
93
        checkRight($rule->right,"w");
94

    
95
        // Is a cached Rule ?
96
        if(method_exists($rule,'deleteCacheByRuleId')){
97
                $rule->deleteCacheByRuleId($_POST["rule_id"]);
98
        }
99
        
100
        unset($_POST["rule_id"]);
101
        $rulecriteria->add($_POST);
102

    
103

    
104
        glpi_header($_SERVER['HTTP_REFERER']);
105
}
106
elseif (isset($_POST["add_action"]))
107
{
108
        checkRight($rule->right,"w");
109

    
110
        // Is a cached Rule ?
111
        if(method_exists($rule,'deleteCacheByRuleId')){
112
                $rule->deleteCacheByRuleId($_POST["rule_id"]);
113
        }
114

    
115
        unset($_POST["rule_id"]);
116

    
117
        $ruleaction->add($_POST);
118

    
119
        glpi_header($_SERVER['HTTP_REFERER']);
120
}
121
elseif (isset($_POST["update_rule"]))
122
{
123
        checkRight($rule->right,"w");
124

    
125
        // Is a cached Rule ?
126
        if(method_exists($rule,'deleteCacheByRuleId')){
127
                $rule->deleteCacheByRuleId($_POST["ID"]);
128
        }
129

    
130
        $rule->update($_POST);
131
        logEvent($_POST['ID'], "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][21]);
132

    
133
        glpi_header($_SERVER['HTTP_REFERER']);
134
} elseif (isset($_POST["add_rule"]))
135
{
136
        checkRight($rule->right,"w");
137

    
138
        $newID=$rule->add($_POST);
139
        logEvent($newID, "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][20]);
140

    
141
        glpi_header($_SERVER['HTTP_REFERER']."?ID=$newID");
142
} elseif (isset($_POST["delete_rule"]))
143
{
144
        checkRight($rule->right,"w");
145
        $rulecollection->deleteRuleOrder($_POST["ranking"]);
146
        $rule->delete($_POST);
147
        logEvent($_POST["ID"], "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][22]);
148

    
149
        // Is a cached Rule ?
150
        if(method_exists($rule,'deleteCacheByRuleId')){
151
                $rule->deleteCacheByRuleId($_POST["ID"]);
152
        }
153

    
154
        glpi_header(ereg_replace('.form','',$_SERVER['PHP_SELF']));
155
}
156

    
157
commonHeader($LANG["common"][12],$_SERVER['PHP_SELF'],"admin",getCategoryNameToDisplay($rulecollection->rule_type),$rulecollection->rule_type);
158

    
159
$rule->showForm($_SERVER['PHP_SELF'],$_GET["ID"]);
160
if (!empty($_GET["ID"])&&$_GET["ID"] >0) {
161
        $rule->showCriteriasList($_SERVER['PHP_SELF'],$_GET["ID"]);
162
        $rule->showActionsList($_SERVER['PHP_SELF'],$_GET["ID"]);
163
}
164
commonFooter();
165
?>
Redmine Appliance - Powered by TurnKey Linux