Sindbad~EG File Manager
<?php
/**
* Debug Module Access - Shows raw database state
*/
require_once 'config/config.php';
checkLogin();
if (!isSuperuser()) {
die('Access denied');
}
$db = Database::getInstance()->getConnection();
// Get Events module info
$eventsModule = $db->query("
SELECT * FROM module_management
WHERE module_name = 'Events'
")->fetch();
// Get all access levels for Events
$eventsAccess = $db->prepare("
SELECT * FROM module_access_levels
WHERE module_id = ?
ORDER BY access_level
");
$eventsAccess->execute([$eventsModule['id']]);
$accessLevels = $eventsAccess->fetchAll();
// Get what Assembly users would see
$assemblyModules = $db->query("
SELECT
m.module_name,
m.is_active,
mal.is_enabled,
mal.access_level
FROM module_management m
INNER JOIN module_access_levels mal ON m.id = mal.module_id
WHERE mal.access_level = 'assembly'
AND m.is_active = 1
AND mal.is_enabled = 1
ORDER BY m.module_name
")->fetchAll();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Debug Module Access</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-gray-100 p-8">
<div class="max-w-6xl mx-auto">
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
<h1 class="text-3xl font-bold text-gray-800 mb-2">
<i class="fas fa-bug text-red-500 mr-2"></i>
Debug Module Access - Events Module
</h1>
<p class="text-gray-600">Raw database state</p>
</div>
<!-- Events Module Info -->
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
<h2 class="text-xl font-bold text-gray-800 mb-4">Events Module Info</h2>
<table class="w-full">
<tr class="border-b">
<td class="py-2 font-semibold">ID:</td>
<td class="py-2"><?php echo $eventsModule['id']; ?></td>
</tr>
<tr class="border-b">
<td class="py-2 font-semibold">Name:</td>
<td class="py-2"><?php echo $eventsModule['module_name']; ?></td>
</tr>
<tr class="border-b">
<td class="py-2 font-semibold">Active:</td>
<td class="py-2">
<span class="px-2 py-1 rounded <?php echo $eventsModule['is_active'] ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'; ?>">
<?php echo $eventsModule['is_active'] ? 'Yes' : 'No'; ?>
</span>
</td>
</tr>
<tr class="border-b">
<td class="py-2 font-semibold">System Critical:</td>
<td class="py-2">
<span class="px-2 py-1 rounded <?php echo $eventsModule['is_system_critical'] ? 'bg-red-100 text-red-800' : 'bg-gray-100 text-gray-800'; ?>">
<?php echo $eventsModule['is_system_critical'] ? 'Yes' : 'No'; ?>
</span>
</td>
</tr>
</table>
</div>
<!-- Access Levels for Events -->
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
<h2 class="text-xl font-bold text-gray-800 mb-4">Access Levels for Events Module</h2>
<table class="w-full">
<thead>
<tr class="bg-gray-100">
<th class="py-2 px-4 text-left">Access Level</th>
<th class="py-2 px-4 text-left">Is Enabled</th>
<th class="py-2 px-4 text-left">Updated At</th>
</tr>
</thead>
<tbody>
<?php foreach ($accessLevels as $access): ?>
<tr class="border-b <?php echo $access['access_level'] === 'assembly' ? 'bg-yellow-50' : ''; ?>">
<td class="py-2 px-4 font-semibold">
<?php echo ucfirst($access['access_level']); ?>
<?php if ($access['access_level'] === 'assembly'): ?>
<span class="ml-2 text-xs bg-yellow-200 px-2 py-1 rounded">← Testing This</span>
<?php endif; ?>
</td>
<td class="py-2 px-4">
<span class="px-3 py-1 rounded font-semibold <?php echo $access['is_enabled'] ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'; ?>">
<?php echo $access['is_enabled'] ? '✓ ENABLED' : '✗ DISABLED'; ?>
</span>
</td>
<td class="py-2 px-4 text-sm text-gray-600">
<?php echo $access['updated_at']; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- What Assembly Users See -->
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
<h2 class="text-xl font-bold text-gray-800 mb-4">
Modules Visible to Assembly Admins
<span class="ml-2 text-sm bg-blue-100 text-blue-800 px-3 py-1 rounded-full">
<?php echo count($assemblyModules); ?> modules
</span>
</h2>
<?php if (empty($assemblyModules)): ?>
<p class="text-red-600 font-semibold">⚠️ No modules visible to Assembly admins!</p>
<?php else: ?>
<div class="grid grid-cols-2 gap-2">
<?php foreach ($assemblyModules as $mod): ?>
<div class="flex items-center p-2 bg-gray-50 rounded">
<i class="fas fa-check text-green-500 mr-2"></i>
<?php echo htmlspecialchars($mod['module_name']); ?>
</div>
<?php endforeach; ?>
</div>
<div class="mt-4 p-4 bg-blue-50 rounded">
<p class="text-sm text-blue-800">
<strong>Check:</strong> Is "Events" in the list above?
</p>
<ul class="mt-2 text-sm text-blue-700">
<li>✓ If YES and is_enabled is TRUE in the table above → Events should appear for Assembly</li>
<li>✗ If NO and is_enabled is FALSE in the table above → Events should NOT appear (correct!)</li>
<li>⚠️ If mismatch → There's a caching or query issue</li>
</ul>
</div>
<?php endif; ?>
</div>
<!-- Actions -->
<div class="flex gap-4">
<button onclick="location.reload()" class="px-6 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600">
<i class="fas fa-sync mr-2"></i>Refresh
</button>
<a href="modules/module-management/index.php" class="px-6 py-3 bg-purple-500 text-white rounded-lg hover:bg-purple-600">
<i class="fas fa-sliders-h mr-2"></i>Module Management
</a>
<a href="test_module_visibility.php" class="px-6 py-3 bg-green-500 text-white rounded-lg hover:bg-green-600">
<i class="fas fa-vial mr-2"></i>Visibility Test
</a>
<a href="dashboard.php" class="px-6 py-3 bg-gray-500 text-white rounded-lg hover:bg-gray-600">
<i class="fas fa-home mr-2"></i>Dashboard
</a>
</div>
</div>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists