GhostManSec
Server: LiteSpeed
System: Linux premium117.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: eblama1 (1214)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/eblama1/sms.karnplayinland.com/Menu.php
<?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 ( 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, [], [ 'MODNAME' ] );

$_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 ( ! 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 ) );
	}
}