Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / ldap.parameters.class.php @ b67d8923

Historique | Voir | Annoter | Télécharger (4,86 ko)

1
<?php
2

    
3
/*
4
 * @version $Id: ldap.parameters.class.php 7882 2009-01-23 18:24:05Z moyo $
5
 -------------------------------------------------------------------------
6
 GLPI - Gestionnaire Libre de Parc Informatique
7
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
8

9
 http://indepnet.net/   http://glpi-project.org
10
 -------------------------------------------------------------------------
11

12
 LICENSE
13

14
 This file is part of GLPI.
15

16
 GLPI is free software; you can redistribute it and/or modify
17
 it under the terms of the GNU General Public License as published by
18
 the Free Software Foundation; either version 2 of the License, or
19
 (at your option) any later version.
20

21
 GLPI is distributed in the hope that it will be useful,
22
 but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 GNU General Public License for more details.
25

26
 You should have received a copy of the GNU General Public License
27
 along with GLPI; if not, write to the Free Software
28
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
 --------------------------------------------------------------------------
30
 */
31

    
32
// ----------------------------------------------------------------------
33
// Original Author of file: Olivier Andreotti
34
// Purpose of file:
35
// ----------------------------------------------------------------------
36
if (!defined('GLPI_ROOT')) {
37
        die("Sorry. You can't access directly to this file");
38
}
39

    
40
/// LDAP criteria class
41
class LdapCriteria extends CommonDBTM {
42

    
43
        /**
44
         * Constructor
45
        **/
46
        function LdapCriteria() {
47
                $this->table = "glpi_rules_ldap_parameters";
48

    
49
        }
50

    
51
        /// Get parameters list
52
        function getParametersList() {
53
                global $DB;
54
                $sql = "SELECT * 
55
                        FROM `" . $this->table . "` 
56
                        WHERE rule_type=".RULE_AFFECT_RIGHTS." 
57
                        ORDER BY name ASC";
58
                $result = $DB->query($sql);
59
                $parameters = array ();
60

    
61
                while ($datas = $DB->fetch_array($result))
62
                        $parameters[] = $datas;
63

    
64
                return $parameters;
65
        }
66

    
67
        /**
68
         * Print the ldap criteria form
69
         *
70
         *@param $target filename : where to go when done.
71
         **/
72
        function showForm($target) {
73
                global $LANG,$CFG_GLPI;
74
                $canedit = haveRight("config", "w");
75
                $ID=-1;
76
                $parameters = $this->getParametersList();
77

    
78
                echo "<form name='entityaffectation_form' id='ldapcriterias_form' method='post' action=\"$target\">";
79

    
80
                if ($canedit) {
81
                        echo "<div class='center'>";
82
                        echo "<table  class='tab_cadre_fixe'>";
83
                        echo "<tr class='tab_bg_1'><th colspan='5'>" .$LANG["ruleldap"][3] . "</tr><tr><td class='tab_bg_2' align='center'>";
84
                        echo "</td><td align='center' class='tab_bg_2'>";
85
                        echo $LANG["common"][16] . ":";
86
                        autocompletionTextField("name", $this->table, "name", "", 30);
87
                        echo $LANG["setup"][601] . ":";
88
                        autocompletionTextField("value", $this->table, "value", "", 30);
89
                        echo "<input type=hidden name='rule_type' value=\"" . RULE_AFFECT_RIGHTS . "\">";
90
                        echo "<input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit'>";
91
                        echo "</td></tr>";
92
                        
93
                        echo "</table></div><br>";
94
                }
95

    
96
                if (!count($parameters)){
97
                        echo "<center>".$LANG["ruleldap"][2]."</center>";
98
                } else {
99
                        echo "<div class='center'><table class='tab_cadrehov'><tr><th colspan='3'>" . $LANG["common"][53]." ".$LANG["ruleldap"][1] . "</th></tr>";
100
                        echo "<tr class='tab_bg_1'><td class='tab_bg_2' colspan='2'>" .  $LANG["common"][16]."</td><td class='tab_bg_2'>".$LANG["setup"][601] . "</td></tr>";
101

    
102
                        foreach ($parameters as $parameter) {
103
                                echo "<tr class='tab_bg_1'>";
104

    
105
                                if ($canedit) {
106
                                        echo "<td width='10'>";
107
                                        $sel = "";
108
                                        if (isset ($_GET["select"]) && $_GET["select"] == "all")
109
                                                $sel = "checked";
110
                                        echo "<input type='checkbox' name='item[" . $parameter["ID"] . "]' value='1' $sel>";
111
                                        echo "</td>";
112
                                }
113

    
114
                                echo "<td>" . $parameter["name"] . "</td>";
115
                                echo "<td>" . $parameter["value"] . "</td>";
116
                                echo "</tr>";
117
                        }
118
                        echo "</table></div>";
119

    
120
                        if ($canedit) {
121
                                echo "<div class='center'>";
122
                                echo "<table  width='80%'>";
123
                                echo "<tr><td><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/arrow-left.png\" alt=''></td><td class='center'><a onclick= \"if ( markAllRows('ldapcriterias_form') ) return false;\" href='" . $_SERVER['PHP_SELF'] . "?ID=$ID&amp;select=all'>" . $LANG["buttons"][18] . "</a></td>";
124
        
125
                                echo "<td>/</td><td class='center'><a onclick= \"if ( unMarkAllRows('ldapcriterias_form') ) return false;\" href='" . $_SERVER['PHP_SELF'] . "?ID=$ID&amp;select=none'>" . $LANG["buttons"][19] . "</a>";
126
                                echo "</td><td align='left' width='80%'>";
127
                                echo "<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>";
128
                                echo "</td>";
129
                                echo "</table>";
130
        
131
                                echo "</div>";
132
        
133
                        }
134
                }
135
                echo "</form>";
136
        }
137
        
138
        function prepareInputForAdd($input){
139
                //LDAP parameters MUST be in lower case
140
                //because the are retieved in lower case  from the directory
141
                $input["value"] = strtolower($input["value"]);
142
                return $input;
143
        }
144
}
145

    
146
?>
Redmine Appliance - Powered by TurnKey Linux