blob: de9a9a692154ac0fc1ae3965170095f478518d0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
namespace JsonApi\Routes\Forum;
use Config;
use CoreForum;
use UserConfig;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use JsonApi\JsonApiController;
class ConfigIndex extends JsonApiController
{
public function __invoke(Request $request, Response $response, $args)
{
$range = get_object_by_range_id($args['range_id']);
if (!$range) {
throw new RecordNotFoundException();
}
$user = $this->getUser($request);
if (!Authority::canShowForum($user, $range)) {
throw new AuthorizationFailedException();
}
return $this->getMetaResponse([
'is-admin' => CoreForum::isAdmin($range->id),
'is-moderator' => CoreForum::isModerator($range->id),
'is-tutor' => $GLOBALS['perm']->have_studip_perm('tutor', $range->id, $user->id),
'anonymous-post' => (bool) Config::get()->FORUM_ANONYMOUS_POSTINGS,
'tile-layout' => (bool) UserConfig::get($user->user_id)->FORUM_TILE_LAYOUT
]);
}
}
|