<?php
$database = new Database();
$db = $database->getConnection();

$userrole = new UserRole($db);
$userrole->rolename = isset($_SESSION['userrole']) ? $_SESSION['userrole'] : "";

$userrole_permission = [];

if ($userrole->rolename == "SuperAdmin") {
    $exclude_columns = ['table_name', 'conn', 'rolename']; 

    $stmt = $db->prepare("DESCRIBE userrole");
    $stmt->execute();
    $columns = $stmt->fetchAll(PDO::FETCH_COLUMN);

    foreach ($columns as $column) {
        if (!in_array($column, $exclude_columns)) {
            $userrole_permission[$column] = 1;
        }
    }

} else {
    $userrole->getPermission();
    $exclude_columns = ['table_name', 'conn'];
    foreach ($userrole as $key => $value) {
        if (!in_array($key, $exclude_columns)) {
            $userrole_permission[$key] = $value;
        }
    }
}
?>
