ryxeo-glpi-git / front / computer.form.php @ b67d8923
Historique | Voir | Annoter | Télécharger (10,9 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: computer.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 | |||
37 | $NEEDED_ITEMS=array("computer","rulesengine","device","networking","monitor","printer","tracking","software","peripheral","reservation","infocom","contract","document","user","group","link","ocsng","phone","enterprise","search","registry","group","setup","ocsng","rule.softwarecategories","rule.dictionnary.software","rule.dictionnary.dropdown"); |
||
38 | |||
39 | define('GLPI_ROOT', '..'); |
||
40 | include (GLPI_ROOT . "/inc/includes.php"); |
||
41 | |||
42 | if(!isset($_GET["ID"])) $_GET["ID"] = ""; |
||
43 | if(!isset($_GET["sort"])) $_GET["sort"] = ""; |
||
44 | if(!isset($_GET["order"])) $_GET["order"] = ""; |
||
45 | if(!isset($_GET["withtemplate"])) $_GET["withtemplate"] = ""; |
||
46 | |||
47 | $computer=new Computer(); |
||
48 | //Add a new computer
|
||
49 | if (isset($_POST["add"])) { |
||
50 | checkRight("computer","w"); |
||
51 | $newID=$computer->add($_POST); |
||
52 | logEvent($newID, "computers", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][20]." ".$_POST["name"]."."); |
||
53 | glpi_header($_SERVER['HTTP_REFERER']); |
||
54 | } |
||
55 | // delete a computer
|
||
56 | else if (isset($_POST["delete"])) { |
||
57 | checkRight("computer","w"); |
||
58 | |||
59 | if (!empty($_POST["withtemplate"])) |
||
60 | $computer->delete($_POST,1); |
||
61 | else $computer->delete($_POST); |
||
62 | logEvent($_POST["ID"], "computers", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][22]); |
||
63 | if(!empty($_POST["withtemplate"])) |
||
64 | glpi_header($CFG_GLPI["root_doc"]."/front/setup.templates.php"); |
||
65 | else
|
||
66 | glpi_header($CFG_GLPI["root_doc"]."/front/computer.php"); |
||
67 | } |
||
68 | else if (isset($_POST["restore"])) |
||
69 | { |
||
70 | checkRight("computer","w"); |
||
71 | $computer->restore($_POST); |
||
72 | logEvent($_POST["ID"],"computers", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][23]); |
||
73 | glpi_header($CFG_GLPI["root_doc"]."/front/computer.php"); |
||
74 | } |
||
75 | else if (isset($_POST["purge"]) || isset($_GET["purge"])) |
||
76 | { |
||
77 | checkRight("computer","w"); |
||
78 | |||
79 | if (isset($_POST["purge"])) |
||
80 | $input["ID"]=$_POST["ID"]; |
||
81 | else
|
||
82 | $input["ID"] = $_GET["ID"]; |
||
83 | |||
84 | $computer->delete($input,1); |
||
85 | logEvent($input["ID"], "computers", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][24]); |
||
86 | glpi_header($CFG_GLPI["root_doc"]."/front/computer.php"); |
||
87 | } |
||
88 | //update a computer
|
||
89 | else if (isset($_POST["update"])) { |
||
90 | checkRight("computer","w"); |
||
91 | $computer->update($_POST); |
||
92 | logEvent($_POST["ID"], "computers", 4, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][21]); |
||
93 | glpi_header($_SERVER['HTTP_REFERER']); |
||
94 | } |
||
95 | //Disconnect a device
|
||
96 | else if (isset($_GET["disconnect"])) { |
||
97 | checkRight("computer","w"); |
||
98 | Disconnect($_GET["ID"]); |
||
99 | logEvent($_GET["cID"], "computers", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][26]); |
||
100 | glpi_header($_SERVER['HTTP_REFERER']); |
||
101 | } |
||
102 | else if (isset($_POST["connect"])&&isset($_POST["item"])&&$_POST["item"]>0){ |
||
103 | checkRight("computer","w"); |
||
104 | Connect($_POST["item"],$_POST["cID"],$_POST["device_type"],$_POST["dohistory"]); |
||
105 | logEvent($_POST["cID"], "computers", 5, "inventory", $_SESSION["glpiname"] ." ".$LANG["log"][27]); |
||
106 | glpi_header($_SERVER['HTTP_REFERER']); |
||
107 | } |
||
108 | //Update a device specification
|
||
109 | elseif(isset($_POST["update_device"])) { |
||
110 | checkRight("computer","w"); |
||
111 | |||
112 | // Update quantity
|
||
113 | foreach ($_POST as $key => $val){ |
||
114 | $data=split("_",$key); |
||
115 | if (count($data)==2) |
||
116 | if ($data[0]=="quantity"){ |
||
117 | update_device_quantity($val,$data[1]); |
||
118 | } |
||
119 | } |
||
120 | |||
121 | // Update specificity
|
||
122 | foreach ($_POST as $key => $val){ |
||
123 | $data=split("_",$key); |
||
124 | if (count($data)==2) |
||
125 | if ($data[0]=="devicevalue"){ |
||
126 | update_device_specif($val,$data[1]); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | logEvent($_POST["ID"],"computers",4,"inventory",$_SESSION["glpiname"] ." ".$LANG["log"][28]); |
||
131 | glpi_header($_SERVER['HTTP_REFERER']); |
||
132 | } |
||
133 | //add a new device
|
||
134 | elseif (isset($_POST["connect_device"])) { |
||
135 | checkRight("computer","w"); |
||
136 | if (isset($_POST["new_device_id"])&&$_POST["new_device_id"]>0) |
||
137 | compdevice_add($_POST["cID"],$_POST["new_device_type"],$_POST["new_device_id"]); |
||
138 | glpi_header($_SERVER['PHP_SELF']."?ID=".$_POST["cID"]."&withtemplate=".$_POST["withtemplate"]); |
||
139 | } |
||
140 | elseif(isset($_POST["unlock_monitor"])){ |
||
141 | checkRight("computer","w"); |
||
142 | if (isset($_POST["lockmonitor"])&&count($_POST["lockmonitor"])){ |
||
143 | foreach ($_POST["lockmonitor"] as $key => $val) |
||
144 | deleteInOcsArray($_POST["ID"],$key,"import_monitor"); |
||
145 | } |
||
146 | glpi_header($_SERVER['HTTP_REFERER']); |
||
147 | } |
||
148 | elseif(isset($_POST["unlock_printer"])){ |
||
149 | checkRight("computer","w"); |
||
150 | if (isset($_POST["lockprinter"])&&count($_POST["lockprinter"])){ |
||
151 | foreach ($_POST["lockprinter"] as $key => $val) |
||
152 | deleteInOcsArray($_POST["ID"],$key,"import_printers"); |
||
153 | } |
||
154 | glpi_header($_SERVER['HTTP_REFERER']); |
||
155 | } |
||
156 | elseif(isset($_POST["unlock_soft"])){ |
||
157 | checkRight("computer","w"); |
||
158 | if (isset($_POST["locksoft"])&&count($_POST["locksoft"])){ |
||
159 | foreach ($_POST["locksoft"] as $key => $val) |
||
160 | deleteInOcsArray($_POST["ID"],$key,"import_software"); |
||
161 | } |
||
162 | glpi_header($_SERVER['HTTP_REFERER']); |
||
163 | } |
||
164 | elseif(isset($_POST["unlock_periph"])){ |
||
165 | checkRight("computer","w"); |
||
166 | if (isset($_POST["lockperiph"])&&count($_POST["lockperiph"])){ |
||
167 | foreach ($_POST["lockperiph"] as $key => $val) |
||
168 | deleteInOcsArray($_POST["ID"],$key,"import_peripheral"); |
||
169 | } |
||
170 | glpi_header($_SERVER['HTTP_REFERER']); |
||
171 | } |
||
172 | elseif(isset($_POST["unlock_ip"])){ |
||
173 | checkRight("computer","w"); |
||
174 | if (isset($_POST["lockip"])&&count($_POST["lockip"])){ |
||
175 | foreach ($_POST["lockip"] as $key => $val) |
||
176 | deleteInOcsArray($_POST["ID"],$key,"import_ip"); |
||
177 | } |
||
178 | glpi_header($_SERVER['HTTP_REFERER']); |
||
179 | } |
||
180 | elseif(isset($_POST["unlock_field"])){ |
||
181 | checkRight("computer","w"); |
||
182 | if (isset($_POST["lockfield"])&&count($_POST["lockfield"])){ |
||
183 | foreach ($_POST["lockfield"] as $key => $val) |
||
184 | deleteInOcsArray($_POST["ID"],$key,"computer_update"); |
||
185 | } |
||
186 | glpi_header($_SERVER['HTTP_REFERER']); |
||
187 | } elseif (isset($_POST["force_ocs_resynch"])){ |
||
188 | //checkRight("ocsng","w");
|
||
189 | checkRight("sync_ocsng","w"); |
||
190 | |||
191 | //Get the ocs server id associated with the machine
|
||
192 | $ocs_server_id = getOCSServerByMachineID($_POST["ID"]); |
||
193 | |||
194 | //Update the computer
|
||
195 | ocsUpdateComputer($_POST["resynch_id"],$ocs_server_id,1,1); |
||
196 | glpi_header($_SERVER['HTTP_REFERER']); |
||
197 | } else {//print computer informations |
||
198 | |||
199 | checkRight("computer","r"); |
||
200 | |||
201 | |||
202 | if (!isset($_SESSION['glpi_onglet'])) $_SESSION['glpi_onglet']=1; |
||
203 | if (isset($_GET['onglet'])) { |
||
204 | $_SESSION['glpi_onglet']=$_GET['onglet']; |
||
205 | } |
||
206 | |||
207 | |||
208 | commonHeader($LANG["Menu"][0],$_SERVER['PHP_SELF'],"inventory","computer"); |
||
209 | |||
210 | //show computer form to add
|
||
211 | if (!empty($_GET["withtemplate"])) { |
||
212 | |||
213 | if ($computer->showForm($_SERVER['PHP_SELF'],$_GET["ID"], $_GET["withtemplate"])){ |
||
214 | if ($_GET["ID"]>0){ |
||
215 | switch($_SESSION['glpi_onglet']){ |
||
216 | case 2 : |
||
217 | showSoftwareInstalled($_GET["ID"],$_GET["withtemplate"]); |
||
218 | break;
|
||
219 | case 3 : |
||
220 | showConnections($_SERVER['PHP_SELF'],$_GET["ID"],$_GET["withtemplate"]); |
||
221 | if ($_GET["withtemplate"]!=2) |
||
222 | showPortsAdd($_GET["ID"],COMPUTER_TYPE); |
||
223 | showPorts($_GET["ID"], COMPUTER_TYPE,$_GET["withtemplate"]); |
||
224 | break;
|
||
225 | case 4 : |
||
226 | showInfocomForm($CFG_GLPI["root_doc"]."/front/infocom.form.php",COMPUTER_TYPE,$_GET["ID"],1,$_GET["withtemplate"]); |
||
227 | showContractAssociated(COMPUTER_TYPE,$_GET["ID"],$_GET["withtemplate"]); |
||
228 | break;
|
||
229 | case 5 : |
||
230 | showDocumentAssociated(COMPUTER_TYPE,$_GET["ID"],$_GET["withtemplate"]); |
||
231 | break;
|
||
232 | default :
|
||
233 | if (!displayPluginAction(COMPUTER_TYPE,$_GET["ID"],$_SESSION['glpi_onglet'], $_GET["withtemplate"])) |
||
234 | showDeviceComputerForm($_SERVER['PHP_SELF'],$_GET["ID"], $_GET["withtemplate"]); |
||
235 | break;
|
||
236 | } |
||
237 | } |
||
238 | } |
||
239 | } else {
|
||
240 | |||
241 | if ($computer->showForm($_SERVER['PHP_SELF'],$_GET["ID"], $_GET["withtemplate"])) { |
||
242 | switch($_SESSION['glpi_onglet']){ |
||
243 | case -1 : |
||
244 | showDeviceComputerForm($_SERVER['PHP_SELF'],$_GET["ID"], $_GET["withtemplate"]); |
||
245 | showSoftwareInstalled($_GET["ID"]); |
||
246 | showConnections($_SERVER['PHP_SELF'],$_GET["ID"]); |
||
247 | showPortsAdd($_GET["ID"],COMPUTER_TYPE); |
||
248 | showPorts($_GET["ID"], COMPUTER_TYPE); |
||
249 | showInfocomForm($CFG_GLPI["root_doc"]."/front/infocom.form.php",COMPUTER_TYPE,$_GET["ID"]); |
||
250 | showContractAssociated(COMPUTER_TYPE,$_GET["ID"]); |
||
251 | showDocumentAssociated(COMPUTER_TYPE,$_GET["ID"]); |
||
252 | showJobListForItem($_SESSION["glpiname"],COMPUTER_TYPE,$_GET["ID"],$_GET["sort"],$_GET["order"]); |
||
253 | showOldJobListForItem($_SESSION["glpiname"],COMPUTER_TYPE,$_GET["ID"],$_GET["sort"],$_GET["order"]); |
||
254 | showLinkOnDevice(COMPUTER_TYPE,$_GET["ID"]); |
||
255 | showRegistry($_GET["ID"]); |
||
256 | displayPluginAction(COMPUTER_TYPE,$_GET["ID"],$_SESSION['glpi_onglet'],$_GET["withtemplate"]); |
||
257 | break;
|
||
258 | case 2 : |
||
259 | showSoftwareInstalled($_GET["ID"]); |
||
260 | break;
|
||
261 | case 3 : |
||
262 | showConnections($_SERVER['PHP_SELF'],$_GET["ID"]); |
||
263 | showPortsAdd($_GET["ID"],COMPUTER_TYPE); |
||
264 | showPorts($_GET["ID"], COMPUTER_TYPE); |
||
265 | break;
|
||
266 | case 4 : |
||
267 | showInfocomForm($CFG_GLPI["root_doc"]."/front/infocom.form.php",COMPUTER_TYPE,$_GET["ID"]); |
||
268 | showContractAssociated(COMPUTER_TYPE,$_GET["ID"]); |
||
269 | break;
|
||
270 | case 5 : |
||
271 | showDocumentAssociated(COMPUTER_TYPE,$_GET["ID"]); |
||
272 | break;
|
||
273 | case 6 : |
||
274 | showJobListForItem($_SESSION["glpiname"],COMPUTER_TYPE,$_GET["ID"],$_GET["sort"],$_GET["order"]); |
||
275 | showOldJobListForItem($_SESSION["glpiname"],COMPUTER_TYPE,$_GET["ID"],$_GET["sort"],$_GET["order"]); |
||
276 | break;
|
||
277 | case 7 : |
||
278 | showLinkOnDevice(COMPUTER_TYPE,$_GET["ID"]); |
||
279 | break;
|
||
280 | case 10 : |
||
281 | showNotesForm($_SERVER['PHP_SELF'],COMPUTER_TYPE,$_GET["ID"]); |
||
282 | break;
|
||
283 | case 11 : |
||
284 | showDeviceReservations($_SERVER['PHP_SELF'],COMPUTER_TYPE,$_GET["ID"]); |
||
285 | break;
|
||
286 | case 12 : |
||
287 | showHistory(COMPUTER_TYPE,$_GET["ID"]); |
||
288 | break;
|
||
289 | case 13 : |
||
290 | ocsEditLock($_SERVER['PHP_SELF'],$_GET["ID"]); |
||
291 | break;
|
||
292 | case 14: |
||
293 | showRegistry($_GET["ID"]); |
||
294 | break;
|
||
295 | default :
|
||
296 | if (!displayPluginAction(COMPUTER_TYPE,$_GET["ID"],$_SESSION['glpi_onglet'],$_GET["withtemplate"])) |
||
297 | showDeviceComputerForm($_SERVER['PHP_SELF'],$_GET["ID"], $_GET["withtemplate"]); |
||
298 | break;
|
||
299 | } |
||
300 | |||
301 | } |
||
302 | } |
||
303 | commonFooter(); |
||
304 | } |
||
305 | ?> |