Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / setup.dropdowns.php @ b67d8923

Historique | Voir | Annoter | Télécharger (10,8 ko)

1
<?php
2
/*
3
 * @version $Id: setup.dropdowns.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

    
37

    
38
//,"ocsng","rulesengine","computer","monitor","printer","peripheral","phone","software","networking","computer","monitor","printer","peripheral","phone","software","networking");
39

    
40
if(!defined('GLPI_ROOT')){
41
        define('GLPI_ROOT', '..');
42

    
43
        $NEEDED_ITEMS=array("setup");
44
        include (GLPI_ROOT . "/inc/includes.php");
45
}
46

    
47
checkSeveralRightsOr(array("dropdown"=>"w","entity_dropdown"=>"w"));
48

    
49
//if(isset($_SERVER['HTTP_REFERER']))
50
//$httpreferer=preg_replace("/\?which=\w*/","",$_SERVER['HTTP_REFERER']);
51
if (isset($_POST["which"]))$which=$_POST["which"];
52
elseif (isset($_GET["which"]))$which=$_GET["which"];
53
else $which="";
54

    
55
if (isset($_GET["where"]))$where=$_GET["where"];
56
else if (isset($_POST["value_where"]))$where=$_POST["value_where"];
57
else $where="";
58
if (isset($_GET["tomove"])) $tomove=$_GET["tomove"];
59
else if (isset($_POST["value_to_move"])) $tomove=$_POST["value_to_move"];
60
else $tomove="";
61
if (isset($_GET["value2"]))$value2=$_GET["value2"];
62
else if (isset($_POST["value2"]))$value2=$_POST["value2"];
63
else $value2="";
64
if (isset($_GET["type"]))$type=$_GET["type"];
65
else if (isset($_POST["type"]))$type=$_POST["type"];
66
else $type="";
67
// Selected Item
68
if (isset($_POST["ID"])) $ID=$_POST["ID"];
69
elseif (isset($_GET["ID"])) $ID=$_GET["ID"];
70
else $ID="";
71

    
72
if (isset($_POST["FK_entities"])) $FK_entities=$_POST["FK_entities"];
73
elseif (isset($_GET["FK_entities"])) $FK_entities=$_GET["FK_entities"];
74
else $FK_entities="";
75

    
76
if (isset($_POST['mass_delete'])){
77
        $input['tablename']=$_POST['which'];
78
        foreach ($_POST["item"] as $key => $val){
79
                if ($val==1) {
80
                        $input['ID']=$key;
81
                        deleteDropdown($input);
82
                }
83
        }
84
        glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&tomove=$tomove&where=$where&type=$type&FK_entities=$FK_entities");
85

    
86
}else if (isset($_POST["several_add"])) {
87
        
88
        for ($i=$_POST["from"];$i<=$_POST["to"];$i++){
89
                $_POST["value"]=$_POST["before"].$i.$_POST["after"];
90
                addDropdown($_POST);
91
        }
92

    
93
        logEvent(0, "dropdown", 5, "setup", $_SESSION["glpiname"]." ".$LANG["log"][20]);
94
        glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&tomove=$tomove&where=$where&type=$type&FK_entities=$FK_entities");
95

    
96
}else if (isset($_POST["move"])) {
97
        logEvent(0, "dropdown", 5, "setup", $_SESSION["glpiname"]." ".$LANG["log"][21]." ".getDropdownName($_POST['tablename'],$_POST['value_to_move']));
98
        moveTreeUnder($_POST["tablename"],$_POST["value_to_move"],$_POST["value_where"]);
99
        glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&tomove=$tomove&where=$where&type=$type&FK_entities=$FK_entities");
100

    
101
}else if (isset($_POST["add"])) {
102
        addDropdown($_POST);
103
        logEvent(0, "dropdown", 5, "setup", $_SESSION["glpiname"]." ".$LANG["log"][20]." ".$_POST["value"]);
104
        glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&tomove=$tomove&where=$where&type=$type&FK_entities=$FK_entities");
105

    
106
} else if (isset($_POST["delete"])) {
107
        if(dropdownUsed($_POST["tablename"], $_POST["ID"]) && empty($_POST["forcedelete"])) {
108
                if (!ereg("popup",$_SERVER['PHP_SELF'])){
109
                        commonHeader($LANG["common"][12],$_SERVER['PHP_SELF'],"config","dropdowns");
110
                }
111
                showDeleteConfirmForm($_SERVER['PHP_SELF'],$_POST["tablename"], $_POST["ID"],$_POST["FK_entities"]);
112
                if (!ereg("popup",$_SERVER['PHP_SELF'])){
113
                        commonFooter();
114
                }
115
        } else {
116
                logEvent(0, "dropdown", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][22]." ".getDropdownName($_POST['which'],$_POST['ID']));
117
                deleteDropdown($_POST);
118
                glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&FK_entities=$FK_entities");
119
        }
120

    
121
} else if (isset($_POST["update"])) {
122
        updateDropdown($_POST);
123
        logEvent(0, "dropdown", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][21]);
124
        glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&ID=$ID&FK_entities=$FK_entities");
125

    
126
} else if (isset($_POST["replace"])) {
127
        replaceDropDropDown($_POST);
128
        logEvent(0, "dropdown", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][21]);
129
        glpi_header($_SERVER['PHP_SELF']."?which=$which&value2=$value2&FK_entities=$FK_entities");
130

    
131
} else {
132
        if (!ereg("popup",$_SERVER['PHP_SELF'])){
133
                commonHeader($LANG["common"][12],$_SERVER['PHP_SELF'],"config","dropdowns");
134
        }
135

    
136
        $optgroup=array(
137
                        $LANG["setup"][139]=>array(
138
                                "glpi_dropdown_locations"=>$LANG["common"][15],
139
                                "glpi_dropdown_state"=>$LANG["setup"][83],
140
                                "glpi_dropdown_manufacturer"=>$LANG["common"][5],
141
                                ),
142

    
143
                        $LANG["setup"][140]=>array(
144
                                "glpi_type_computers"=>$LANG["setup"][4],
145
                                "glpi_type_networking"=>$LANG["setup"][42],
146
                                "glpi_type_printers"=>$LANG["setup"][43],
147
                                "glpi_type_monitors"=>$LANG["setup"][44],
148
                                "glpi_type_peripherals"=>$LANG["setup"][69],
149
                                "glpi_type_phones"=>$LANG["setup"][504],
150
                                "glpi_dropdown_cartridge_type"=>$LANG["setup"][84],
151
                                "glpi_dropdown_consumable_type"=>$LANG["setup"][92],
152
                                "glpi_dropdown_contract_type"=>$LANG["setup"][85],
153
                                "glpi_dropdown_contact_type"=>$LANG["setup"][82],        
154
                                "glpi_dropdown_ram_type"=>$LANG["setup"][86],
155
                                "glpi_dropdown_enttype"=>$LANG["setup"][80],
156
                                "glpi_dropdown_interface"=>$LANG["setup"][93],
157
                                "glpi_dropdown_case_type"=>$LANG["setup"][45],
158
                                "glpi_dropdown_phone_power"=>$LANG["setup"][505],
159
                                ),
160

    
161
                        $LANG["common"][22]=>array(
162
                                        "glpi_dropdown_model"=>$LANG["setup"][91],
163
                                        "glpi_dropdown_model_networking"=>$LANG["setup"][95],
164
                                        "glpi_dropdown_model_printers"=>$LANG["setup"][96],
165
                                        "glpi_dropdown_model_monitors"=>$LANG["setup"][94],
166
                                        "glpi_dropdown_model_peripherals"=>$LANG["setup"][97],
167
                                        "glpi_dropdown_model_phones"=>$LANG["setup"][503],
168

    
169
                                        ),
170

    
171
                        $LANG["setup"][142]=>array(
172
                                        "glpi_dropdown_budget"=>$LANG["financial"][87],
173
                                        "glpi_dropdown_rubdocs"=>$LANG["setup"][81],
174
                                        ),
175

    
176
                        $LANG["title"][24]=>array(
177
                                        "glpi_dropdown_tracking_category"=>$LANG["setup"][79],
178
                                        ),
179

    
180
                        $LANG["setup"][144]=>array(
181
                                        "glpi_dropdown_kbcategories"=>$LANG["title"][5],        
182
                                        ),
183

    
184
                        $LANG["setup"][145]=>array(
185
                                        "glpi_dropdown_os"=>$LANG["setup"][5],        
186
                                        "glpi_dropdown_os_version"=>$LANG["computers"][52],
187
                                        "glpi_dropdown_os_sp"=>$LANG["computers"][53],
188
                                        "glpi_dropdown_auto_update"=>$LANG["computers"][51],
189
                                        ),
190

    
191
                        $LANG["setup"][88]=>array(
192
                                        "glpi_dropdown_iface"=>$LANG["setup"][9],
193
                                        "glpi_dropdown_firmware"=>$LANG["setup"][71],
194
                                        "glpi_dropdown_netpoint"=>$LANG["setup"][73],
195
                                        "glpi_dropdown_domain"=>$LANG["setup"][89],
196
                                        "glpi_dropdown_network"=>$LANG["setup"][88],
197
                                        "glpi_dropdown_vlan"=>$LANG["setup"][90],        
198
                                        ),
199
                        
200
                        $LANG["Menu"][4]=>array(
201
                        "glpi_dropdown_software_category"=>$LANG["softwarecategories"][5],
202
                        )
203
                        
204
                        ); //end $opt
205

    
206
        $plugdrop=getPluginsDropdowns();
207
        if (count($plugdrop)){
208
                $optgroup=array_merge($optgroup,$plugdrop);
209
        }
210
        if (!haveRight("dropdown","w")){
211
                foreach($optgroup as $label=>$dp){
212
                        foreach ($dp as $key => $val){
213
                                if (!in_array($key,$CFG_GLPI["specif_entities_tables"])){
214
                                        unset($optgroup[$label][$key]);
215
                                }
216
                                
217
                        }
218
                        if (count($optgroup[$label])==0){
219
                                unset($optgroup[$label]);
220
                        }
221
                }
222
        }
223

    
224
        if (!haveRight("entity_dropdown","w")){
225
                foreach($optgroup as $label=>$dp){
226
                        foreach ($dp as $key => $val){
227
                                if (in_array($key,$CFG_GLPI["specif_entities_tables"])){
228
                                        unset($optgroup[$label][$key]);
229
                                }
230
                                
231
                        }
232
                        if (count($optgroup[$label])==0){
233
                                unset($optgroup[$label]);
234
                        }
235
                }
236
        }
237
        
238
        if (!ereg("popup",$_SERVER['PHP_SELF'])){
239
                echo "<div align='center'><form method='get' action=\"".$_SERVER['PHP_SELF']."\">";
240
                echo "<table class='tab_cadre' cellpadding='5'><tr><th colspan='2'>";
241
                echo $LANG["setup"][72].": </th></tr><tr class='tab_bg_1'><td><select name='which'>";
242
        
243
                foreach($optgroup as $label=>$dp){
244
        
245
                        echo "<optgroup label=\"$label\">";
246
        
247
                        foreach ($dp as $key => $val){
248
                                $sel="";
249
                                if ($which==$key) $sel="selected";
250
                                echo "<option value='$key' $sel>".$val."</option>";        
251
                        }
252
                        echo "</optgroup>";
253
                }
254
                echo "</select></td>";
255
                echo "<td><input type='submit' value=\"".$LANG["buttons"][2]."\" class='submit' ></td></tr>";
256
                echo "</table></form></div>";
257
        }
258

    
259
        if ($which=="glpi_dropdown_netpoint"){
260
                if (haveRight("entity_dropdown","w")){
261
                        $title=$LANG["setup"][73];
262
                        
263
                        if (ereg("popup",$_SERVER['PHP_SELF'])){
264
                                
265
                                if ($value2>0) {
266
                                        $title .= " (" . $LANG["common"][15] . ":&nbsp;" . getDropdownName("glpi_dropdown_locations", $value2) . ")";
267
                                }
268
                                
269
                        } else {
270
                                echo "<div align='center'><form method='get' action=\"".$_SERVER['PHP_SELF']."\">";
271
                                echo "<table class='tab_cadre' cellpadding='5'><tr><th colspan='2'>";
272
                                echo $LANG["setup"][77].": </th></tr><tr class='tab_bg_1'><td>";
273
                                echo "<input type='hidden' name='which' value='glpi_dropdown_netpoint' />";
274
                                dropdownValue("glpi_dropdown_locations", "value2", $value2, $FK_entities);
275
                                echo "</td><td><input type='submit' value=\"".$LANG["buttons"][2]."\" class='submit' ></td></tr>";
276
                                echo "</table></form></div>";
277
                        }
278
                        if (strlen($value2) > 0) {
279
                                if (isset($_GET['mass_deletion'])){
280
                                        showDropdownList($_SERVER['PHP_SELF'],$which,$FK_entities,$value2);
281
                                } else {
282
                                        showFormNetpoint($_SERVER['PHP_SELF'],$title,$ID,$FK_entities,$value2);
283
                                }
284
                        }                
285
                }
286
        } else if ($which){
287
                // Search title
288
                $title="";
289
                foreach ($optgroup as $key => $val){
290
                        if (isset($val[$which])){
291
                                $title=$val[$which];
292
                        }
293
                }
294
                if (isset($_GET['mass_deletion'])){
295
                        showDropdownList($_SERVER['PHP_SELF'],$which,$FK_entities);
296
                } else {
297
                        if (!empty($title)){
298
                                if (in_array($which,$CFG_GLPI["dropdowntree_tables"])){
299
                                        showFormTreeDown($_SERVER['PHP_SELF'],$which,$title,$ID,$value2,$where,$tomove,$type,$FK_entities);
300
                                } else {
301
                                        showFormDropDown($_SERVER['PHP_SELF'],$which,$title,$ID,$FK_entities);
302
                                }
303
                        }
304
                }
305
        }
306

    
307
        if (!ereg("popup",$_SERVER['PHP_SELF'])){
308
                commonFooter();
309
        }
310
}
311

    
312

    
313
?>
Redmine Appliance - Powered by TurnKey Linux