jsonError($app, $e);
        }
    });
    $app->put('/id/:id/status/:status', validatePrivileges(array('user', 'administrator')), function ($id, $status) use($app, $comment) {
        try {
            $c = $comment->getByID($id);
            if ($GLOBALS['privileges'] == 'user' && $status != 0) {
                throw new Exception('Jako użytkownik możesz jedynie zgłaszać nadużycia.', 403);
            }
            if ($GLOBALS['privileges'] == 'user' && $c['status_id'] > 1) {
                throw new Exception('Możesz zgłaszać nadużycia jedynie dla niezatwierdzonych komentarzy.', 403);
            }
            $result = $comment->setStatus($id, $status);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
    $app->delete('/id/:id', validatePrivileges(array('user', 'administrator')), function ($id) use($app, $comment) {
        try {
            $c = $comment->getByID($id);
            if ($GLOBALS['privileges'] == 'user' && $GLOBALS['user_id'] != $c['user_id']) {
                throw new Exception('Nie jesteś autorem komentarza.', 403);
            }
            $result = $comment->delete($id);
            jsonSuccess($app, $result);
        } catch (Exception $e) {
            jsonError($app, $e);
        }
    });
});