ts3phpframework
Loading...
Searching...
No Matches
ServerGroup.php
Go to the documentation of this file.
1<?php
2
3namespace PlanetTeamSpeak\TeamSpeak3Framework\Node;
4
5use PlanetTeamSpeak\TeamSpeak3Framework\Exception\NodeException;
6use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
7
13class ServerGroup extends Group
14{
23 public function __construct(Server $server, array $info, string $index = "sgid")
24 {
25 $this->parent = $server;
26 $this->nodeInfo = $info;
27
28 if (!array_key_exists($index, $this->nodeInfo)) {
29 throw new NodeException("invalid groupID", 0xA00);
30 }
31
32 $this->nodeId = $this->nodeInfo[$index];
33 }
34
41 public function rename(string $name): void
42 {
43 $this->getParent()->serverGroupRename($this->getId(), $name);
44 }
45
53 public function delete(bool $force = false): void
54 {
55 $this->getParent()->serverGroupDelete($this->getId(), $force);
56 }
57
66 public function copy(string $name = null, int $tsgid = 0, int $type = TeamSpeak3::GROUP_DBTYPE_REGULAR): int
67 {
68 return $this->getParent()->serverGroupCopy($this->getId(), $name, $tsgid, $type);
69 }
70
77 public function permList(bool $permsid = false): array
78 {
79 return $this->getParent()->serverGroupPermList($this->getId(), $permsid);
80 }
81
92 public function permAssign(int $permid, int $permvalue, int $permnegated = 0, int $permskip = 0): void
93 {
94 $this->getParent()->serverGroupPermAssign($this->getId(), $permid, $permvalue, $permnegated, $permskip);
95 }
96
102 public function permAssignByName($permname, $permvalue, $permnegated = false, $permskip = false)
103 {
104 $this->permAssign($permname, $permvalue, $permnegated, $permskip);
105 }
106
114 public function permRemove(int $permid): void
115 {
116 $this->getParent()->serverGroupPermRemove($this->getId(), $permid);
117 }
118
124 public function permRemoveByName($permname)
125 {
126 $this->permRemove($permname);
127 }
128
134 public function clientList(): array
135 {
136 return $this->getParent()->serverGroupClientList($this->getId());
137 }
138
146 public function clientAdd(int $cldbid): void
147 {
148 $this->getParent()->serverGroupClientAdd($this->getId(), $cldbid);
149 }
150
157 public function clientDel(int $cldbid): void
158 {
159 $this->getParent()->serverGroupClientDel($this->getId(), $cldbid);
160 }
161
167 public function tokenCreate($description = null, $customset = null): string
168 {
169 return $this->privilegeKeyCreate($description, $customset);
170 }
171
179 public function privilegeKeyCreate(string $description = null, string $customset = null): string
180 {
181 return $this->getParent()
182 ->privilegeKeyCreate($this->getId(), TeamSpeak3::TOKEN_SERVERGROUP, 0, $description, $customset);
183 }
184
188 protected function fetchNodeList()
189 {
190 $this->nodeList = [];
191
192 foreach ($this->getParent()->clientList() as $client) {
193 if (in_array($this->getId(), explode(",", $client["client_servergroups"]))) {
194 $this->nodeList[] = $client;
195 }
196 }
197 }
198
204 public function getUniqueId(): string
205 {
206 return $this->getParent()->getUniqueId() . "_sg" . $this->getId();
207 }
208
214 public function getIcon(): string
215 {
216 return "group_server";
217 }
218}
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Node\Node objects.
copy(string $name=null, int $tsgid=0, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
permAssignByName($permname, $permvalue, $permnegated=false, $permskip=false)
tokenCreate($description=null, $customset=null)
__construct(Server $server, array $info, string $index="sgid")
privilegeKeyCreate(string $description=null, string $customset=null)
permAssign(int $permid, int $permvalue, int $permnegated=0, int $permskip=0)
Class describing a TeamSpeak 3 virtual server and all it's parameters.
Definition Server.php:21
const TOKEN_SERVERGROUP
0: server group token (id1={groupID} id2=0)
const GROUP_DBTYPE_REGULAR
1: regular group (used for regular clients)