Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / entity.form.php @ b67d8923

Historique | Voir | Annoter | Télécharger (5,06 ko)

1
<?php
2
/*
3
 * @version $Id: entity.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:
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36
$NEEDED_ITEMS=array("entity","rulesengine","rule.ocs","rule.right","user","profile");
37

    
38
define('GLPI_ROOT', '..');
39
include (GLPI_ROOT . "/inc/includes.php");
40

    
41
checkRight("entity","r");
42

    
43
$entity=new Entity();
44
$entitydata=new EntityData();
45

    
46
if (isset($_POST["update"]))
47
{
48
        checkRight("entity","w");
49
        $entitydata->update($_POST);
50
        logEvent($_POST["ID"], "entity", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][21]);
51
        glpi_header($_SERVER['HTTP_REFERER']);
52
} else if (isset($_POST["adduser"]))
53
{
54
        checkRight("entity","w");
55

    
56
        addUserProfileEntity($_POST);
57

    
58
        logEvent($_POST["FK_entities"], "entity", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][61]);
59
        glpi_header($_SERVER['HTTP_REFERER']);
60
} else if (isset($_POST["add_rule"]))
61
{
62
        checkRight("entity","w");
63

    
64

    
65
        $rule = new OcsAffectEntityRule;
66
        $ruleid = $rule->add($_POST);
67
        
68
        if ($ruleid)
69
        {
70
                //Add an action associated to the rule
71
                $ruleAction = new RuleAction;
72
                //Action is : affect computer to this entity
73
                $ruleAction->addActionByAttributes("assign", $ruleid, "FK_entities", $_POST["affectentity"]);
74
        }
75
                
76
        logEvent($ruleid, "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][20]);
77
        glpi_header($_SERVER['HTTP_REFERER']);
78
} else if (isset($_POST["add_user_rule"]))
79
{
80
        checkRight("entity","w");
81

    
82

    
83
        $rule = new RightAffectRule;
84
        $ruleid = $rule->add($_POST);
85
        
86
        if ($ruleid)
87
        {
88
                //Add an action associated to the rule
89
                $ruleAction = new RuleAction;
90
                //Action is : affect computer to this entity
91
                $ruleAction->addActionByAttributes("assign", $ruleid, "FK_entities", $_POST["affectentity"]);
92
                if ($_POST["FK_profiles"]){
93
                        $ruleAction->addActionByAttributes("assign", $ruleid, "FK_profiles", $_POST["FK_profiles"]);
94
                }
95
                $ruleAction->addActionByAttributes("assign", $ruleid, "recursive", $_POST["recursive"]);
96
        }
97
                
98
        logEvent($ruleid, "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][22]);
99
        glpi_header($_SERVER['HTTP_REFERER']);
100

    
101
} else if (isset($_POST["deleteuser"]))
102
{
103
        checkRight("entity","w");
104

    
105
        if (count($_POST["item"])){
106
                foreach ($_POST["item"] as $key => $val){
107
                        deleteUserProfileEntity($key);
108
                }
109
        }
110

    
111
        logEvent($_POST["FK_entities"], "entity", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][62]);
112
        glpi_header($_SERVER['HTTP_REFERER']);
113
}elseif (isset($_POST["delete_computer_rule"]) || isset($_POST["delete_user_rule"]))
114
{
115
        checkRight("entity","w");
116
        if (isset($_POST["delete_computer_rule"])){
117
                $rule = new OcsAffectEntityRule;                
118
        } else {
119
                $rule = new RightAffectRule;
120
        }
121
                
122
        if (count($_POST["item"])){
123
                foreach ($_POST["item"] as $key => $val){        
124
                        $rule->delete(array('ID'=>$key));
125
                }
126
        }
127

    
128
        logEvent(0, "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][22]);
129
        glpi_header($_SERVER['HTTP_REFERER']);
130
}
131

    
132
commonHeader($LANG["Menu"][37],$_SERVER['PHP_SELF'],"admin","entity");
133

    
134
if (!isset($_SESSION['glpi_onglet'])) $_SESSION['glpi_onglet']=1;
135
if (isset($_GET['onglet'])) {
136
        $_SESSION['glpi_onglet']=$_GET['onglet'];
137
}        
138

    
139

    
140
$ocsrule = new OcsAffectEntityRule;
141
$ldaprule = new RightAffectRule;
142

    
143
if ($entity->showForm($_SERVER['PHP_SELF'],$_GET["ID"])){
144
        switch($_SESSION['glpi_onglet']){
145
                case -1 :        
146
                        showEntityUser($_SERVER['PHP_SELF'],$_GET["ID"]);
147
                        displayPluginAction(ENTITY_TYPE,$_GET["ID"],$_SESSION['glpi_onglet']);
148
                        if ($CFG_GLPI["ocs_mode"])
149
                                $ocsrule->showAndAddRuleForm($_SERVER['PHP_SELF'],$_GET["ID"]);
150
                        $ldaprule->showAndAddRuleForm($_SERVER['PHP_SELF'],$_GET["ID"]);
151
                break;
152
                case 2 : 
153
                        showEntityUser($_SERVER['PHP_SELF'],$_GET["ID"]);
154
                break;
155
                case 3 :
156
                        $ldaprule->showAndAddRuleForm($_SERVER['PHP_SELF'],$_GET["ID"]);
157
                        if ($CFG_GLPI["ocs_mode"])
158
                                $ocsrule->showAndAddRuleForm($_SERVER['PHP_SELF'],$_GET["ID"]);
159
                        break;
160
                default :
161
                        if (!displayPluginAction(ENTITY_TYPE,$_GET["ID"],$_SESSION['glpi_onglet'])){
162
                                
163
                        }
164
                break;
165
        }
166
}
167

    
168
commonFooter();
169
?>
Redmine Appliance - Powered by TurnKey Linux