ChangeApprovalPolicy.php
824 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
<?php
namespace FootyRoom\Core\Comment;
use FootyRoom\Core\AuthException;
use FootyRoom\User\User;
class ChangeApprovalPolicy
{
/**
* Decides whether user can moderate specific comment.
*
* @param \FootyRoom\User\User $user
* @param string $discussionId
* @param bool $throw
*
* @throws \FootyRoom\Core\AuthException
*
* @return bool
*/
public static function check(User $user, $discussionId = '', $throw = false)
{
if (substr($discussionId, 0, 5) === 'wall:' && (int) substr($discussionId, 5) === $user->getUserId()) {
return true;
}
if (CommentPolicy::canModerate($user, $throw)) {
return true;
}
if ($throw) {
throw new AuthException();
}
return false;
}
}