|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\AdminChat\ChatCommand; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups; |
|
6
|
|
|
use eXpansion\Framework\AdminGroups\Model\AbstractAdminChatCommand; |
|
7
|
|
|
use eXpansion\Framework\Core\Helpers\ChatNotification; |
|
8
|
|
|
use eXpansion\Framework\Core\Helpers\Time; |
|
9
|
|
|
use eXpansion\Framework\Core\Storage\PlayerStorage; |
|
10
|
|
|
use Maniaplanet\DedicatedServer\Connection; |
|
11
|
|
|
use Psr\Log\LoggerInterface; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class Restart |
|
15
|
|
|
* |
|
16
|
|
|
* @package eXpansion\Bundle\AdminChat\ChatCommand; |
|
17
|
|
|
* @author oliver de Cramer <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractConnectionCommand extends AbstractAdminChatCommand |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var Connection */ |
|
22
|
|
|
protected $connection; |
|
23
|
|
|
|
|
24
|
|
|
/** @var ChatNotification */ |
|
25
|
|
|
protected $chatNotification; |
|
26
|
|
|
|
|
27
|
|
|
/** @var PlayerStorage */ |
|
28
|
|
|
protected $playerStorage; |
|
29
|
|
|
|
|
30
|
|
|
/** @var LoggerInterface */ |
|
31
|
|
|
protected $logger; |
|
32
|
|
|
|
|
33
|
|
|
/** @var Time */ |
|
34
|
|
|
protected $timeHelper; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Send chat output to public chat |
|
38
|
|
|
* @var bool |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $isPublic = true; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* AbstractConnectionCommand constructor. |
|
44
|
|
|
* @param $command |
|
45
|
|
|
* @param string $permission |
|
46
|
|
|
* @param array $aliases |
|
47
|
|
|
* @param AdminGroups $adminGroupsHelper |
|
48
|
|
|
* @param Connection $connection |
|
49
|
|
|
* @param ChatNotification $chatNotification |
|
50
|
|
|
* @param PlayerStorage $playerStorage |
|
51
|
|
|
* @param LoggerInterface $logger |
|
52
|
|
|
* @param Time $timeHelper |
|
53
|
|
|
*/ |
|
54
|
2 |
|
public function __construct( |
|
55
|
|
|
$command, |
|
56
|
|
|
$permission, |
|
57
|
|
|
array $aliases = [], |
|
58
|
|
|
AdminGroups $adminGroupsHelper, |
|
59
|
|
|
Connection $connection, |
|
60
|
|
|
ChatNotification $chatNotification, |
|
61
|
|
|
PlayerStorage $playerStorage, |
|
62
|
|
|
LoggerInterface $logger, |
|
63
|
|
|
Time $timeHelper |
|
64
|
|
|
) { |
|
65
|
2 |
|
parent::__construct($command, $permission, $aliases, $adminGroupsHelper); |
|
66
|
|
|
|
|
67
|
2 |
|
$this->connection = $connection; |
|
68
|
2 |
|
$this->chatNotification = $chatNotification; |
|
69
|
2 |
|
$this->playerStorage = $playerStorage; |
|
70
|
2 |
|
$this->logger = $logger; |
|
71
|
2 |
|
$this->timeHelper = $timeHelper; |
|
72
|
2 |
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param bool $bool chat output visibility |
|
76
|
|
|
*/ |
|
77
|
|
|
public function setPublic($bool) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->isPublic = (bool)$bool; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get admin group Label |
|
84
|
|
|
* |
|
85
|
|
|
* @param string $login |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
1 |
|
public function getGroupLabel($login) |
|
89
|
|
|
{ |
|
90
|
1 |
|
$group = $this->adminGroupsHelper->getLoginUserGroups($login); |
|
91
|
|
|
|
|
92
|
1 |
|
$groupName = "Admin"; |
|
93
|
1 |
|
if ($group) { |
|
94
|
|
|
if ($groupName) { |
|
95
|
|
|
$groupName = $this->adminGroupsHelper->getGroupLabel($group->getName()); |
|
96
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
1 |
|
return $groupName; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
} |
|
104
|
|
|
|