has('permissions', ["AND" => ['apikey' => $apikey, 'roleid' => $roleid]]) === true; } public static function add($apikey, $roleid) { global $database; if (!$database->has('apikeys', ['apikey' => $apikey])) { throw new Exception("No such API key found."); } if (!$database->has('roles', ['roleid' => $roleid])) { throw new Exception("No such role ID found."); } if (!$database->has('permissions', ["AND" => ['apikey' => $apikey, 'roleid' => $roleid]])) { $database->insert('permissions', ['apikey' => $apikey, 'roleid' => $roleid]); } } public static function remove($apikey, $roleid) { global $database; if (!$database->has('apikeys', ['apikey' => $apikey])) { throw new Exception("No such API key found."); } if (!$database->has('roles', ['roleid' => $roleid])) { throw new Exception("No such role ID found."); } $database->delete('permissions', ["AND" => ['apikey' => $apikey, 'roleid' => $roleid]]); } }