TeamSpeak 3 PHP Framework
Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
TeamSpeak3_Node_Client Class Reference

Class describing a TeamSpeak 3 client and all it's parameters. More...

+ Inheritance diagram for TeamSpeak3_Node_Client:

Public Member Functions

 __construct (TeamSpeak3_Node_Server $server, array $info, $index="clid")
 The TeamSpeak3_Node_Client constructor. More...
 
 __toString ()
 Returns a string representation of this node. More...
 
 addServerGroup ($sgid)
 Adds the client to the server group specified with $sgid. More...
 
 avatarDownload ()
 Downloads and returns the clients avatar file content. More...
 
 avatarGetName ()
 Returns the possible name of the clients avatar. More...
 
 ban ($timeseconds=null, $reason=null)
 Bans the client from the server. More...
 
 customInfo ()
 Returns a list of custom properties for the client. More...
 
 deleteDb ()
 Deletes the clients properties from the database. More...
 
 getClones ()
 Returns a list of client connections using the same identity as this client. More...
 
 getIcon ()
 Returns the name of a possible icon to display the node object. More...
 
 getRev ()
 Returns the revision/build number from the clients version string. More...
 
 getSymbol ()
 Returns a symbol representing the node. More...
 
 getUniqueId ()
 Returns a unique identifier for the node which can be used as a HTML property. More...
 
 iconDownload ()
 Downloads and returns the clients icon file content. More...
 
 infoDb ()
 Returns a list of properties from the database for the client. More...
 
 kick ($reasonid=TeamSpeak3::KICK_CHANNEL, $reasonmsg=null)
 Kicks the client from his currently joined channel or from the server. More...
 
 memberOf ()
 Returns all server and channel groups the client is currently residing in. More...
 
 message ($msg)
 Sends a text message to the client. More...
 
 modify (array $properties)
 Changes the clients properties using given properties. More...
 
 modifyDb (array $properties)
 Changes the clients properties using given properties. More...
 
 move ($cid, $cpw=null)
 Moves the client to another channel. More...
 
 permAssign ($permid, $permvalue, $permskip=FALSE)
 Adds a set of specified permissions to the client. More...
 
 permAssignByName ($permname, $permvalue, $permskip=FALSE)
 Alias for permAssign(). More...
 
 permList ($permsid=FALSE)
 Returns a list of permissions defined for the client. More...
 
 permOverview ($cid)
 Returns an array containing the permission overview of the client. More...
 
 permRemove ($permid)
 Removes a set of specified permissions from a client. More...
 
 permRemoveByName ($permname)
 Alias for permRemove(). More...
 
 poke ($msg)
 Sends a poke message to the client. More...
 
 remServerGroup ($sgid)
 Removes the client from the server group specified with $sgid. More...
 
 sendPluginCmd ($plugin, $data)
 Sends a plugin command to the client. More...
 
 setChannelGroup ($cid, $cgid)
 Sets the channel group of a client to the ID specified. More...
 
- Public Member Functions inherited from TeamSpeak3_Node_Abstract
 __call ($name, array $args)
 Called whenever we're using an unknown method. More...
 
 __get ($offset)
 
 __set ($offset, $value)
 
 __sleep ()
 Commit pending data. More...
 
 __toString ()
 Returns a string representation of this node. More...
 
 count ()
 
 current ()
 
 execute ($cmd, array $params=array())
 Prepares and executes a ServerQuery command and returns the result. More...
 
 getChildren ()
 
 getClass ($prefix="ts3_")
 Returns a possible classname for the node which can be used as a HTML property. More...
 
 getIcon ()
 Returns the name of a possible icon to display the node object. More...
 
 getId ()
 Returns the primary ID of the current node. More...
 
 getInfo ($extend=TRUE, $convert=FALSE)
 Returns all information available on this node. More...
 
 getParent ()
 Returns the parent object of the current node. More...
 
 getProperty ($property, $default=null)
 Returns the specified property or a pre-defined default value from the node info array. More...
 
 getSymbol ()
 Returns a symbol representing the node. More...
 
 getUniqueId ()
 Returns a unique identifier for the node which can be used as a HTML property. More...
 
 getViewer (TeamSpeak3_Viewer_Interface $viewer)
 Returns the HTML code to display a TeamSpeak 3 viewer. More...
 
 hasChildren ()
 
 hasNext ()
 
 iconGetName ($key)
 Returns the internal path of the node icon. More...
 
 iconIsLocal ($key)
 Returns TRUE if the node icon has a local source. More...
 
 key ()
 
 next ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 prepare ($cmd, array $params=array())
 Uses given parameters and returns a prepared ServerQuery command. More...
 
 request ($cmd, $throw=TRUE)
 Sends a prepared command to the server and returns the result. More...
 
 rewind ()
 
 toArray ()
 Returns an assoc array filled with current node info properties. More...
 
 toString ()
 Returns a string representation of this node. More...
 
 valid ()
 

Protected Member Functions

 fetchNodeInfo ()
 
- Protected Member Functions inherited from TeamSpeak3_Node_Abstract
 delStorage ($key)
 Deletes data from the internal storage array. More...
 
 fetchNodeInfo ()
 
 fetchNodeList ()
 
 filterList (array $nodes=array(), array $rules=array())
 Filters given node list array using specified filter rules. More...
 
 getStorage ($key, $default=null)
 Returns data from the internal storage array. More...
 
 resetNodeInfo ()
 
 resetNodeList ()
 
 setStorage ($key, $val)
 Writes data to the internal storage array. More...
 
 verifyNodeList ()
 

Additional Inherited Members

- Protected Attributes inherited from TeamSpeak3_Node_Abstract
 $nodeId = 0x00
 
 $nodeInfo = array()
 
 $nodeList = null
 
 $parent = null
 
 $server = null
 
 $storage = array()
 

Detailed Description

Class describing a TeamSpeak 3 client and all it's parameters.

Constructor & Destructor Documentation

◆ __construct()

__construct ( TeamSpeak3_Node_Server  $server,
array  $info,
  $index = "clid" 
)

The TeamSpeak3_Node_Client constructor.

Parameters
TeamSpeak3_Node_Server$server
array$info
string$index
Exceptions
TeamSpeak3_Adapter_ServerQuery_Exception
Returns
TeamSpeak3_Node_Client
41  {
42  $this->parent = $server;
43  $this->nodeInfo = $info;
44 
45  if(!array_key_exists($index, $this->nodeInfo))
46  {
47  throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
48  }
49 
50  $this->nodeId = $this->nodeInfo[$index];
51  }
$server
Definition: Abstract.php:39
Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
Definition: Exception.php:29

Member Function Documentation

◆ __toString()

__toString ( )

Returns a string representation of this node.

Returns
string
434  {
435  return (string) $this["client_nickname"];
436  }

◆ addServerGroup()

addServerGroup (   $sgid)

Adds the client to the server group specified with $sgid.

Parameters
integer$sgid
Returns
void
253  {
254  $this->getParent()->serverGroupClientAdd($sgid, $this["client_database_id"]);
255  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ avatarDownload()

avatarDownload ( )

Downloads and returns the clients avatar file content.

Returns
TeamSpeak3_Helper_String
284  {
285  if($this["client_flag_avatar"] == NULL) return;
286 
287  $download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->avatarGetName());
288  $transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
289 
290  return $transfer->download($download["ftkey"], $download["size"]);
291  }
avatarGetName()
Returns the possible name of the clients avatar.
Definition: Client.php:273
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
static factory($uri)
Factory for TeamSpeak3_Adapter_Abstract classes.
Definition: TeamSpeak3.php:316

◆ avatarGetName()

avatarGetName ( )

Returns the possible name of the clients avatar.

Returns
TeamSpeak3_Helper_String
274  {
275  return new TeamSpeak3_Helper_String("/avatar_" . $this["client_base64HashClientUID"]);
276  }
Helper class for string handling.
Definition: String.php:29

◆ ban()

ban (   $timeseconds = null,
  $reason = null 
)

Bans the client from the server.

Please note that this will create two separate ban rules for the targeted clients IP address and his unique identifier.

Parameters
integer$timeseconds
string$reason
Returns
array
153  {
154  return $this->getParent()->clientBan($this->getId(), $timeseconds, $reason);
155  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113

◆ customInfo()

customInfo ( )

Returns a list of custom properties for the client.

Returns
array
163  {
164  return $this->getParent()->customInfo($this["client_database_id"]);
165  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ deleteDb()

deleteDb ( )

Deletes the clients properties from the database.

Returns
void
84  {
85  $this->getParent()->clientDeleteDb($this["client_database_id"]);
86  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ getClones()

getClones ( )

Returns a list of client connections using the same identity as this client.

Returns
array
299  {
300  return $this->execute("clientgetids", array("cluid" => $this["client_unique_identifier"]))->toAssocArray("clid");
301  }
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ getIcon()

getIcon ( )

Returns the name of a possible icon to display the node object.

Returns
string
383  {
384  if($this["client_type"])
385  {
386  return "client_query";
387  }
388  elseif($this["client_away"])
389  {
390  return "client_away";
391  }
392  elseif(!$this["client_output_hardware"])
393  {
394  return "client_snd_disabled";
395  }
396  elseif($this["client_output_muted"])
397  {
398  return "client_snd_muted";
399  }
400  elseif(!$this["client_input_hardware"])
401  {
402  return "client_mic_disabled";
403  }
404  elseif($this["client_input_muted"])
405  {
406  return "client_mic_muted";
407  }
408  elseif($this["client_is_channel_commander"])
409  {
410  return $this["client_flag_talking"] ? "client_cc_talk" : "client_cc_idle";
411  }
412  else
413  {
414  return $this["client_flag_talking"] ? "client_talk" : "client_idle";
415  }
416  }

◆ getRev()

getRev ( )

Returns the revision/build number from the clients version string.

Returns
integer
309  {
310  return $this["client_type"] ? null : $this["client_version"]->section("[", 1)->filterDigits();
311  }

◆ getSymbol()

getSymbol ( )

Returns a symbol representing the node.

Returns
string
424  {
425  return "@";
426  }

◆ getUniqueId()

getUniqueId ( )

Returns a unique identifier for the node which can be used as a HTML property.

Returns
string
373  {
374  return $this->getParent()->getUniqueId() . "_cl" . $this->getId();
375  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113

◆ iconDownload()

iconDownload ( )

Downloads and returns the clients icon file content.

Returns
TeamSpeak3_Helper_String
336  {
337  if($this->iconIsLocal("client_icon_id") || $this["client_icon_id"] == 0) return;
338 
339  $download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("client_icon_id"));
340  $transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
341 
342  return $transfer->download($download["ftkey"], $download["size"]);
343  }
iconGetName($key)
Returns the internal path of the node icon.
Definition: Abstract.php:135
iconIsLocal($key)
Returns TRUE if the node icon has a local source.
Definition: Abstract.php:124
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
static factory($uri)
Factory for TeamSpeak3_Adapter_Abstract classes.
Definition: TeamSpeak3.php:316

◆ infoDb()

infoDb ( )

Returns a list of properties from the database for the client.

Returns
array
94  {
95  return $this->getParent()->clientInfoDb($this["client_database_id"]);
96  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ kick()

kick (   $reasonid = TeamSpeak3::KICK_CHANNEL,
  $reasonmsg = null 
)

Kicks the client from his currently joined channel or from the server.

Parameters
integer$reasonid
string$reasonmsg
Returns
void
129  {
130  $this->getParent()->clientKick($this->getId(), $reasonid, $reasonmsg);
131  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113

◆ memberOf()

memberOf ( )

Returns all server and channel groups the client is currently residing in.

Returns
array
319  {
320  $groups = array($this->getParent()->channelGroupGetById($this["client_channel_group_id"]));
321 
322  foreach(explode(",", $this["client_servergroups"]) as $sgid)
323  {
324  $groups[] = $this->getParent()->serverGroupGetById($sgid);
325  }
326 
327  return $groups;
328  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ message()

message (   $msg)

Sends a text message to the client.

Parameters
string$msg
Returns
void
105  {
106  $this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(), "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
107  }
const TEXTMSG_CLIENT
1: target is a client
Definition: TeamSpeak3.php:121
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ modify()

modify ( array  $properties)

Changes the clients properties using given properties.

Parameters
array$properties
Returns
void
60  {
61  $properties["clid"] = $this->getId();
62 
63  $this->execute("clientedit", $properties);
64  $this->resetNodeInfo();
65  }
resetNodeInfo()
Definition: Abstract.php:445
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ modifyDb()

modifyDb ( array  $properties)

Changes the clients properties using given properties.

Parameters
array$properties
Returns
void
74  {
75  $this->getParent()->clientModifyDb($this["client_database_id"], $properties);
76  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ move()

move (   $cid,
  $cpw = null 
)

Moves the client to another channel.

Parameters
integer$cid
string$cpw
Returns
void
117  {
118  $this->getParent()->clientMove($this->getId(), $cid, $cpw);
119  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113

◆ permAssign()

permAssign (   $permid,
  $permvalue,
  $permskip = FALSE 
)

Adds a set of specified permissions to the client.

Multiple permissions can be added by providing the three parameters of each permission.

Parameters
integer$permid
integer$permvalue
integer$permskip
Returns
void
199  {
200  $this->getParent()->clientPermAssign($this["client_database_id"], $permid, $permvalue, $permskip);
201  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ permAssignByName()

permAssignByName (   $permname,
  $permvalue,
  $permskip = FALSE 
)

Alias for permAssign().

Deprecated:
209  {
210  $this->permAssign($permname, $permvalue, $permskip);
211  }
permAssign($permid, $permvalue, $permskip=FALSE)
Adds a set of specified permissions to the client.
Definition: Client.php:198

◆ permList()

permList (   $permsid = FALSE)

Returns a list of permissions defined for the client.

Parameters
boolean$permsid
Returns
array
185  {
186  return $this->getParent()->clientPermList($this["client_database_id"], $permsid);
187  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ permOverview()

permOverview (   $cid)

Returns an array containing the permission overview of the client.

Parameters
integer$cid
Returns
array
174  {
175  return $this->execute("permoverview", array("cldbid" => $this["client_database_id"], "cid" => $cid, "permid" => 0))->toArray();
176  }
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ permRemove()

permRemove (   $permid)

Removes a set of specified permissions from a client.

Multiple permissions can be removed at once.

Parameters
integer$permid
Returns
void
220  {
221  $this->getParent()->clientPermRemove($this["client_database_id"], $permid);
222  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ permRemoveByName()

permRemoveByName (   $permname)

Alias for permRemove().

Deprecated:
230  {
231  $this->permRemove($permname);
232  }
permRemove($permid)
Removes a set of specified permissions from a client.
Definition: Client.php:219

◆ poke()

poke (   $msg)

Sends a poke message to the client.

Parameters
string$msg
Returns
void
140  {
141  $this->getParent()->clientPoke($this->getId(), $msg);
142  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113

◆ remServerGroup()

remServerGroup (   $sgid)

Removes the client from the server group specified with $sgid.

Parameters
integer$sgid
Returns
void
264  {
265  $this->getParent()->serverGroupClientDel($sgid, $this["client_database_id"]);
266  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ sendPluginCmd()

sendPluginCmd (   $plugin,
  $data 
)

Sends a plugin command to the client.

Parameters
string$plugin
string$data
Returns
void
353  {
354  $this->execute("plugincmd", array("name" => $plugin, "data" => $data, "targetmode" => TeamSpeak3::PLUGINCMD_CLIENT, "target" => $this->getId()));
355  }
const PLUGINCMD_CLIENT
3: send plugincmd to all given client ids
Definition: TeamSpeak3.php:130
getId()
Returns the primary ID of the current node.
Definition: Abstract.php:113
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ setChannelGroup()

setChannelGroup (   $cid,
  $cgid 
)

Sets the channel group of a client to the ID specified.

Parameters
integer$cid
integer$cgid
Returns
void
242  {
243  $this->getParent()->clientSetChannelGroup($this["client_database_id"], $cid, $cgid);
244  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

The documentation for this class was generated from the following file: