PDO::ERRMODE_EXCEPTION]);$db->exec('BEGIN READ ONLY'); try{ $sql="SELECT u.id,u.name,a.role,a.opportunity_types,a.source FROM portal_role_assignments a JOIN users u ON u.id=a.user_id WHERE a.revoked_at IS NULL AND a.starts_at<=now() AND (a.expires_at IS NULL OR a.expires_at>now()) ORDER BY u.id,a.role"; $grants=$db->query($sql)->fetchAll(PDO::FETCH_ASSOC); $proof=['source'=>'fresh restored destination; read only','target'=>$p['restore_target'],'operational_assignments'=>$grants,'permission_changes'=>0,'paths'=>['promoter_list'=>'/minhas-oportunidades','promoter_create'=>'/minhas-oportunidades/create','review_queue'=>'/minhas-oportunidades?queue=review','publication_queue'=>'/minhas-oportunidades?queue=publication','documents_and_articles'=>'/management/portal-services','sectors'=>'/management/sectors','editorial_installation'=>'/management/editorial-installation'],'limits'=>'Administrative management permission does not grant an operational opportunity scope; existing grants and independent workflow decisions preserved. No new roles assigned.']; file_put_contents(__DIR__.'/ACESSOS-FUNCIONARIOS.json',json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));echo json_encode(['active_role_assignments'=>count($grants),'users'=>array_values(array_unique(array_column($grants,'id'))),'roles'=>array_values(array_unique(array_column($grants,'role')))]).PHP_EOL; }finally{$db->exec('ROLLBACK');}