ryxeo-glpi-git / htdocs / ajax / dropdownMassiveAction.php @ 1c14bcc4
Historique | Voir | Annoter | Télécharger (8,41 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: dropdownMassiveAction.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: Julien Dombre
|
33 |
// Purpose of file:
|
34 |
// ----------------------------------------------------------------------
|
35 | |
36 | |
37 |
define('GLPI_ROOT','..'); |
38 |
$NEEDED_ITEMS=array("search","enterprise","tracking","ocsng","profile"); |
39 |
include (GLPI_ROOT."/inc/includes.php"); |
40 |
header("Content-Type: text/html; charset=UTF-8"); |
41 |
header_nocache(); |
42 | |
43 |
if (isset($_POST["action"])&&isset($_POST["type"])&&!empty($_POST["type"])){ |
44 | |
45 | |
46 |
switch ($_POST["type"]){ |
47 |
case TRACKING_TYPE : |
48 |
checkTypeRight("update_ticket","1"); |
49 |
break;
|
50 |
default :
|
51 |
if (in_array($_POST["type"],$CFG_GLPI["infocom_types"])){ |
52 |
checkSeveralRightsOr(array($_POST["type"]=>"w","contract_infocom"=>"w")); |
53 |
} else {
|
54 |
checkTypeRight($_POST["type"],"w"); |
55 |
} |
56 |
break;
|
57 |
} |
58 | |
59 |
|
60 | |
61 |
echo "<input type='hidden' name='action' value='".$_POST["action"]."'>"; |
62 |
echo "<input type='hidden' name='device_type' value='".$_POST["type"]."'>"; |
63 |
switch($_POST["action"]){ |
64 |
case "activate_rule": |
65 |
echo dropdownYesNo("activate_rule"); |
66 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
67 |
break;
|
68 |
case "move_rule": |
69 |
echo "<select name='move_type'>"; |
70 |
echo "<option value='after' selected>".$LANG["buttons"][47]."</option>"; |
71 |
echo "<option value='before'>".$LANG["buttons"][46]."</option>"; |
72 |
echo "</select> "; |
73 |
dropdownRules($_POST['rule_type'],"ranking"); |
74 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
75 |
break;
|
76 |
case "add_followup": |
77 |
showAddFollowupForm(-1,true); |
78 |
break;
|
79 |
case "compute_software_category": |
80 |
case "replay_dictionnary": |
81 |
case "force_ocsng_update": |
82 |
case "force_user_ldap_update": |
83 |
case "delete": |
84 |
case "purge": |
85 |
case "restore": |
86 |
case "add_transfer_list": |
87 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
88 |
break;
|
89 |
case "unlock_ocsng_field": |
90 |
$fields['all']=$LANG["common"][66]; |
91 |
$fields+=getOcsLockableFields();
|
92 |
dropdownArrayValues("field",$fields); |
93 |
|
94 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
95 |
break;
|
96 |
case "unlock_ocsng_monitor"; |
97 |
case "unlock_ocsng_peripheral"; |
98 |
case "unlock_ocsng_software"; |
99 |
case "unlock_ocsng_printer"; |
100 |
case "unlock_ocsng_ip"; |
101 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
102 |
break;
|
103 |
case "install": |
104 |
dropdownSoftwareToInstall("lID",0,$_SESSION["glpiactive_entity"],1); |
105 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][4]."\" >"; |
106 |
break;
|
107 |
case "connect": |
108 |
dropdownConnect(COMPUTER_TYPE,$_POST["type"],"connect_item"); |
109 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
110 |
break;
|
111 |
case "connect_to_computer": |
112 |
dropdownAllItems("connect_item",0,0,$_SESSION["glpiactive_entity"],array(PHONE_TYPE,MONITOR_TYPE,PRINTER_TYPE,PERIPHERAL_TYPE),true); |
113 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
114 |
break;
|
115 |
case "disconnect": |
116 |
echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
117 |
break;
|
118 |
case "add_group": |
119 |
dropdownValue("glpi_groups","group",0); |
120 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
121 |
break;
|
122 |
case "add_userprofile": |
123 |
dropdownValue("glpi_entities","FK_entities",0,1,$_SESSION['glpiactiveentities']); |
124 |
echo ". ".$LANG["profiles"][22].":"; |
125 |
dropdownUnderProfiles("FK_profiles");
|
126 |
echo ". ".$LANG["profiles"][28].":"; |
127 |
dropdownYesNo("recursive",0); |
128 |
|
129 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
130 |
break;
|
131 |
case "add_document": |
132 |
dropdownDocument("docID");
|
133 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
134 |
break;
|
135 |
case "add_contract": |
136 |
dropdown("glpi_contracts","conID",1); |
137 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
138 |
break;
|
139 |
case "add_contact": |
140 |
dropdown("glpi_contacts","conID",1); |
141 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
142 |
break;
|
143 |
case "add_enterprise": |
144 |
dropdown("glpi_enterprises","entID",1); |
145 |
echo " <input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"".$LANG["buttons"][2]."\" >"; |
146 |
break;
|
147 |
case "update": |
148 |
$first_group=true; |
149 |
$newgroup=""; |
150 |
$items_in_group=0; |
151 |
$show_all=true; |
152 |
$show_infocoms=true; |
153 |
if (in_array($_POST["type"],$CFG_GLPI["infocom_types"])&& |
154 |
(!haveTypeRight($_POST["type"],"w")||!haveTypeRight(INFOCOM_TYPE,"w"))){ |
155 |
$show_all=false; |
156 |
$show_infocoms=haveTypeRight(INFOCOM_TYPE,"w"); |
157 |
} |
158 |
echo "<select name='id_field' id='massiveaction_field'>"; |
159 |
echo "<option value='0' selected>------</option>"; |
160 |
$searchopt=cleanSearchOption($_POST["type"],'w'); |
161 |
foreach ($searchopt as $key => $val){ |
162 |
if (!is_array($val)){ |
163 |
if (!empty($newgroup)&&$items_in_group>0) { |
164 |
echo $newgroup; |
165 |
$first_group=false; |
166 |
} |
167 |
$items_in_group=0; |
168 |
$newgroup=""; |
169 |
if (!$first_group) $newgroup.="</optgroup>"; |
170 |
$newgroup.="<optgroup label=\"$val\">"; |
171 |
} else {
|
172 |
if ($key>1 |
173 |
&&$key!=80 // No FK_entities massive action |
174 |
){ // No ID
|
175 |
if (!empty($val["linkfield"]) |
176 |
||$val["table"]=="glpi_infocoms" |
177 |
||$val["table"]=="glpi_enterprises_infocoms" |
178 |
||$val["table"]=="glpi_dropdown_budget" |
179 |
||($val["table"]=="glpi_ocs_link"&&$key==101) // auto_update_ocs |
180 |
){ |
181 |
if ($show_all){ |
182 |
$newgroup.= "<option value='$key'>".$val["name"]."</option>"; |
183 |
$items_in_group++;
|
184 |
} else {
|
185 |
// Do not show infocom items
|
186 |
if (($show_infocoms&&isInfocomSearch($_POST["type"],$key)) |
187 |
||(!$show_infocoms&&!isInfocomSearch($_POST["type"],$key)) |
188 |
){ |
189 |
$newgroup.= "<option value='$key'>".$val["name"]."</option>"; |
190 |
$items_in_group++;
|
191 |
} |
192 |
} |
193 |
} |
194 |
} |
195 |
} |
196 |
} |
197 |
if (!empty($newgroup)&&$items_in_group>0) echo $newgroup; |
198 |
if (!$first_group) |
199 |
echo "</optgroup>"; |
200 |
|
201 |
echo "</select>"; |
202 |
|
203 |
|
204 |
$params=array('id_field'=>'__VALUE__', |
205 |
'device_type'=>$_POST["type"], |
206 |
); |
207 |
ajaxUpdateItemOnSelectEvent("massiveaction_field","show_massiveaction_field",$CFG_GLPI["root_doc"]."/ajax/dropdownMassiveActionField.php",$params); |
208 |
|
209 |
echo "<span id='show_massiveaction_field'> </span>\n"; |
210 | |
211 |
break;
|
212 |
default :
|
213 |
// Plugin specific actions
|
214 |
if ($_POST["type"]>1000){ |
215 |
if (isset($PLUGIN_HOOKS['plugin_types'][$_POST["type"]])){ |
216 |
$function='plugin_'.$PLUGIN_HOOKS['plugin_types'][$_POST["type"]].'_MassiveActionsDisplay'; |
217 |
if (function_exists($function)){ |
218 |
$function($_POST["type"],$_POST["action"]); |
219 |
} |
220 |
} |
221 |
} else {
|
222 |
// Need to search display item over plugins
|
223 |
$split=split('_',$_POST["action"]); |
224 |
if (isset($split[1])){ |
225 |
$function='plugin_'.$split[1].'_MassiveActionsDisplay'; |
226 |
if (function_exists($function)){ |
227 |
$function($_POST["type"],$_POST["action"]); |
228 |
} |
229 |
} |
230 |
} |
231 |
break;
|
232 | |
233 |
} |
234 |
} |
235 | |
236 |
?>
|