-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModeratePermission.php
More file actions
40 lines (34 loc) · 971 Bytes
/
ModeratePermission.php
File metadata and controls
40 lines (34 loc) · 971 Bytes
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
37
38
39
40
<?php
/**
*
* Copyright (C) 2015-2019 FeatherBB
* based on code by (C) 2008-2015 FluxBB
* and Rickard Andersson (C) 2002-2008 PunBB
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*
* $app = new \Slim\Slim();
* $app->add(new \Slim\Extras\Middleware\FeatherBBAuth());
*
*/
namespace FeatherBB\Middleware;
use FeatherBB\Core\Error;
use FeatherBB\Model\Forum;
/**
* Middleware to check if the moderator has its special powers for this post
* Take the topic ID, get the forum ID and check with it
*/
class ModeratePermission
{
public function __invoke($request, $response, $next)
{
$args = $request->getAttribute('routeInfo')[2];
$tid = $args['id'];
$fid = Forum::getId($tid);
$permission = Forum::canModerate($fid);
if (!$permission) {
throw new Error(__('No permission'), 403);
}
$response = $next($request, $response);
return $response;
}
}