10 lines
1.7 KiB
PHP
10 lines
1.7 KiB
PHP
<?php
|
|
$p=json_decode(file_get_contents(__DIR__.'/FRESH-BACKUP.json'),true,512,JSON_THROW_ON_ERROR);$name=$p['restore_target']['database'];if(!preg_match('/^editorial_before_\d{8}_\d{6}_test$/D',$name))throw new RuntimeException('Restored QA only');
|
|
$db=new PDO('pgsql:host=127.0.0.1;port=55441;dbname='.$name,'postgres','',[PDO::ATTR_ERRMODE=>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');}
|