Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / profile.function.php @ b67d8923

Historique | Voir | Annoter | Télécharger (8,96 ko)

1
<?php
2
/*
3
 * @version $Id: profile.function.php 7875 2009-01-23 15:16:47Z 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
function showProfileConfig($target,$ID,$prof){
41
        global $LANG,$CFG_GLPI;
42
        
43
        $onfocus="";
44
                if (!empty($ID)&&$ID){
45
                        $prof->getFromDB($ID);
46
                } else {
47
                        $prof->getEmpty();
48
                        $onfocus="onfocus=\"this.value=''\"";
49
                }
50
        
51
        if (empty($prof->fields["interface"])) $prof->fields["interface"]="helpdesk";
52
        if (empty($prof->fields["name"])) $prof->fields["name"]=$LANG["common"][0];
53
        
54
        echo "<form name='form' method='post' action=\"$target\">";
55
        echo "<div class='center'>";
56
        echo "<table class='tab_cadre_fixe'><tr>";
57
        echo "<th>".$LANG["common"][16]." :&nbsp;&nbsp;&nbsp;&nbsp;";
58
        echo "<input type='text' name='name' value=\"".$prof->fields["name"]."\" $onfocus></th>";
59
        echo "<th>".$LANG["profiles"][2]." :&nbsp;&nbsp;&nbsp;&nbsp;";
60
        echo "<select name='interface' id='profile_interface'>";
61
        echo "<option value='helpdesk' ".($prof->fields["interface"]=="helpdesk"?"selected":"").">".$LANG["Menu"][31]."</option>";
62
        echo "<option value='central' ".($prof->fields["interface"]=="central"?"selected":"").">".$LANG["title"][0]."</option>";
63
        echo "</select></th>";
64
        echo "</tr></table>";
65

    
66
        $params=array('interface'=>'__VALUE__','ID'=>$ID,);
67
        
68
        ajaxUpdateItemOnSelectEvent("profile_interface","profile_form",$CFG_GLPI["root_doc"]."/ajax/profiles.php",$params,false);
69
        ajaxUpdateItem("profile_form",$CFG_GLPI["root_doc"]."/ajax/profiles.php",$params,false,'profile_interface');
70

    
71
        echo "<div align='center' id='profile_form'>";
72
        echo "</div>";
73
        echo "</div>";
74
        showLegend();
75
        echo "</form>";
76
}
77

    
78
        
79
function showProfileEntityUser($target,$ID,$prof){        
80
         
81
         global $DB,$LANG,$CFG_GLPI;
82
         
83
        $canedit=haveRight("user","w");
84

    
85
        $show=true;
86
         if (!empty($ID)&&$ID){
87
                $prof->getFromDB($ID);
88
        } else {
89
                $prof->getEmpty();
90
                $show=false;
91
        }
92
                 
93
         echo "<div class='center'>";
94
        echo "<table class='tab_cadre_fixe'><tr>";
95
        echo "<th>".$LANG["profiles"][22]." :&nbsp;&nbsp;&nbsp;&nbsp;".$prof->fields["name"]."</th></tr>";
96
        echo "<tr><th colspan='2'>".$LANG["Menu"][14]." (D=".$LANG["profiles"][29].", R=".$LANG["profiles"][28].")</th></tr>";
97
         echo "</table>";
98
        echo "</div>";
99
          
100
        if (!$show){
101
                return false;
102
        }
103

    
104
          $query="SELECT glpi_users.*, glpi_users_profiles.FK_entities AS entity, glpi_users_profiles.ID AS linkID, glpi_users_profiles.dynamic as dynamic,glpi_users_profiles.recursive as recursive   
105
                 FROM glpi_users_profiles 
106
                 LEFT JOIN glpi_entities ON (glpi_entities.ID=glpi_users_profiles.FK_entities)
107
                 LEFT JOIN glpi_users ON (glpi_users.ID=glpi_users_profiles.FK_users)
108
                 WHERE glpi_users_profiles.FK_profiles='".$ID."' AND glpi_users.deleted=0 ".getEntitiesRestrictRequest("AND","glpi_users_profiles")." 
109
                 ORDER BY glpi_entities.completename";
110

    
111
         echo "<div class='center'>";
112
        echo "<table class='tab_cadre_fixe'>";
113

    
114
        $i=0;
115
        $nb_per_line=3;
116

    
117
         if ($result = $DB->query($query))
118
         { 
119
                 if ($DB->numrows($result)!=0)
120
                 {
121
                         
122
                         $temp=-1;
123
                         while ($data=$DB->fetch_array($result)) 
124
                        {        
125
                                 if($data["entity"]!=$temp)
126
                                {
127
                                        while ($i%$nb_per_line!=0)
128
                                        {
129
                                                if ($canedit){
130
                                                        echo "<td width='10'>&nbsp;</td>";
131
                                                }
132
                                                echo "<td class='tab_bg_1'>&nbsp;</td>\n";
133
                                                $i++;
134
                                        }
135

    
136
                                        if ($i!=0) {
137
                                                echo "</table>";
138
                                                if ($canedit){
139
                                                        echo "<div class='center'>";
140
                                                        echo "<table width='100%'>";
141
                                                        echo "<tr><td><img src=\"".$CFG_GLPI["root_doc"]."/pics/arrow-left.png\" alt=''></td><td class='center'><a onclick= \"if ( markAllRows('profileuser_form$temp') ) return false;\" href='".$_SERVER['PHP_SELF']."?ID=$ID&amp;select=all'>".$LANG["buttons"][18]."</a></td>";
142
                                                        
143
                                                        echo "<td>/</td><td class='center'><a onclick= \"if ( unMarkAllRows('profileuser_form$temp') ) return false;\" href='".$_SERVER['PHP_SELF']."?ID=$ID&amp;select=none'>".$LANG["buttons"][19]."</a>";
144
                                                        echo "</td><td align='left' width='80%'>";
145
                                                        dropdownValue("glpi_entities","FK_entities",0,1,$_SESSION['glpiactiveentities']);
146
                                                        echo "&nbsp;<input type='submit' name='moveentity' value=\"".$LANG["buttons"][20]."\"
147
 class='submit'>";
148
                                                        echo "&nbsp;<input type='submit' name='deleteuser' value=\"".$LANG["buttons"][6]."\" class='submit'>";
149

    
150
                                                        echo "</td>";
151
                                                        echo "</table>";
152
                                                        echo "</div>";
153
                                                }
154
                                                echo "</div></form></td></tr>\n";
155
                                        }
156

    
157

    
158
                                        // New entity
159
                                         $i=0;
160
                                         $temp=$data["entity"];                
161

    
162
                                        
163
                                        echo "<tr class='tab_bg_2'>";
164
                                        echo "<td align='left'>"; 
165
                                        echo "<a href=\"javascript:showHideDiv('entity$temp','imgcat$temp', '".GLPI_ROOT."/pics/folder.png','".GLPI_ROOT."/pics/folder-open.png');\">";
166
                                        echo "<img alt='' name='imgcat$temp' src=\"".GLPI_ROOT."/pics/folder.png\">&nbsp; <strong>".getDropdownName('glpi_entities',$data["entity"])."</strong>";
167
                                        echo "</a>"; 
168
                                        echo "</td>"; 
169
                                        echo "</tr>"; 
170
                                        echo "<tr><td>";
171

    
172
                                        echo "<form name='profileuser_form$temp' id='profileuser_form$temp' method='post' action=\"$target\">";
173
                                        echo "<div align='center' id='entity$temp' style=\"display:none;\">\n"; 
174
                                        echo "<table class='tab_cadre_fixe'>\n";
175
                                }
176

    
177
                                 if ($i%$nb_per_line==0) {
178
                                        if ($i!=0) echo "</tr>\n";
179
                                                echo "<tr class='tab_bg_1'>\n";
180
                                        $i=0;        
181
                                }
182

    
183
                                if ($canedit){
184
                                        echo "<td width='10'>";
185
                                        $sel="";
186
                                        if (isset($_GET["select"])&&$_GET["select"]=="all") $sel="checked";
187
                                        echo "<input type='checkbox' name='item[".$data["linkID"]."]' value='1' $sel>";
188
                                        echo "</td>";
189
                                }
190

    
191
                                echo "<td class='tab_bg_1'>".formatUserName($data["ID"],$data["name"],$data["realname"],$data["firstname"],1);
192

    
193
                                if ($data["dynamic"]||$data["recursive"]){
194
                                        echo "<strong>&nbsp;(";
195
                                        if ($data["dynamic"]) echo "D";
196
                                        if ($data["dynamic"]&&$data["recursive"]) echo ", ";
197
                                                if ($data["recursive"]) echo "R";
198
                                        echo ")</strong>";
199
                                }
200
                                echo "</td>\n";
201

    
202
                                $i++;
203
                                         
204
                        }
205
                        
206
                        if ($i%$nb_per_line!=0)
207
                        {
208
                                while ($i%$nb_per_line!=0)
209
                                {
210
                                        if ($canedit){
211
                                                echo "<td width='10'>&nbsp;</td>";
212
                                        }
213

    
214
                                        echo "<td class='tab_bg_1'>&nbsp;---</td>";
215

    
216
                                        $i++;
217
                                }
218
                                
219
                        }
220
                        if ($i!=0) {
221
                                echo "</table>";
222
                                if ($canedit){
223
                                        echo "<div class='center'>";
224
                                        echo "<table width='100%'>";
225
                                        echo "<tr><td><img src=\"".$CFG_GLPI["root_doc"]."/pics/arrow-left.png\" alt=''></td><td class='center'><a onclick= \"if ( markAllRows('profileuser_form$temp') ) return false;\" href='".$_SERVER['PHP_SELF']."?ID=$ID&amp;select=all'>".$LANG["buttons"][18]."</a></td>";
226
                                        
227
                                        echo "<td>/</td><td class='center'><a onclick= \"if ( unMarkAllRows('profileuser_form$temp') ) return false;\" href='".$_SERVER['PHP_SELF']."?ID=$ID&amp;select=none'>".$LANG["buttons"][19]."</a>";
228
                                        echo "</td><td align='left' width='80%'>";
229
                                        dropdownValue("glpi_entities","FK_entities",0,1,$_SESSION['glpiactiveentities']);
230
                                        echo "&nbsp;<input type='submit' name='moveentity' value=\"".$LANG["buttons"][20]."\" class='submit'>";
231
                                        echo "&nbsp;<input type='submit' name='deleteuser' value=\"".$LANG["buttons"][6]."\" class='submit'>";
232
                                        echo "</td>";
233
                                        echo "</table>";
234
                                        echo "</div>";
235
                                }
236
                                echo "</div></form></td></tr>\n";        
237
                        }
238

    
239
                }
240
                 else
241
                         echo "<tr><td class='tab_bg_1' align=center>".$LANG["profiles"][33]."</td></tr>";
242
                 }
243
 
244
         echo "</table>";
245
        echo "</div>";
246

    
247
  }
248

    
249
function showLegend(){
250
        global $LANG;
251
        
252
        echo "<table class='tab_cadre_fixe'>";
253
        echo "<tr class='tab_bg_2'><td width='70' style='text-decoration:underline'><strong>".$LANG["profiles"][34]." : </strong></td><td class='tab_bg_4' width='15' style='border:1px solid black'></td><td><strong>".$LANG["profiles"][0]."</strong></td></tr>";
254
        echo "<tr class='tab_bg_2'><td></td><td class='tab_bg_2' width='15' style='border:1px solid black'></td><td><strong>".$LANG["profiles"][1]."</strong></td></tr>";
255
        echo "</table>";
256
}
257

    
258
?>
Redmine Appliance - Powered by TurnKey Linux