Path : /home/vishqocm/pcib.in/student/database/
File Upload :
Current File : //home/vishqocm/pcib.in/student/database/student_functions.php

<?php
/**
 * Student Helper Functions
 * Common utility functions for the student panel
 */

/**
 * Check if the current user has student privileges
 * Returns true if the user is logged in and has student role
 * 
 * @return bool
 */
function has_student_privileges() {
    if (!isset($_SESSION['user_id']) || 
        !isset($_SESSION['role']) || 
        $_SESSION['role'] !== 'student') {
        return false;
    }
    return true;
}

/**
 * Verify student access and redirect if unauthorized
 * 
 * @param string $redirect_url URL to redirect to if unauthorized
 * @return void
 */
function require_student_privileges($redirect_url = '../login.php') {
    if (!has_student_privileges()) {
        header("Location: $redirect_url");
        exit;
    }
}

/**
 * Get a user-friendly display name for a role
 * 
 * @param string $role Role identifier
 * @return string User-friendly role name
 */
function get_role_display_name($role) {
    switch ($role) {
        case 'admin':
            return 'Administrator';
        case 'developer':
            return 'Developer';
        case 'director':
            return 'Director';
        case 'instructor':
            return 'Instructor';
        case 'student':
            return 'Student';
        default:
            return ucfirst($role);
    }
}
?>