Path : /home/vishqocm/pcib.in/admin/
File Upload :
Current File : /home/vishqocm/pcib.in/admin/README_DIRECTOR_ROLE.md

# Director Role Configuration

## Overview
This document outlines the changes made to grant the `director` role the same permissions as the `admin` role throughout the system.

## Changes Made

1. **Login Redirection**
   - Modified `login.php` to redirect directors to the admin panel
   - Updated `google_auth.php` to redirect directors to the admin panel

2. **Admin Functions**
   - Added new helper functions in `admin/includes/functions.php`:
     - `user_has_admin_privileges()`: Checks if user has admin or director role
     - `require_admin_privileges()`: Redirects if user doesn't have admin privileges

3. **Mass Update Script**
   - Created `admin/update_director_privileges.php` to update role checks in PHP files
   - This script uses regular expressions to find and replace role checks throughout the admin directory
   - The script provides a report of all files that were modified

## Affected Files
The following key files were modified:
- `login.php` - Updated redirect logic
- `google_auth.php` - Updated redirect logic
- `admin/login.php` - Updated initial access check
- `admin/includes/functions.php` - Added new helper functions
- Multiple admin PHP files - Updated role checks

## How to Verify Changes
To verify the changes have been applied correctly:
1. Log in with a director account (create one if needed)
2. Confirm you can access the admin dashboard
3. Test various admin features to ensure they work correctly
4. If you encounter any access issues, run the `update_director_privileges.php` script again

## Technical Details
The permission system now recognizes both `admin` and `director` roles for administrative access by:
1. Using logic like `$_SESSION['role'] == 'admin' || $_SESSION['role'] == 'director'` for equality checks
2. Using logic like `$_SESSION['role'] !== 'admin' && $_SESSION['role'] !== 'director'` for inequality checks
3. Centralizing access control through helper functions where possible

## Contact
If you encounter any issues with these changes, please contact the system administrator.