1
|
|
|
<?php |
2
|
|
|
/** @noinspection PhpDeprecationInspection */ |
3
|
|
|
/** @noinspection SqlResolve */ |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Created by Gorlum 14.08.2019 1:37 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Pm; |
10
|
|
|
|
11
|
|
|
use Core\GlobalContainer; |
12
|
|
|
use HelperString; |
13
|
|
|
|
14
|
|
|
class PlayerIgnore { |
15
|
|
|
const IGNORE_PM = 1; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var bool[][][] $ignores [$playerId][$ignoredId][$subsystem] = {false|true} |
19
|
|
|
*/ |
20
|
|
|
protected $ignores = []; |
21
|
|
|
|
22
|
|
|
public function __construct(GlobalContainer $gc) { |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function ignore($playerId, $ignoredId, $subsystem = self::IGNORE_PM) { |
26
|
|
|
if (!$this->isIgnored($playerId, $ignoredId, $subsystem)) { |
27
|
|
|
doquery("REPLACE INTO `{{player_ignore}}` SET `player_id` = {$playerId}, `ignored_id` = {$ignoredId}, `subsystem` = {$subsystem}"); |
|
|
|
|
28
|
|
|
|
29
|
|
|
$this->ignores[$playerId][$ignoredId][$subsystem] = true; |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function unIgnore($playerId, $ignoredId, $subsystem = self::IGNORE_PM) { |
34
|
|
|
if ($this->isIgnored($playerId, $ignoredId, $subsystem)) { |
35
|
|
|
doquery("DELETE FROM `{{player_ignore}}` WHERE `player_id` = {$playerId} AND `ignored_id` = {$ignoredId} AND `subsystem` = {$subsystem}"); |
|
|
|
|
36
|
|
|
|
37
|
|
|
$this->ignores[$playerId][$ignoredId][$subsystem] = false; |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function isIgnored($playerId, $ignoredId, $subsystem = self::IGNORE_PM) { |
42
|
|
|
if (!isset($this->ignores[$playerId][$ignoredId][$subsystem])) { |
43
|
|
|
$ignored = doquery("SELECT * FROM `{{player_ignore}}` WHERE `player_id` = {$playerId} AND `ignored_id` = {$ignoredId} AND `subsystem` = {$subsystem}", true); |
|
|
|
|
44
|
|
|
|
45
|
|
|
$this->ignores[$playerId][$ignoredId][$subsystem] = !empty($ignored); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
return $this->ignores[$playerId][$ignoredId][$subsystem]; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getIgnores($playerId, $htmlEncode = true) { |
52
|
|
|
$result = []; |
53
|
|
|
|
54
|
|
|
$ignores = doquery( |
|
|
|
|
55
|
|
|
"SELECT pi.*, u.username |
56
|
|
|
FROM `{{player_ignore}}` AS pi |
57
|
|
|
LEFT JOIN `{{users}}` AS u ON u.id = pi.ignored_id |
58
|
|
|
WHERE `player_id` = {$playerId} |
59
|
|
|
ORDER BY `player_id`, `ignored_id`,`subsystem`" |
60
|
|
|
); |
61
|
|
|
while ($row = db_fetch($ignores)) { |
62
|
|
|
$name = $htmlEncode ? HelperString::htmlEncode($row['username']) : $row['username']; |
63
|
|
|
|
64
|
|
|
$result[] = [ |
65
|
|
|
'ID' => $row['ignored_id'], |
66
|
|
|
'NAME' => $name, |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return $result; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.