ROCKVIEW UNIVERSITY SLPS
CAMPUS DIRECTOR ACCOUNT CREATION — V5

PURPOSE
This patch adds creation of completely new Campus Director login accounts directly from the Staff > Campus Director Access page.

FILES INCLUDED
- slps/shared/api/campus_director_access.php
- slps/shared/views/campus_director_access_workspace.php
- slps/shared/js/campus-director-access.js
- slps/shared/css/campus-director.css
- slps/shared/views/modules/campus-director.php (compatibility route for the existing Campus Director login redirect)

INSTALLATION
1. Back up the live SLPS files and database.
2. Extract this ZIP into the existing application root, preserving the slps/ folder structure.
3. Allow the four files above to overwrite their existing counterparts.
4. Sign in as a Staff user and open Campus Director Access.
5. Refresh the page with Ctrl+F5.

HOW TO CREATE A DIRECTOR
1. Complete Full name, Username, Email address, Initial password and Confirm initial password.
2. Use a password of at least 12 characters.
3. Select Create Director account.
4. The account is created with role campus_director and appears in the Director selector.
5. Select the campus, tick the additional modules required, and select Save access permissions.
6. Give the Director their username/email and initial password through a secure channel. The Director can sign in using either the username or email address, subject to the existing SLPS login rules. The included compatibility route ensures the current login redirect opens the Campus Director dashboard.

SECURITY AND VALIDATION
- Only authenticated Staff accounts can create Campus Director accounts or administer their campus access.
- Passwords are stored using PHP password_hash(PASSWORD_DEFAULT); plaintext passwords are not stored or written to the audit log.
- Username and email are checked for duplicates and are also protected by the database unique constraints.
- Username accepts 3–150 letters, numbers, dots, underscores or hyphens.
- Email address is validated; full name is limited to 150 characters.
- Initial password must be at least 12 characters.
- Requests use the existing SLPS session and CSRF-token mechanism.
- The new account is active immediately. Campus oversight becomes available after Staff grants a campus assignment.

DATABASE REQUIREMENT
The users.role column must permit the value 'campus_director'. This is already required by the existing Campus Director access workflow and login implementation. If account creation returns a database role-constraint error, apply the existing campus-director role migration once before retrying. Do not repeatedly run a migration that has already been applied.

IMPORTANT
This is a targeted patch, not a full SLPS replacement. It does not change the existing login system, other roles, student registration, or quiz APIs. The live database and production login flow were not available for end-to-end testing here. PHP and JavaScript syntax checks were completed on the changed files.


V6 DESIGN CORRECTION
The account registration form now uses a strict responsive two-column grid on desktop and a single-column layout on mobile. High-specificity selectors prevent global SLPS form styles from compressing the fields into one row. Replace the included campus-director.css file and hard-refresh the browser (Ctrl+F5).


V7 WORKFLOW AND DATABASE CORRECTION
1. Apply database/migrations/20261105_allow_campus_director_role.sql once. It updates the original SLPS role CHECK constraint to permit campus_director. If your live database uses a different constraint name or an ENUM column, inspect the users table definition and adapt the migration before running it.
2. The new account form now requires an assigned campus. The account and campus grant are inserted in one database transaction; if either insert fails, neither is committed.
3. Additional module permissions remain editable in the Access Configuration section after account creation.
4. Replace the included workspace, API, JavaScript, and CSS files. Hard-refresh the browser (Ctrl+F5).
5. Test with a non-production account first. This package has not been tested against the live database.
