1 |
<?php
|
2 |
//$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/phplib/menu.inc,v 1.10 2006/08/06 03:51:54 dashley Exp $
|
3 |
//--------------------------------------------------------------------------------------------------------------
|
4 |
//menu.inc--FboPrime Menu Generation Functions
|
5 |
//Copyright (C) 2006 David T. Ashley
|
6 |
//
|
7 |
//This program is free software; you can redistribute it and/or
|
8 |
//modify it under the terms of the GNU General Public License
|
9 |
//as published by the Free Software Foundation; either version 2
|
10 |
//of the License, or (at your option) any later version.
|
11 |
//
|
12 |
//This program is distributed in the hope that it will be useful,
|
13 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
//GNU General Public License for more details.
|
16 |
//
|
17 |
//You should have received a copy of the GNU General Public License
|
18 |
//along with this program; if not, write to the Free Software
|
19 |
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
//********************************************************************************
|
21 |
//This contains functions used to log events, both to the loge table of the
|
22 |
//database, and to the system log.
|
23 |
//--------------------------------------------------------------------------------------------------------------
|
24 |
require_once("global.inc");
|
25 |
require_once("strfunc.inc");
|
26 |
require_once("utime.inc");
|
27 |
//
|
28 |
//--------------------------------------------------------------------------------------------------------------
|
29 |
//Generates a menu list as a function of:
|
30 |
//
|
31 |
//INPUTS
|
32 |
// a)The full set of user information (the database record as
|
33 |
// an associative array), or FALSE if no user is logged in.
|
34 |
// b)The desired menu level. The menu level
|
35 |
// is an integer, with 0 representing the fewest options, 1 representing
|
36 |
// a medium number of options, and 2 represents the largest number
|
37 |
// of options.
|
38 |
// c)The target date as a DT8 (for example "20060516"), or FALSE if
|
39 |
// not required.
|
40 |
// d)The target time as a T4 (for example, "0500"), or FALSE if not
|
41 |
// required.
|
42 |
// e)The name of the script (final element of path).
|
43 |
//
|
44 |
//OUTPUT
|
45 |
// An array arranged as 3-tuples (starting at [0]),
|
46 |
// [N] : "H" if the 3-tuple is a category heading, or
|
47 |
// "E" if it is an entry.
|
48 |
// [N+1] : Text of the category heading or entry.
|
49 |
// [N+2] : Hyperlink corresponding to the entry (or the
|
50 |
// empty string for headings).
|
51 |
//
|
52 |
function MENU_menu_gen($userinfo, $menulevel, $dt8in, $t4in, $scriptname_in)
|
53 |
{
|
54 |
//Form a string containing the date and time arranged as GET parameters. This will be tacked
|
55 |
//on to certain URLs.
|
56 |
if (($dt8in === FALSE) && ($t4in === FALSE))
|
57 |
{
|
58 |
//No parameters to be appended.
|
59 |
$get_par_append = FALSE;
|
60 |
}
|
61 |
else if (($dt8in === FALSE) && ($t4in !== FALSE))
|
62 |
{
|
63 |
//Time has been specified, but date not.
|
64 |
$get_par_append = "sdtim=" . $t4in;
|
65 |
}
|
66 |
else if (($dt8in !== FALSE) && ($t4in === FALSE))
|
67 |
{
|
68 |
//Date has been specified, but time not.
|
69 |
$get_par_append = "sddt=" . $dt8in;
|
70 |
}
|
71 |
else //Both have been specified.
|
72 |
{
|
73 |
$get_par_append = "sddt=" . $dt8in . "&sdtim=" . $t4in;
|
74 |
}
|
75 |
|
76 |
$i = 0;
|
77 |
|
78 |
//The heading "Scheduling Views" is always appropriate.
|
79 |
$rv[$i ] = "H";
|
80 |
$rv[$i+1] = "Scheduling Views";
|
81 |
$rv[$i+2] = "";
|
82 |
$i += 3;
|
83 |
//
|
84 |
//Scheduling day view is always appropriate.
|
85 |
$rv[$i ] = "E";
|
86 |
$rv[$i+1] = "Day View";
|
87 |
if ($get_par_append === FALSE)
|
88 |
$rv[$i+2] = "index.php";
|
89 |
else
|
90 |
$rv[$i+2] = "index.php?" . $get_par_append;
|
91 |
$i += 3;
|
92 |
//
|
93 |
//Scheduling week view is only appropriate at menu level 1 and above.
|
94 |
if ($menulevel >= 1)
|
95 |
{
|
96 |
$rv[$i ] = "E";
|
97 |
$rv[$i+1] = "Week View";
|
98 |
if ($get_par_append === FALSE)
|
99 |
$rv[$i+2] = "schedweekview.php";
|
100 |
else
|
101 |
$rv[$i+2] = "schedweekview.php?" . $get_par_append;
|
102 |
$i += 3;
|
103 |
}
|
104 |
//
|
105 |
//Scheduling month view is only appropriate at menu level 2 and above.
|
106 |
if ($menulevel >= 2)
|
107 |
{
|
108 |
$rv[$i ] = "E";
|
109 |
$rv[$i+1] = "Month View";
|
110 |
if ($get_par_append === FALSE)
|
111 |
$rv[$i+2] = "schedmonthview.php";
|
112 |
else
|
113 |
$rv[$i+2] = "schedmonthview.php?" . $get_par_append;
|
114 |
$i += 3;
|
115 |
}
|
116 |
//
|
117 |
//The heading "Queries" is only appropriate when a user is logged in.
|
118 |
if ($userinfo !== FALSE)
|
119 |
{
|
120 |
$rv[$i ] = "H";
|
121 |
$rv[$i+1] = "Queries";
|
122 |
$rv[$i+2] = "";
|
123 |
$i += 3;
|
124 |
//
|
125 |
//Showing "My Reservations" is only appropriate when a user is logged in.
|
126 |
$rv[$i ] = "E";
|
127 |
$rv[$i+1] = "Show My Reservations";
|
128 |
if ($get_par_append === FALSE)
|
129 |
$rv[$i+2] = "myresshow.php";
|
130 |
else
|
131 |
$rv[$i+2] = "myresshow.php?" . $get_par_append;
|
132 |
$i += 3;
|
133 |
}
|
134 |
//
|
135 |
//Utilities should be shown if the user is cleared to view the users list, clear to
|
136 |
//edit resources, to view the log entries, or to view the database statistics and
|
137 |
//if the menu level is 2.
|
138 |
//
|
139 |
if (
|
140 |
($userinfo !== FALSE)
|
141 |
&&
|
142 |
(
|
143 |
(PERM_get_val_from_string($userinfo["perm"], "canviewuserslist" ) !== FALSE)
|
144 |
||
|
145 |
(PERM_get_val_from_string($userinfo["perm"], "canvieweditresources" ) !== FALSE)
|
146 |
||
|
147 |
(PERM_get_val_from_string($userinfo["perm"], "canviewlogentries" ) !== FALSE)
|
148 |
||
|
149 |
(PERM_get_val_from_string($userinfo["perm"], "canviewdbstats" ) !== FALSE)
|
150 |
)
|
151 |
&&
|
152 |
($menulevel >= 2)
|
153 |
)
|
154 |
{
|
155 |
$rv[$i ] = "H";
|
156 |
$rv[$i+1] = "Utilities";
|
157 |
$rv[$i+2] = "";
|
158 |
$i += 3;
|
159 |
|
160 |
//Display the view/edit active users option if the permission string says it is OK.
|
161 |
if (PERM_get_val_from_string($userinfo["perm"], "canviewuserslist") !== FALSE)
|
162 |
{
|
163 |
$rv[$i ] = "E";
|
164 |
$rv[$i+1] = "View/Edit Active Users";
|
165 |
$rv[$i+2] = "userlistactive.php";
|
166 |
$i += 3;
|
167 |
}
|
168 |
|
169 |
//Display the view/edit inactive users option if the permission string says it is OK.
|
170 |
if (PERM_get_val_from_string($userinfo["perm"], "canviewuserslist") !== FALSE)
|
171 |
{
|
172 |
$rv[$i ] = "E";
|
173 |
$rv[$i+1] = "View/Edit Inactive Users";
|
174 |
$rv[$i+2] = "userlistinactive.php";
|
175 |
$i += 3;
|
176 |
}
|
177 |
|
178 |
//Display the view/edit resources option if the permission string says it is OK.
|
179 |
if (PERM_get_val_from_string($userinfo["perm"], "canvieweditresources") !== FALSE)
|
180 |
{
|
181 |
$rv[$i ] = "E";
|
182 |
$rv[$i+1] = "View/Edit Resources";
|
183 |
$rv[$i+2] = "resourcelist.php";
|
184 |
$i += 3;
|
185 |
}
|
186 |
|
187 |
//Display the logview option if the permission string says it is OK.
|
188 |
if (PERM_get_val_from_string($userinfo["perm"], "canviewlogentries") !== FALSE)
|
189 |
{
|
190 |
$rv[$i ] = "E";
|
191 |
$rv[$i+1] = "View Resource Scheduler Log";
|
192 |
if ($get_par_append === FALSE)
|
193 |
$rv[$i+2] = "viewresschedlog.php";
|
194 |
else
|
195 |
$rv[$i+2] = "viewresschedlog.php?" . $get_par_append;
|
196 |
$i += 3;
|
197 |
}
|
198 |
|
199 |
//Display the database view option if the permission string says it is OK.
|
200 |
if (PERM_get_val_from_string($userinfo["perm"], "canviewdbstats") !== FALSE)
|
201 |
{
|
202 |
$rv[$i ] = "E";
|
203 |
$rv[$i+1] = "View Database Statistics";
|
204 |
if ($get_par_append === FALSE)
|
205 |
$rv[$i+2] = "viewdbstats.php";
|
206 |
else
|
207 |
$rv[$i+2] = "viewdbstats.php?" . $get_par_append;
|
208 |
$i += 3;
|
209 |
}
|
210 |
}
|
211 |
//
|
212 |
//The self-administration heading applies only when a user is logged in and the
|
213 |
//menu level is 2 or greater.
|
214 |
//
|
215 |
if (($userinfo !== FALSE) && ($menulevel >= 2))
|
216 |
{
|
217 |
$rv[$i ] = "H";
|
218 |
$rv[$i+1] = "Self-Administration";
|
219 |
$rv[$i+2] = "";
|
220 |
$i += 3;
|
221 |
}
|
222 |
//
|
223 |
//The password change applies only when a user is logged in and when the
|
224 |
//menu level >= 1.
|
225 |
//
|
226 |
if (($userinfo !== FALSE) && ($menulevel >= 2))
|
227 |
{
|
228 |
$rv[$i ] = "E";
|
229 |
$rv[$i+1] = "Change Password";
|
230 |
if ($get_par_append === FALSE)
|
231 |
$rv[$i+2] = "userpwchange.php";
|
232 |
else
|
233 |
$rv[$i+2] = "userpwchange.php?" . $get_par_append;
|
234 |
$i += 3;
|
235 |
}
|
236 |
//
|
237 |
//The change personal information only applies when a user is
|
238 |
//logged in and the menu level >= 1.
|
239 |
//
|
240 |
if (($userinfo !== FALSE) && ($menulevel >= 2))
|
241 |
{
|
242 |
$rv[$i ] = "E";
|
243 |
$rv[$i+1] = "Change Personal Information";
|
244 |
if ($get_par_append === FALSE)
|
245 |
$rv[$i+2] = "userpersinfochange.php";
|
246 |
else
|
247 |
$rv[$i+2] = "userpersinfochange.php?" . $get_par_append;
|
248 |
$i += 3;
|
249 |
}
|
250 |
//
|
251 |
//Menus heading is only appropriate when a user is logged in and at the day view
|
252 |
//scheduler.
|
253 |
if (($userinfo !== FALSE) && ($scriptname_in == "index.php"))
|
254 |
{
|
255 |
$rv[$i ] = "H";
|
256 |
$rv[$i+1] = "Menus";
|
257 |
$rv[$i+2] = "";
|
258 |
$i += 3;
|
259 |
//
|
260 |
//Showing "More Options" is appropriate only when options level is 1 or less.
|
261 |
if ($menulevel <= 1)
|
262 |
{
|
263 |
$rv[$i ] = "E";
|
264 |
$rv[$i+1] = "Show More Options";
|
265 |
if ($get_par_append === FALSE)
|
266 |
$rv[$i+2] = "index.php?menulvladjst=u";
|
267 |
else
|
268 |
$rv[$i+2] = "index.php?" . "menulvladjst=u&" . $get_par_append;
|
269 |
$i += 3;
|
270 |
}
|
271 |
//Showing "Fewer Options" is appropriate only when options level is 1 or more.
|
272 |
if ($menulevel >= 1)
|
273 |
{
|
274 |
$rv[$i ] = "E";
|
275 |
$rv[$i+1] = "Show Fewer Options";
|
276 |
if ($get_par_append === FALSE)
|
277 |
$rv[$i+2] = "index.php?menulvladjst=d";
|
278 |
else
|
279 |
$rv[$i+2] = "index.php?" . "menulvladjst=d&" . $get_par_append;
|
280 |
$i += 3;
|
281 |
}
|
282 |
}
|
283 |
//
|
284 |
//Session administration heading and subheadings are only appropriate when a user is logged in, and
|
285 |
//should only be performed from the dayview page.
|
286 |
if ($userinfo !== FALSE)
|
287 |
{
|
288 |
$rv[$i ] = "H";
|
289 |
$rv[$i+1] = "Session Administration";
|
290 |
$rv[$i+2] = "";
|
291 |
$i += 3;
|
292 |
//
|
293 |
//Showing "Logout" is appropriate only when user logged in.
|
294 |
$rv[$i ] = "E";
|
295 |
$rv[$i+1] = "Logout";
|
296 |
if ($get_par_append === FALSE)
|
297 |
$rv[$i+2] = "index.php?logout=1";
|
298 |
else
|
299 |
$rv[$i+2] = "index.php?" . "logout=1&" . $get_par_append;
|
300 |
$i += 3;
|
301 |
}
|
302 |
//
|
303 |
return($rv);
|
304 |
}
|
305 |
//
|
306 |
//--------------------------------------------------------------------------------------------------------------
|
307 |
//End of $RCSfile: menu.inc,v $.
|
308 |
//--------------------------------------------------------------------------------------------------------------
|
309 |
?>
|