5 lines
1.6 KiB
PHP
5 lines
1.6 KiB
PHP
<?php
|
|
$book=$argv[1]??'regression';require __DIR__.'/sgf-single-bootstrap.php';$p=json_decode(file_get_contents($repo.'/docs/integration/sgf-document-read-access-proposal.json'),true);if(($p['approved']??false)!==true||$p['scope']!==$f['scope'])throw new LogicException('Exact approval required');$profiles=json_decode(file_get_contents($s['root'].'/single-profiles.json'),true)['profiles'];$count=0;
|
|
$host->transaction(function()use($host,$p,$profiles,&$count){foreach($p['existing_host_rights'] as $grant)foreach($grant['profiles'] as $profile){$id=$profiles[$profile]['user_id'];if(!in_array($profile,['finance_prepare','finance_review'],true)||$id!==$p['profiles'][$profile])throw new LogicException('Only approved existing identities');if(!$host->table('company_memberships')->where(['tenant_id'=>1,'company_id'=>2,'user_id'=>$id])->exists())throw new LogicException('Membership changed');$v=['tenant_id'=>1,'company_id'=>2,'unit_id'=>$grant['scope']==='unit'?2:null,'user_id'=>$id,'permission'=>$grant['permission']];if($host->table('permission_grants')->where($v)->exists())continue;$host->table('permission_grants')->insert($v);App\Modules\Identity\Services\Audit::record('access.granted_on_creation',null,1,2,$v['unit_id'],$id,['permission'=>$grant['permission'],'reason'=>$p['authorization']]);$count++;}});
|
|
file_put_contents($work.'/document-read-access.json',json_encode(['passed'=>true,'book'=>$book,'new_grants'=>$count,'approved_concessions'=>10,'new_permission_names'=>0,'new_profiles'=>0,'public_grants'=>0],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'book'=>$book,'new_grants'=>$count,'proof'=>$work.'/document-read-access.json']).PHP_EOL;
|