<?php
require_once '../../core/config.php';
require_once '../../core/session.php';
require_once '../../core/database.php';
require_once '../../core/permissions.php';

require_login();
require_permission('admin.users.edit');

$id = (int)$_GET['id'];
$pdo = db();

$stmt = $pdo->prepare("SELECT email, name, role, status, module_permissions FROM users WHERE id = ?");
$stmt->execute([$id]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);

header('Content-Type: application/json');
echo json_encode($user);