ryxeo-glpi-git / inc / group.class.php @ b67d8923
Historique | Voir | Annoter | Télécharger (6,4 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: group.class.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 (!defined('GLPI_ROOT')){ |
||
37 | die("Sorry. You can't access directly to this file"); |
||
38 | } |
||
39 | |||
40 | |||
41 | // CLASSES contact
|
||
42 | class Group extends CommonDBTM{ |
||
43 | |||
44 | /**
|
||
45 | * Constructor
|
||
46 | **/
|
||
47 | function Group () { |
||
48 | $this->table="glpi_groups"; |
||
49 | $this->type=GROUP_TYPE; |
||
50 | } |
||
51 | |||
52 | function cleanDBonPurge($ID) { |
||
53 | global $DB,$CFG_GLPI,$LINK_ID_TABLE; |
||
54 | |||
55 | $query = "DELETE from glpi_users_groups WHERE FK_groups = '$ID'"; |
||
56 | $DB->query($query); |
||
57 | |||
58 | } |
||
59 | |||
60 | function post_getEmpty () { |
||
61 | global $CFG_GLPI; |
||
62 | //$this->fields["ldap_field"]=$CFG_GLPI["ldap_field_group"];
|
||
63 | } |
||
64 | |||
65 | |||
66 | function defineOnglets($withtemplate){ |
||
67 | global $LANG; |
||
68 | if (haveRight("user","r")) |
||
69 | $ong[1]=$LANG["Menu"][14]; |
||
70 | |||
71 | $ong[2]=$LANG["common"][1]; |
||
72 | return $ong; |
||
73 | } |
||
74 | |||
75 | /**
|
||
76 | * Print the group form
|
||
77 | *
|
||
78 | *
|
||
79 | * Print group form
|
||
80 | *
|
||
81 | *@param $target filename : where to go when done.
|
||
82 | *@param $ID Integer : Id of the contact to print
|
||
83 | *@param $withtemplate='' boolean : template or basic item
|
||
84 | *
|
||
85 | *
|
||
86 | *@return Nothing (display)
|
||
87 | *
|
||
88 | **/
|
||
89 | function showForm ($target,$ID,$withtemplate='') { |
||
90 | |||
91 | global $CFG_GLPI, $LANG; |
||
92 | |||
93 | if (!haveRight("group","r")) return false; |
||
94 | |||
95 | $con_spotted=false; |
||
96 | |||
97 | if (empty($ID)) { |
||
98 | |||
99 | if($this->getEmpty()) $con_spotted = true; |
||
100 | } else {
|
||
101 | if($this->getFromDB($ID)&&haveAccessToEntity($this->fields["FK_entities"])) $con_spotted = true; |
||
102 | } |
||
103 | |||
104 | if ($con_spotted){ |
||
105 | |||
106 | $this->showOnglets($ID, $withtemplate,$_SESSION['glpi_onglet']); |
||
107 | |||
108 | echo "<form method='post' name=form action=\"$target\"><div class='center'>"; |
||
109 | if (empty($ID)){ |
||
110 | echo "<input type='hidden' name='FK_entities' value='".$_SESSION["glpiactive_entity"]."'>"; |
||
111 | } |
||
112 | |||
113 | echo "<table class='tab_cadre_fixe' cellpadding='2' >"; |
||
114 | echo "<tr><th colspan='2'>"; |
||
115 | if (empty($ID)) { |
||
116 | echo $LANG["setup"][605]; |
||
117 | |||
118 | } else {
|
||
119 | echo $LANG["common"][2]." ".$this->fields["ID"]; |
||
120 | } |
||
121 | if (isMultiEntitiesMode()){
|
||
122 | echo " (".getDropdownName("glpi_entities",$this->fields["FK_entities"]).")"; |
||
123 | } |
||
124 | |||
125 | echo "</th></tr>"; |
||
126 | |||
127 | echo "<tr><td class='tab_bg_1' valign='top'>"; |
||
128 | |||
129 | echo "<table cellpadding='1' cellspacing='0' border='0'>\n"; |
||
130 | |||
131 | echo "<tr><td>".$LANG["common"][16].": </td>"; |
||
132 | echo "<td>"; |
||
133 | autocompletionTextField("name","glpi_groups","name",$this->fields["name"],30,$this->fields["FK_entities"]); |
||
134 | echo "</td></tr>"; |
||
135 | |||
136 | echo "<tr><td>".$LANG["common"][64].": </td>"; |
||
137 | echo "<td>"; |
||
138 | dropdownUsers('FK_users',$this->fields["FK_users"],'all',0,1,$this->fields["FK_entities"]); |
||
139 | echo "</td></tr>"; |
||
140 | |||
141 | if(useAuthLdap()){
|
||
142 | echo "<tr><td colspan='2' align='center'>".$LANG["setup"][256].": </td>"; |
||
143 | echo "</tr>"; |
||
144 | |||
145 | echo "<tr><td>".$LANG["setup"][260].": </td>"; |
||
146 | echo "<td>"; |
||
147 | autocompletionTextField("ldap_field","glpi_groups","ldap_field",$this->fields["ldap_field"],30,$this->fields["FK_entities"]); |
||
148 | echo "</td></tr>"; |
||
149 | |||
150 | echo "<tr><td>".$LANG["setup"][601].": </td>"; |
||
151 | echo "<td>"; |
||
152 | autocompletionTextField("ldap_value","glpi_groups","ldap_value",$this->fields["ldap_value"],30,$this->fields["FK_entities"]); |
||
153 | echo "</td></tr>"; |
||
154 | |||
155 | echo "<tr><td colspan='2' align='center'>".$LANG["setup"][257].": </td>"; |
||
156 | echo "</tr>"; |
||
157 | |||
158 | |||
159 | echo "<tr><td>".$LANG["setup"][261].": </td>"; |
||
160 | echo "<td>"; |
||
161 | autocompletionTextField("ldap_group_dn","glpi_groups","ldap_group_dn",$this->fields["ldap_group_dn"],30,$this->fields["FK_entities"]); |
||
162 | echo "</td></tr>"; |
||
163 | } |
||
164 | |||
165 | echo "</table>"; |
||
166 | |||
167 | echo "</td>\n"; |
||
168 | |||
169 | echo "<td class='tab_bg_1' valign='top'>"; |
||
170 | |||
171 | echo "<table cellpadding='1' cellspacing='0' border='0'><tr><td>"; |
||
172 | echo $LANG["common"][25].": </td></tr>"; |
||
173 | echo "<tr><td class='center'><textarea cols='45' rows='4' name='comments' >".$this->fields["comments"]."</textarea>"; |
||
174 | echo "</td></tr></table>"; |
||
175 | |||
176 | echo "</td>"; |
||
177 | echo "</tr>"; |
||
178 | |||
179 | if (haveRight("group","w")) |
||
180 | if ($ID=="") { |
||
181 | |||
182 | echo "<tr>"; |
||
183 | echo "<td class='tab_bg_2' valign='top' colspan='2'>"; |
||
184 | echo "<div class='center'><input type='submit' name='add' value=\"".$LANG["buttons"][8]."\" class='submit'></div>"; |
||
185 | echo "</td>"; |
||
186 | echo "</tr>"; |
||
187 | |||
188 | |||
189 | } else {
|
||
190 | |||
191 | echo "<tr>"; |
||
192 | echo "<td class='tab_bg_2' valign='top'>"; |
||
193 | echo "<input type='hidden' name='ID' value=\"$ID\">\n"; |
||
194 | echo "<div class='center'><input type='submit' name='update' value=\"".$LANG["buttons"][7]."\" class='submit' ></div>"; |
||
195 | echo "</td>\n\n"; |
||
196 | echo "<td class='tab_bg_2' valign='top'>\n"; |
||
197 | echo "<div class='center'><input type='submit' name='delete' value=\"".$LANG["buttons"][6]."\" class='submit'></div>"; |
||
198 | |||
199 | echo "</td>"; |
||
200 | echo "</tr>"; |
||
201 | |||
202 | } |
||
203 | echo "</table></div></form>"; |
||
204 | |||
205 | } else {
|
||
206 | echo "<div class='center'><strong>".$LANG["common"][54]."</strong></div>"; |
||
207 | return false; |
||
208 | |||
209 | } |
||
210 | return true; |
||
211 | } |
||
212 | |||
213 | |||
214 | /**
|
||
215 | * Print a good title for group pages
|
||
216 | *
|
||
217 | *@return nothing (display)
|
||
218 | **/
|
||
219 | function title() { |
||
220 | global $LANG, $CFG_GLPI; |
||
221 | |||
222 | $buttons = array (); |
||
223 | if (haveRight("group", "w") && haveRight("user_auth_method", "w") && useAuthLdap()) { |
||
224 | $buttons["ldap.group.php"] = $LANG["setup"][3]; |
||
225 | $title=""; |
||
226 | } else {
|
||
227 | $title = $LANG["Menu"][36]; |
||
228 | } |
||
229 | |||
230 | displayTitle($CFG_GLPI["root_doc"] . "/pics/groupes.png", $LANG["Menu"][36], $title, $buttons); |
||
231 | } |
||
232 | |||
233 | } |
||
234 | |||
235 | ?> |