'u','plugin'=>'d')); //User must have user update right and delete plugin right to perform this action * ```. * * @param function action/code to execute * @param array Array wich contain right to execute action * * @return print json response */ public static function write($f, $p = array()) { global $myUser; header('content-type:application/json'); $response = array(); set_error_handler(function ($level, $error, $file, $line) { throw new Exception($error." \r\n\r\n ".$file.' - L '.$line.'');}); try { foreach ($p as $section => $right) { if (!$myUser->can($section, $right)) throw new Exception('Vous ne disposez pas des droits suffisants pour effectuer cette action'); } $f($response); } catch (Exception $e) { $response['error'] = $e->getMessage(); $response['errorCode'] = $e->getCode(); if($myUser->superadmin) $response['trace'] = $e->getTraceAsString(); } echo json_encode($response); restore_error_handler(); } }