<?php
declare(strict_types=1);
require_once __DIR__.'/../shared/lib/student_projects.php';
require_once __DIR__.'/../shared/lib/guidelines.php';
require_once __DIR__.'/../shared/lib/suggestions.php';
function ensure($ok){if(!$ok)throw new RuntimeException('Staff permission assertion failed');}
$user=['id'=>99,'role'=>'staff'];ensure(project_filter($user)===['1=1',[]]);ensure(guideline_scope($user)===['department_id'=>null,'can_edit'=>true]);ensure(suggestion_can_remove($user,123));ensure(!suggestion_can_remove(['id'=>99,'role'=>'student'],123));ensure(project_filter(['id'=>123,'role'=>'student'])===['p.student_user_id=?',[123]]);
foreach(['notices.php'=>'publisher','student_projects.php'=>'can_grade','papers.php'=>'can_solution'] as $file=>$cap){$source=file_get_contents(__DIR__.'/../shared/api/'.$file);ensure(str_contains($source,"['admin','staff','hod']"));}
$source=file_get_contents(__DIR__.'/../shared/api/module.php');preg_match('/\$specs=(\[.*?\]);/s',$source,$m);$specs=eval('return '.$m[1].';');ensure(in_array('staff',$specs['system-settings-backup'][2],true));
echo "PASS: global staff project visibility, guideline editing, suggestion moderation, management capabilities, student isolation and settings access.\n";
