3 lines
1.3 KiB
PHP
3 lines
1.3 KiB
PHP
<?php
|
|
$book='8085';require __DIR__.'/sgf-single-bootstrap.php';$out=['passed'=>true,'new_grants'=>0,'new_writes'=>0,'native_privileges'=>[],'existing_host_rights'=>[]];foreach(['SELECT','INSERT','UPDATE','DELETE']as$right)$out['native_privileges'][$right]=(bool)$native->selectOne('SELECT has_table_privilege(current_user,?,?) allowed',['public.stock_items',$right])->allowed;$out['native_sequence_usage']=(bool)$native->selectOne("SELECT has_sequence_privilege(current_user,pg_get_serial_sequence('public.stock_items','id'),'USAGE') allowed")->allowed;$out['columns']=$native->table('information_schema.columns')->where(['table_schema'=>'public','table_name'=>'stock_items'])->orderBy('ordinal_position')->get(['column_name','data_type','is_nullable'])->all();$out['existing_host_rights']=$host->table('permission_grants')->where(['tenant_id'=>1,'company_id'=>2,'unit_id'=>2])->whereIn('permission',['stock.items.prepare','stock.items.review'])->get(['user_id','permission'])->all();file_put_contents($work.'/stock-catalogue-access-readonly.json',json_encode($out,JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'native_privileges'=>$out['native_privileges'],'native_sequence_usage'=>$out['native_sequence_usage'],'columns'=>$out['columns'],'existing_host_rights'=>$out['existing_host_rights'],'proof'=>$work.'/stock-catalogue-access-readonly.json']).PHP_EOL;
|