Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / htdocs / ajax / dropdownDocument.php @ 1c14bcc4

Historique | Voir | Annoter | Télécharger (3,22 ko)

1
<?php
2
/*
3
 * @version $Id: dropdownDocument.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("dropdownDocument.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
$where=" WHERE  (glpi_docs.rubrique = '".$_POST['rubdoc']."' AND glpi_docs.deleted='0' ) ";
51

    
52

    
53
if (isset($_POST["entity_restrict"])){
54
        $where.=getEntitiesRestrictRequest("AND","glpi_docs",'',$_POST["entity_restrict"],true);
55
} else {
56
        $where.=getEntitiesRestrictRequest("AND","glpi_docs",'','',true);
57
}
58

    
59
if (isset($_POST['used'])) {
60
        $where .=" AND ID NOT IN (0";
61
        if (is_array($_POST['used'])) {
62
                        $used=$_POST['used'];
63
                } else {
64
                        $used=unserialize(stripslashes($_POST['used']));
65
                }
66
        foreach($used as $val)
67
                $where .= ",$val";
68
        $where .= ") ";
69
}
70

    
71
if ($_POST['searchText']!=$CFG_GLPI["ajax_wildcard"])
72
        $where.=" AND glpi_docs.name ".makeTextSearch($_POST['searchText']);
73

    
74
$NBMAX=$CFG_GLPI["dropdown_max"];
75
$LIMIT="LIMIT 0,$NBMAX";
76
if ($_POST['searchText']==$CFG_GLPI["ajax_wildcard"]) $LIMIT="";
77

    
78

    
79
$query = "SELECT * FROM glpi_docs $where ORDER BY FK_entities, name $LIMIT";
80
//error_log($query);
81
$result = $DB->query($query);
82

    
83
echo "<select name=\"".$_POST['myname']."\">";
84

    
85
echo "<option value=\"0\">-----</option>";
86

    
87
if ($DB->numrows($result)) {
88
        $prev=-1;
89
        while ($data=$DB->fetch_array($result)) {
90
                if ($data["FK_entities"]!=$prev) {
91
                        if ($prev>=0) {
92
                                echo "</optgroup>";
93
                        }
94
                        $prev=$data["FK_entities"];
95
                        echo "<optgroup label=\"". getDropdownName("glpi_entities", $prev) ."\">";
96
                }
97
                $output = $data["name"];
98
                echo "<option value=\"".$data["ID"]."\" title=\"".cleanInputText($output)."\">".substr($output,0,$CFG_GLPI["dropdown_limit"])."</option>";
99
        }
100
        if ($prev>=0) {
101
                echo "</optgroup>";
102
        }
103
}
104
echo "</select>";
105

    
106
?>
Redmine Appliance - Powered by TurnKey Linux