forked from luutruong/XF2_Censorship
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListener.php
More file actions
34 lines (27 loc) · 755 Bytes
/
Listener.php
File metadata and controls
34 lines (27 loc) · 755 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
<?php
/**
* @license
* Copyright 2018 TruongLuu. All Rights Reserved.
*/
namespace Truonglv\Censorship;
use XF;
use XF\Entity\User;
use XF\Mvc\Entity\Entity;
class Listener
{
public static function onEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
{
$structure->columns['tl_censorship_enabled'] = ['type' => Entity::BOOL, 'default' => true];
}
public static function isDisabledCensor(User $user = null)
{
$user = $user ?: XF::visitor();
if (!$user->user_id) {
return false;
}
if (!$user->hasPermission('general', 'tlCensorship_canOnOff')) {
return false;
}
return !$user->Option->tl_censorship_enabled;
}
}