Sindbad~EG File Manager

Current Path : /home/copmadinaarea/thecopmadinaarea.org/portal/
Upload File :
Current File : /home/copmadinaarea/thecopmadinaarea.org/portal/test_module_visibility.php

<?php
/**
 * Test Module Visibility by Access Level
 * Shows which modules are visible to each access level
 */

require_once 'config/config.php';
checkLogin();

// Only superusers can run this
if (!isSuperuser()) {
    die('Access denied. Only superusers can run this test.');
}

$db = Database::getInstance()->getConnection();

// Test each access level
$accessLevels = ['assembly', 'district', 'area', 'superuser'];
$results = [];

foreach ($accessLevels as $level) {
    $query = "
        SELECT 
            m.module_name,
            m.category,
            m.is_active,
            mal.is_enabled
        FROM module_management m
        INNER JOIN module_access_levels mal ON m.id = mal.module_id
        WHERE mal.access_level = ?
        AND m.is_active = 1
        AND mal.is_enabled = 1
        ORDER BY m.category, m.display_order
    ";
    
    $stmt = $db->prepare($query);
    $stmt->execute([$level]);
    $results[$level] = $stmt->fetchAll();
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test Module Visibility</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-7xl 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-vial text-blue-500 mr-2"></i>
                Module Visibility Test
            </h1>
            <p class="text-gray-600">Shows which modules are visible to each access level</p>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
            <?php foreach ($accessLevels as $level): ?>
                <div class="bg-white rounded-lg shadow-lg p-6">
                    <h2 class="text-xl font-bold text-gray-800 mb-4 flex items-center">
                        <?php 
                        $icons = [
                            'assembly' => 'church',
                            'district' => 'map-marker-alt',
                            'area' => 'map',
                            'superuser' => 'crown'
                        ];
                        ?>
                        <i class="fas fa-<?php echo $icons[$level]; ?> text-blue-500 mr-2"></i>
                        <?php echo ucfirst($level); ?> Admin
                        <span class="ml-auto text-sm bg-blue-100 text-blue-800 px-3 py-1 rounded-full">
                            <?php echo count($results[$level]); ?> modules
                        </span>
                    </h2>

                    <?php if (empty($results[$level])): ?>
                        <p class="text-gray-500 italic">No modules visible</p>
                    <?php else: ?>
                        <?php 
                        $grouped = [];
                        foreach ($results[$level] as $module) {
                            $cat = $module['category'] ?? 'General';
                            $grouped[$cat][] = $module;
                        }
                        ?>

                        <?php foreach ($grouped as $category => $modules): ?>
                            <div class="mb-4">
                                <h3 class="text-sm font-semibold text-gray-600 uppercase mb-2">
                                    <?php echo htmlspecialchars($category); ?>
                                </h3>
                                <ul class="space-y-1">
                                    <?php foreach ($modules as $module): ?>
                                        <li class="flex items-center text-sm text-gray-700">
                                            <i class="fas fa-check text-green-500 mr-2"></i>
                                            <?php echo htmlspecialchars($module['module_name']); ?>
                                        </li>
                                    <?php endforeach; ?>
                                </ul>
                            </div>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </div>
            <?php endforeach; ?>
        </div>

        <div class="mt-8 bg-yellow-50 border-l-4 border-yellow-500 p-6 rounded-lg">
            <h3 class="text-lg font-bold text-yellow-800 mb-3">
                <i class="fas fa-info-circle mr-2"></i>How to Test
            </h3>
            <ol class="space-y-2 text-yellow-700">
                <li><strong>1.</strong> Go to Module Management</li>
                <li><strong>2.</strong> Disable a module for a specific access level (e.g., disable "Events" for Assembly)</li>
                <li><strong>3.</strong> Refresh this page to see the change</li>
                <li><strong>4.</strong> Log in as that user type to verify they can't see the module</li>
                <li><strong>5.</strong> The module should disappear from their sidebar</li>
            </ol>
        </div>

        <div class="mt-6 flex gap-4">
            <a href="modules/module-management/index.php" 
               class="px-6 py-3 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-lg hover:from-blue-600 hover:to-purple-700 transition shadow-lg">
                <i class="fas fa-sliders-h mr-2"></i>
                Module Management
            </a>
            <a href="dashboard.php" 
               class="px-6 py-3 bg-gray-500 text-white rounded-lg hover:bg-gray-600 transition shadow-lg">
                <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