<?php
// Helper functions for user management

function getUserVerificationStatus($user_id) {
    global $conn;
    
    if (!$conn) {
        require_once 'db.php';
    }
    
    $result = mysqli_query($conn, 
        "SELECT id_verified, verification_status 
         FROM users 
         WHERE id = $user_id"
    );
    
    if ($result && mysqli_num_rows($result) > 0) {
        $user_data = mysqli_fetch_assoc($result);
        return $user_data['id_verified'] ?? false;
    }
    
    return false;
}

function isUserVerified($user_id) {
    return getUserVerificationStatus($user_id);
}

function getUserProfileData($user_id) {
    global $conn;
    
    if (!$conn) {
        require_once 'db.php';
    }
    
    $result = mysqli_query($conn, 
        "SELECT id_verified, verification_status, name, email, phone 
         FROM users 
         WHERE id = $user_id"
    );
    
    if ($result && mysqli_num_rows($result) > 0) {
        return mysqli_fetch_assoc($result);
    }
    
    return null;
}
?>