-
Notifications
You must be signed in to change notification settings - Fork 346
/
Menu.php
96 lines (82 loc) · 2.15 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
<?php
/**
* Generate Menu entries
*
* Depending on:
* Activated modules
* User profile & exceptions
*
* Save it in $_ROSARIO['Menu'] global var
*
* @package RosarioSIS
*/
if ( ! empty( $_ROSARIO['Menu'] ) )
{
return;
}
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 ( $profile == 'student' )
{
// Force student profile to parent (same rights in Menu.php files).
$profile = 'parent';
}
$_ROSARIO['Menu'] = [];
// 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 ], [] );
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 program allowed, add it.
if ( AllowUse( $program, true ) // Cache all.
&& ( $profile !== 'admin'
|| empty( $exceptions[ $modcat ][ $program ] )
|| AllowEdit( $program, true ) ) ) // Cache all.
{
$_ROSARIO['Menu'][ $modcat ][ $program ] = $title;
// Default to first allowed program if default not allowed.
if ( ! isset( $_ROSARIO['Menu'][ $modcat ]['default'] )
|| ! 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 ) );
}
}