forked from francoisjacquet/rosariosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.php
111 lines (97 loc) · 2.73 KB
/
Menu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* Generate Menu entries
*
* Depending on:
* Activated modules
* User profile & exceptions
*
* Save it in $_ROSARIO['Menu'] global var
*
* @package RosarioSIS
*/
if ( empty( $_ROSARIO['Menu'] ) )
{
if ( ! isset( $RosarioModules ) )
{
global $RosarioModules;
}
// Include Menu.php for each active module.
foreach ( (array) $RosarioModules as $module => $active )
{
if ( $active )
{
if ( ROSARIO_DEBUG )
{
include 'modules/' . $module . '/Menu.php';
}
else
@include 'modules/' . $module . '/Menu.php';
}
}
$profile = User( 'PROFILE' );
if ( User( 'PROFILE_ID' ) != '' )
{
$allow_use_sql = "SELECT MODNAME
FROM PROFILE_EXCEPTIONS
WHERE PROFILE_ID='" . User( 'PROFILE_ID' ) . "'
AND CAN_USE='Y'";
}
// If user has custom exceptions.
else
{
$allow_use_sql = "SELECT MODNAME
FROM STAFF_EXCEPTIONS
WHERE USER_ID='" . User( 'STAFF_ID' ) . "'
AND CAN_USE='Y'";
}
if ( $profile == 'student' )
{
// Force student profile to parent (same rights in Menu.php files).
$profile = 'parent';
}
$_ROSARIO['AllowUse'] = DBGet( $allow_use_sql, array(), array( 'MODNAME' ) );
// Loop menu entries for each module & profile.
// Save menu entries in $_ROSARIO['Menu'] global var.
foreach ( (array) $menu as $modcat => $profiles )
{
// FJ bugfix remove modules with no programs.
$no_programs_in_module = true;
$programs = issetVal( $profiles[ $profile ], array() );
foreach ( (array) $programs as $program => $title )
{
if ( $program === 'title' // Module title.
|| $program === 'default' // Default program when opening module.
|| is_numeric( $program ) ) // If program is numeric, it is a section.
{
$_ROSARIO['Menu'][ $modcat ][ $program ] = $title;
continue;
}
// if ($_ROSARIO['AllowUse'][ $program ] && ($profile!='admin' || ! $exceptions[ $modcat ][ $program ] || AllowEdit($program)))
// If program allowed, add it.
if ( ! empty( $_ROSARIO['AllowUse'][ $program ] )
&& ( $profile !== 'admin'
|| empty( $exceptions[ $modcat ][ $program ] )
|| AllowEdit( $program ) ) )
{
$_ROSARIO['Menu'][ $modcat ][ $program ] = $title;
// Default to first allowed program if default not allowed.
if ( ! isset( $_ROSARIO['Menu'][ $modcat ]['default'] )
|| empty( $_ROSARIO['AllowUse'][ $_ROSARIO['Menu'][ $modcat ]['default'] ] ) )
{
$_ROSARIO['Menu'][ $modcat ]['default'] = $program;
}
$no_programs_in_module = false;
}
}
if ( $no_programs_in_module )
{
unset( $_ROSARIO['Menu'][ $modcat ] );
}
// Compat with Modules < 2.9: no title entry for Menu.
elseif ( ! isset( $_ROSARIO['Menu'][ $modcat ]['title'] ) )
{
$_ROSARIO['Menu'][ $modcat ]['title'] = _( str_replace( '_', ' ', $modcat ) );
}
}
}