ryxeo-glpi-git / ajax / dropdownUsers.php @ b67d8923
Historique | Voir | Annoter | Télécharger (4,19 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: dropdownUsers.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 | // Direct access to file
|
||
37 | if(ereg("dropdownUsers.php",$_SERVER['PHP_SELF'])){ |
||
38 | define('GLPI_ROOT','..'); |
||
39 | $AJAX_INCLUDE=1; |
||
40 | include (GLPI_ROOT."/inc/includes.php"); |
||
41 | header("Content-Type: text/html; charset=UTF-8"); |
||
42 | header_nocache(); |
||
43 | } |
||
44 | if (!defined('GLPI_ROOT')){ |
||
45 | die("Can not acces directly to this file"); |
||
46 | } |
||
47 | |||
48 | checkCentralAccess(); |
||
49 | // Make a select box with all glpi users
|
||
50 | |||
51 | if (!isset($_POST['right'])) { |
||
52 | $_POST['right']="all"; |
||
53 | } |
||
54 | // Default view : Nobody
|
||
55 | if (!isset($_POST['all'])) { |
||
56 | $_POST['all']=0; |
||
57 | } |
||
58 | |||
59 | $used=array(); |
||
60 | |||
61 | if (isset($_POST['used'])) { |
||
62 | if (is_array($_POST['used'])) { |
||
63 | $used=$_POST['used']; |
||
64 | } else {
|
||
65 | $used=unserialize(stripslashes($_POST['used'])); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | $result=dropdownUsersSelect(false, $_POST['right'], $_POST["entity_restrict"], $_POST['value'], $used, $_POST['searchText']); |
||
70 | |||
71 | |||
72 | $users=array(); |
||
73 | if ($DB->numrows($result)) { |
||
74 | while ($data=$DB->fetch_array($result)) { |
||
75 | $users[$data["ID"]]=formatUserName($data["ID"],$data["name"],$data["realname"],$data["firstname"]); |
||
76 | $logins[$data["ID"]]=$data["name"]; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | asort($users); |
||
81 | |||
82 | echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name=\"".$_POST['myname']."\">"; |
||
83 | |||
84 | if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"] && $DB->numrows($result)==$CFG_GLPI["dropdown_max"]) |
||
85 | echo "<option value=\"0\">--".$LANG["common"][11]."--</option>"; |
||
86 | |||
87 | |||
88 | if ($_POST['all']==0){ |
||
89 | echo "<option value=\"0\">[ Nobody ]</option>"; |
||
90 | } else if($_POST['all']==1) { |
||
91 | echo "<option value=\"0\">[ ".$LANG["common"][66]." ]</option>"; |
||
92 | } |
||
93 | |||
94 | if (isset($_POST['value'])){ |
||
95 | $output=getUserName($_POST['value']); |
||
96 | if (!empty($output)&&$output!=" ") |
||
97 | echo "<option selected value='".$_POST['value']."'>".$output."</option>"; |
||
98 | } |
||
99 | |||
100 | if (count($users)) { |
||
101 | foreach ($users as $ID => $output){ |
||
102 | |||
103 | echo "<option value=\"".$ID."\" title=\"".cleanInputText($output." - ".$logins[$ID])."\">".substr($output,0,$CFG_GLPI["dropdown_limit"])."</option>"; |
||
104 | } |
||
105 | } |
||
106 | echo "</select>"; |
||
107 | |||
108 | if (isset($_POST["comments"])&&$_POST["comments"]){ |
||
109 | $params=array('value'=>'__VALUE__','table'=>"glpi_users"); |
||
110 | if (isset($_POST['update_link'])){ |
||
111 | $params['withlink']="comments_link_".$_POST["myname"].$_POST["rand"]; |
||
112 | } |
||
113 | ajaxUpdateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],"comments_".$_POST["myname"].$_POST["rand"],$CFG_GLPI["root_doc"]."/ajax/comments.php",$params,false); |
||
114 | } |
||
115 | |||
116 | // Manage updates others dropdown for helpdesk
|
||
117 | if (isset($_POST["helpdesk_ajax"])&&$_POST["helpdesk_ajax"]){ |
||
118 | |||
119 | $params=array('userID'=>'__VALUE__', |
||
120 | 'entity_restrict'=>$_POST["entity_restrict"], |
||
121 | 'device_type'=>0 |
||
122 | ); |
||
123 | ajaxUpdateItemOnSelectEvent("dropdown_author".$_POST["rand"],"tracking_my_devices",$CFG_GLPI["root_doc"]."/ajax/updateTrackingDeviceType.php",$params,false); |
||
124 | |||
125 | $params=array('value'=>'__VALUE__' |
||
126 | ); |
||
127 | ajaxUpdateItemOnSelectEvent("dropdown_author".$_POST["rand"],"uemail_result",$CFG_GLPI["root_doc"]."/ajax/uemailUpdate.php",$params,false); |
||
128 | |||
129 | } |
||
130 | |||
131 | |||
132 | ?> |