ryxeo-glpi-git / ajax / dropdownRules.php @ b67d8923
Historique | Voir | Annoter | Télécharger (2,71 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: dropdownRules.php 7882 2009-01-23 18:24:05Z 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: Remi Collet
|
33 |
// Purpose of file:
|
34 |
// ----------------------------------------------------------------------
|
35 |
|
36 |
// Direct access to file
|
37 |
if(ereg("dropdownRules.php",$_SERVER['PHP_SELF'])){ |
38 |
define('GLPI_ROOT','..'); |
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 |
checkLoginUser(); |
49 |
|
50 |
|
51 |
// Make a select box with preselected values
|
52 |
if (!isset($_POST["limit"])) { |
53 |
$_POST["limit"]=$CFG_GLPI["dropdown_limit"]; |
54 |
} |
55 |
|
56 |
$NBMAX=$CFG_GLPI["dropdown_max"]; |
57 |
$LIMIT="LIMIT 0,$NBMAX"; |
58 |
|
59 |
$sql = "SELECT ID,name,ranking FROM glpi_rules_descriptions WHERE rule_type='".$_POST["type"]."'"; |
60 |
|
61 |
if ($_POST['searchText']==$CFG_GLPI["ajax_wildcard"]) { |
62 |
$LIMIT=""; |
63 |
} else {
|
64 |
$sql .= " AND name ".makeTextSearch($_POST['searchText']); |
65 |
} |
66 |
$sql .= " ORDER BY ranking ASC " . $LIMIT; |
67 |
|
68 |
$result = $DB->query($sql); |
69 |
|
70 |
echo "<select id='dropdown_".$_POST["myname"].$_POST["rand"]."' name=\"".$_POST['myname']."\" size='1'>"; |
71 |
|
72 |
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"] && $DB->numrows($result)==$NBMAX) { |
73 |
echo "<option value='0'>--".$LANG["common"][11]."--</option>"; |
74 |
} else {
|
75 |
echo "<option value='0'>-----</option>"; |
76 |
} |
77 |
|
78 |
|
79 |
if ($DB->numrows($result)) { |
80 |
while ($data =$DB->fetch_array($result)) { |
81 |
$ID = $data['ID']; |
82 |
$name = $data['name']; |
83 |
echo "<option value='$ID' title=\"".cleanInputText($name)."\">".utf8_substr($name,0,$_POST["limit"])."</option>"; |
84 |
} |
85 |
} |
86 |
echo "</select>"; |
87 |
|
88 |
?>
|