ryxeo-glpi-git / ajax / dropdownUsersTracking.php @ b67d8923
Historique | Voir | Annoter | Télécharger (3,9 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: dropdownUsersTracking.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 |
if(ereg("dropdownUsersTracking.php",$_SERVER['PHP_SELF'])){ |
37 |
define('GLPI_ROOT','..'); |
38 |
$AJAX_INCLUDE=1; |
39 |
include (GLPI_ROOT."/inc/includes.php"); |
40 |
header("Content-Type: text/html; charset=UTF-8"); |
41 |
header_nocache(); |
42 |
|
43 |
} |
44 |
if (!defined('GLPI_ROOT')){ |
45 |
die("Can not acces directly to this file"); |
46 |
} |
47 |
|
48 |
checkCentralAccess(); |
49 |
|
50 |
// Make a select box with all glpi users
|
51 |
|
52 |
$where=" glpi_users.deleted='0' AND glpi_users.active='1' "; |
53 |
if (strlen($_POST['searchText'])>0&&$_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]){ |
54 |
$where.=" AND (glpi_users.name ".makeTextSearch($_POST['searchText'])." OR glpi_users.realname ".makeTextSearch($_POST['searchText'])." OR glpi_users.firstname ".makeTextSearch($_POST['searchText']).")"; |
55 |
} |
56 |
|
57 |
$NBMAX=$CFG_GLPI["dropdown_max"]; |
58 |
$LIMIT="LIMIT 0,$NBMAX"; |
59 |
if ($_POST['searchText']==$CFG_GLPI["ajax_wildcard"]) $LIMIT=""; |
60 |
|
61 |
$query = "SELECT glpi_users.ID, glpi_users.name, glpi_users.realname, glpi_users.firstname FROM glpi_users WHERE $where AND ID IN (SELECT DISTINCT ".$_POST['field']." FROM glpi_tracking ".getEntitiesRestrictRequest("WHERE","glpi_tracking").") "; |
62 |
|
63 |
$query.=" ORDER BY glpi_users.realname,glpi_users.firstname,glpi_users.name $LIMIT"; |
64 |
|
65 |
$result = $DB->query($query); |
66 |
|
67 |
$users=array(); |
68 |
if ($DB->numrows($result)) { |
69 |
while ($data=$DB->fetch_array($result)) { |
70 |
$users[$data["ID"]]=formatUserName($data["ID"],$data["name"],$data["realname"],$data["firstname"]); |
71 |
$logins[$data["ID"]]=$data["name"]; |
72 |
} |
73 |
} |
74 |
|
75 |
asort($users); |
76 |
|
77 |
echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name=\"".$_POST['myname']."\">"; |
78 |
|
79 |
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"]&&$DB->numrows($result)==$NBMAX) |
80 |
echo "<option value=\"0\">--".$LANG["common"][11]."--</option>"; |
81 |
|
82 |
echo "<option value=\"0\">[ ".$LANG["common"][66]." ]</option>"; |
83 |
|
84 |
if (isset($_POST['value'])){ |
85 |
$output=getUserName($_POST['value']); |
86 |
if (!empty($output)&&$output!=" ") |
87 |
echo "<option selected value='".$_POST['value']."' title=\"".cleanInputText($output)."\">".substr($output,0,$CFG_GLPI["dropdown_limit"])."</option>"; |
88 |
} |
89 |
|
90 |
if (count($users)) { |
91 |
foreach ($users as $ID => $output){ |
92 |
|
93 |
echo "<option value=\"".$ID."\" ".($ID == $_POST['value']?"selected":"")." title=\"".cleanInputText($output)."\">".substr($output,0,$CFG_GLPI["dropdown_limit"])."</option>"; |
94 |
} |
95 |
} |
96 |
echo "</select>"; |
97 |
|
98 |
if (isset($_POST["comments"])&&$_POST["comments"]){ |
99 |
$params=array('value'=>'__VALUE__','table'=>'glpi_users'); |
100 |
ajaxUpdateItemOnSelectEvent("dropdown_".$_POST["myname"].$_POST["rand"],"comments_".$_POST["myname"].$_POST["rand"],$CFG_GLPI["root_doc"]."/ajax/comments.php",$params,false); |
101 |
} |
102 |
|
103 |
?>
|