ts3phpframework
Loading...
Searching...
No Matches
ChannelGroup.php
Go to the documentation of this file.
1<?php
2
3namespace PlanetTeamSpeak\TeamSpeak3Framework\Node;
4
5use PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException;
6use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
7use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
8
15class ChannelGroup extends Group
16{
25 public function __construct(Server $server, array $info, string $index = "cgid")
26 {
27 $this->parent = $server;
28 $this->nodeInfo = $info;
29
30 if (!array_key_exists($index, $this->nodeInfo)) {
31 throw new ServerQueryException("invalid groupID", 0xA00);
32 }
33
34 $this->nodeId = $this->nodeInfo[$index];
35 }
36
43 public function rename(string $name): void
44 {
45 $this->getParent()->channelGroupRename($this->getId(), $name);
46 }
47
55 public function delete(bool $force = false): void
56 {
57 $this->getParent()->channelGroupDelete($this->getId(), $force);
58 }
59
68 public function copy(string $name = null, int $tcgid = 0, int $type = TeamSpeak3::GROUP_DBTYPE_REGULAR): int
69 {
70 return $this->getParent()->channelGroupCopy($this->getId(), $name, $tcgid, $type);
71 }
72
79 public function permList(bool $permsid = false): array
80 {
81 return $this->getParent()->channelGroupPermList($this->getId(), $permsid);
82 }
83
92 public function permAssign(int $permid, int $permvalue): void
93 {
94 $this->getParent()->channelGroupPermAssign($this->getId(), $permid, $permvalue);
95 }
96
102 public function permAssignByName($permname, $permvalue)
103 {
104 $this->permAssign($permname, $permvalue);
105 }
106
114 public function permRemove(int $permid): void
115 {
116 $this->getParent()->channelGroupPermRemove($this->getId(), $permid);
117 }
118
124 public function permRemoveByName($permname)
125 {
126 $this->permRemove($permname);
127 }
128
137 public function clientList(int $cid = null, int $cldbid = null, bool $resolve = false): array
138 {
139 return $this->getParent()->channelGroupClientList($this->getId(), $cid, $cldbid, $resolve);
140 }
141
147 public function tokenCreate($cid, $description = null, $customset = null): StringHelper
148 {
149 return $this->privilegeKeyCreate($cid, $description, $customset);
150 }
151
160 public function privilegeKeyCreate(int $cid, string $description = null, string $customset = null): StringHelper
161 {
162 return $this->getParent()->privilegeKeyCreate($this->getId(), TeamSpeak3::TOKEN_CHANNELGROUP, $cid, $description, $customset);
163 }
164
168 protected function fetchNodeList()
169 {
170 $this->nodeList = [];
171
172 foreach ($this->getParent()->clientList() as $client) {
173 if ($client["client_channel_group_id"] == $this->getId()) {
174 $this->nodeList[] = $client;
175 }
176 }
177 }
178
184 public function getUniqueId(): string
185 {
186 return $this->getParent()->getUniqueId() . "_cg" . $this->getId();
187 }
188
194 public function getIcon(): string
195 {
196 return "group_channel";
197 }
198}
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.
Class describing a TeamSpeak 3 channel group and all it's parameters.
copy(string $name=null, int $tcgid=0, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
tokenCreate($cid, $description=null, $customset=null)
__construct(Server $server, array $info, string $index="cgid")
clientList(int $cid=null, int $cldbid=null, bool $resolve=false)
privilegeKeyCreate(int $cid, string $description=null, string $customset=null)
Class describing a TeamSpeak 3 virtual server and all it's parameters.
Definition Server.php:21
const TOKEN_CHANNELGROUP
1: channel group token (id1={groupID} id2={channelID})
const GROUP_DBTYPE_REGULAR
1: regular group (used for regular clients)