Initial commit
This commit is contained in:
624
lib/ts3phpframework/libraries/TeamSpeak3/Node/Abstract.php
Normal file
624
lib/ts3phpframework/libraries/TeamSpeak3/Node/Abstract.php
Normal file
@ -0,0 +1,624 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Abstract.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Abstract
|
||||
* @brief Abstract class describing a TeamSpeak 3 node and all it's parameters.
|
||||
*/
|
||||
abstract class TeamSpeak3_Node_Abstract implements RecursiveIterator, ArrayAccess, Countable
|
||||
{
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected $parent = null;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected $server = null;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected $nodeId = 0x00;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected $nodeList = null;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected $nodeInfo = array();
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected $storage = array();
|
||||
|
||||
/**
|
||||
* Sends a prepared command to the server and returns the result.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param boolean $throw
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
*/
|
||||
public function request($cmd, $throw = TRUE)
|
||||
{
|
||||
return $this->getParent()->request($cmd, $throw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses given parameters and returns a prepared ServerQuery command.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param array $params
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function prepare($cmd, array $params = array())
|
||||
{
|
||||
return $this->getParent()->prepare($cmd, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares and executes a ServerQuery command and returns the result.
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param array $params
|
||||
* @return TeamSpeak3_Adapter_ServerQuery_Reply
|
||||
*/
|
||||
public function execute($cmd, array $params = array())
|
||||
{
|
||||
return $this->request($this->prepare($cmd, $params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent object of the current node.
|
||||
*
|
||||
* @return TeamSpeak3_Adapter_ServerQuery
|
||||
* @return TeamSpeak3_Node_Abstract
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary ID of the current node.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->nodeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the node icon has a local source.
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function iconIsLocal($key)
|
||||
{
|
||||
return ($this[$key] > 0 && $this[$key] < 1000) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal path of the node icon.
|
||||
*
|
||||
* @param string $key
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconGetName($key)
|
||||
{
|
||||
$iconid = ($this[$key] < 0) ? (pow(2, 32))-($this[$key]*-1) : $this[$key];
|
||||
|
||||
return new TeamSpeak3_Helper_String("/icon_" . $iconid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a possible classname for the node which can be used as a HTML property.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @return string
|
||||
*/
|
||||
public function getClass($prefix = "ts3_")
|
||||
{
|
||||
if($this instanceof TeamSpeak3_Node_Channel && $this->isSpacer())
|
||||
{
|
||||
return $prefix . "spacer";
|
||||
}
|
||||
elseif($this instanceof TeamSpeak3_Node_Client && $this["client_type"])
|
||||
{
|
||||
return $prefix . "query";
|
||||
}
|
||||
|
||||
return $prefix . TeamSpeak3_Helper_String::factory(get_class($this))->section("_", 2)->toLower();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getIcon();
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getSymbol();
|
||||
|
||||
/**
|
||||
* Returns the HTML code to display a TeamSpeak 3 viewer.
|
||||
*
|
||||
* @param TeamSpeak3_Viewer_Interface $viewer
|
||||
* @return string
|
||||
*/
|
||||
public function getViewer(TeamSpeak3_Viewer_Interface $viewer)
|
||||
{
|
||||
$html = $viewer->fetchObject($this);
|
||||
|
||||
$iterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
foreach($iterator as $node)
|
||||
{
|
||||
$siblings = array();
|
||||
|
||||
for($level = 0; $level < $iterator->getDepth(); $level++)
|
||||
{
|
||||
$siblings[] = ($iterator->getSubIterator($level)->hasNext()) ? 1 : 0;
|
||||
}
|
||||
|
||||
$siblings[] = (!$iterator->getSubIterator($level)->hasNext()) ? 1 : 0;
|
||||
|
||||
$html .= $viewer->fetchObject($node, $siblings);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters given node list array using specified filter rules.
|
||||
*
|
||||
* @param array $nodes
|
||||
* @param array $rules
|
||||
* @return array
|
||||
*/
|
||||
protected function filterList(array $nodes = array(), array $rules = array())
|
||||
{
|
||||
if(!empty($rules))
|
||||
{
|
||||
foreach($nodes as $node)
|
||||
{
|
||||
if(!$node instanceof TeamSpeak3_Node_Abstract) continue;
|
||||
|
||||
$props = $node->getInfo(FALSE);
|
||||
$props = array_intersect_key($props, $rules);
|
||||
|
||||
foreach($props as $key => $val)
|
||||
{
|
||||
if($val instanceof TeamSpeak3_Helper_String)
|
||||
{
|
||||
$match = $val->contains($rules[$key], TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$match = $val == $rules[$key];
|
||||
}
|
||||
|
||||
if($match === FALSE)
|
||||
{
|
||||
unset($nodes[$node->getId()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all information available on this node. If $convert is enabled, some property
|
||||
* values will be converted to human-readable values.
|
||||
*
|
||||
* @param boolean $extend
|
||||
* @param boolean $convert
|
||||
* @return array
|
||||
*/
|
||||
public function getInfo($extend = TRUE, $convert = FALSE)
|
||||
{
|
||||
if($extend)
|
||||
{
|
||||
$this->fetchNodeInfo();
|
||||
}
|
||||
|
||||
if($convert)
|
||||
{
|
||||
$info = $this->nodeInfo;
|
||||
|
||||
foreach($info as $key => $val)
|
||||
{
|
||||
$key = TeamSpeak3_Helper_String::factory($key);
|
||||
|
||||
if($key->contains("_bytes_"))
|
||||
{
|
||||
$info[$key->toString()] = TeamSpeak3_Helper_Convert::bytes($val);
|
||||
}
|
||||
elseif($key->contains("_bandwidth_"))
|
||||
{
|
||||
$info[$key->toString()] = TeamSpeak3_Helper_Convert::bytes($val) . "/s";
|
||||
}
|
||||
elseif($key->contains("_packets_"))
|
||||
{
|
||||
$info[$key->toString()] = number_format($val, null, null, ".");
|
||||
}
|
||||
elseif($key->contains("_packetloss_"))
|
||||
{
|
||||
$info[$key->toString()] = sprintf("%01.2f", floatval($val->toString())*100) . "%";
|
||||
}
|
||||
elseif($key->endsWith("_uptime"))
|
||||
{
|
||||
$info[$key->toString()] = TeamSpeak3_Helper_Convert::seconds($val);
|
||||
}
|
||||
elseif($key->endsWith("_version"))
|
||||
{
|
||||
$info[$key->toString()] = TeamSpeak3_Helper_Convert::version($val);
|
||||
}
|
||||
elseif($key->endsWith("_icon_id"))
|
||||
{
|
||||
$info[$key->toString()] = $this->iconGetName($key)->filterDigits();
|
||||
}
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
return $this->nodeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified property or a pre-defined default value from the node info array.
|
||||
*
|
||||
* @param string $property
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getProperty($property, $default = null)
|
||||
{
|
||||
if(!$this->offsetExists($property))
|
||||
{
|
||||
$this->fetchNodeInfo();
|
||||
}
|
||||
|
||||
if(!$this->offsetExists($property))
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $this->nodeInfo[(string) $property];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return get_class($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
{
|
||||
return $this->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an assoc array filled with current node info properties.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->nodeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever we're using an unknown method.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $args
|
||||
* @throws TeamSpeak3_Node_Exception
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, array $args)
|
||||
{
|
||||
if($this->getParent() instanceof TeamSpeak3_Node_Abstract)
|
||||
{
|
||||
return call_user_func_array(array($this->getParent(), $name), $args);
|
||||
}
|
||||
|
||||
throw new TeamSpeak3_Node_Exception("node method '" . $name . "()' does not exist");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the internal storage array.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $val
|
||||
* @return void
|
||||
*/
|
||||
protected function setStorage($key, $val)
|
||||
{
|
||||
$this->storage[$key] = $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data from the internal storage array.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getStorage($key, $default = null)
|
||||
{
|
||||
return !empty($this->storage[$key]) ? $this->storage[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes data from the internal storage array.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
protected function delStorage($key)
|
||||
{
|
||||
unset($this->storage[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit pending data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return array("parent", "storage", "nodeId");
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeInfo()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function resetNodeInfo()
|
||||
{
|
||||
$this->nodeInfo = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function verifyNodeList()
|
||||
{
|
||||
if($this->nodeList === null)
|
||||
{
|
||||
$this->fetchNodeList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function resetNodeList()
|
||||
{
|
||||
$this->nodeList = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return count($this->nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return current($this->nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return $this->current();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function hasChildren()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return $this->current()->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function hasNext()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return $this->key()+1 < $this->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return key($this->nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return $this->key() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return next($this->nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->verifyNodeList();
|
||||
|
||||
return reset($this->nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists((string) $offset, $this->nodeInfo) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if(!$this->offsetExists($offset))
|
||||
{
|
||||
$this->fetchNodeInfo();
|
||||
}
|
||||
|
||||
if(!$this->offsetExists($offset))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid parameter", 0x602);
|
||||
}
|
||||
|
||||
return $this->nodeInfo[(string) $offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if(method_exists($this, "modify"))
|
||||
{
|
||||
return $this->modify(array((string) $offset => $value));
|
||||
}
|
||||
|
||||
throw new TeamSpeak3_Node_Exception("node '" . get_class($this) . "' is read only");
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($this->nodeInfo[(string) $offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __get($offset)
|
||||
{
|
||||
return $this->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __set($offset, $value)
|
||||
{
|
||||
$this->offsetSet($offset, $value);
|
||||
}
|
||||
}
|
588
lib/ts3phpframework/libraries/TeamSpeak3/Node/Channel.php
Normal file
588
lib/ts3phpframework/libraries/TeamSpeak3/Node/Channel.php
Normal file
@ -0,0 +1,588 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Channel.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Channel
|
||||
* @brief Class describing a TeamSpeak 3 channel and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Channel extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Channel constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Channel
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "cid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid channelID", 0x300);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array filled with TeamSpeak3_Node_Channel objects.
|
||||
*
|
||||
* @param array $filter
|
||||
* @return array
|
||||
*/
|
||||
public function subChannelList(array $filter = array())
|
||||
{
|
||||
$channels = array();
|
||||
|
||||
foreach($this->getParent()->channelList() as $channel)
|
||||
{
|
||||
if($channel["pid"] == $this->getId())
|
||||
{
|
||||
$channels[$channel->getId()] = $channel;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->filterList($channels, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Node_Channel object matching the given ID.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Channel
|
||||
*/
|
||||
public function subChannelGetById($cid)
|
||||
{
|
||||
if(!array_key_exists((string) $cid, $this->subChannelList()))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid channelID", 0x300);
|
||||
}
|
||||
|
||||
return $this->channelList[(string) $cid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Node_Channel object matching the given name.
|
||||
*
|
||||
* @param integer $name
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Channel
|
||||
*/
|
||||
public function subChannelGetByName($name)
|
||||
{
|
||||
foreach($this->subChannelList() as $channel)
|
||||
{
|
||||
if($channel["channel_name"] == $name) return $channel;
|
||||
}
|
||||
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid channelID", 0x300);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array filled with TeamSpeak3_Node_Client objects.
|
||||
*
|
||||
* @param array $filter
|
||||
* @return array
|
||||
*/
|
||||
public function clientList(array $filter = array())
|
||||
{
|
||||
$clients = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if($client["cid"] == $this->getId())
|
||||
{
|
||||
$clients[$client->getId()] = $client;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->filterList($clients, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Node_Client object matching the given ID.
|
||||
*
|
||||
* @param integer $clid
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Client
|
||||
*/
|
||||
public function clientGetById($clid)
|
||||
{
|
||||
if(!array_key_exists($clid, $this->clientList()))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
|
||||
}
|
||||
|
||||
return $this->clientList[intval($clid)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TeamSpeak3_Node_Client object matching the given name.
|
||||
*
|
||||
* @param integer $name
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Client
|
||||
*/
|
||||
public function clientGetByName($name)
|
||||
{
|
||||
foreach($this->clientList() as $client)
|
||||
{
|
||||
if($client["client_nickname"] == $name) return $client;
|
||||
}
|
||||
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions defined for a client in the channel.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function clientPermList($cldbid, $permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelClientPermList($this->getId(), $cldbid, $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to a client in a specific channel. Multiple permissions can be added by
|
||||
* providing the two parameters of each permission.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @return void
|
||||
*/
|
||||
public function clientPermAssign($cldbid, $permid, $permvalue)
|
||||
{
|
||||
$this->getParent()->channelClientPermAssign($this->getId(), $cldbid, $permid, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for clientPermAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function clientPermAssignByName($cldbid, $permname, $permvalue)
|
||||
{
|
||||
$this->clientPermAssign($cldbid, $permname, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from a client in the channel. Multiple permissions can be removed at once.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function clientPermRemove($cldbid, $permid)
|
||||
{
|
||||
$this->getParent()->channelClientPermRemove($this->getId(), $cldbid, $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for clientPermRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function clientPermRemoveByName($cldbid, $permname)
|
||||
{
|
||||
$this->clientPermRemove($cldbid, $permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions defined for the channel.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the channel. Multiple permissions can be added by
|
||||
* providing the two parameters of each permission.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue)
|
||||
{
|
||||
$this->getParent()->channelPermAssign($this->getId(), $permid, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the channel. Multiple permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->channelPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of files and directories stored in the channels file repository.
|
||||
*
|
||||
* @param string $cpw
|
||||
* @param string $path
|
||||
* @param boolean $recursive
|
||||
* @return array
|
||||
*/
|
||||
public function fileList($cpw = "", $path = "/", $recursive = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelFileList($this->getId(), $cpw, $path, $recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns detailed information about the specified file stored in the channels file repository.
|
||||
*
|
||||
* @param string $cpw
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function fileInfo($cpw = "", $name = "/")
|
||||
{
|
||||
return $this->getParent()->channelFileInfo($this->getId(), $cpw, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a file in the channels file repository. If the two parameters $tcid and $tcpw are specified, the file
|
||||
* will be moved into another channels file repository.
|
||||
*
|
||||
* @param string $cpw
|
||||
* @param string $oldname
|
||||
* @param string $newname
|
||||
* @param integer $tcid
|
||||
* @param string $tcpw
|
||||
* @return void
|
||||
*/
|
||||
public function fileRename($cpw = "", $oldname = "/", $newname = "/", $tcid = null, $tcpw = null)
|
||||
{
|
||||
$this->getParent()->channelFileRename($this->getId(), $cpw, $oldname, $newname, $tcid, $tcpw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes one or more files stored in the channels file repository.
|
||||
*
|
||||
* @param string $cpw
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
public function fileDelete($cpw = "", $name = "/")
|
||||
{
|
||||
$this->getParent()->channelFileDelete($this->getId(), $cpw, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new directory in a channels file repository.
|
||||
*
|
||||
* @param string $cpw
|
||||
* @param string $dirname
|
||||
* @return void
|
||||
*/
|
||||
public function dirCreate($cpw = "", $dirname = "/")
|
||||
{
|
||||
$this->getParent()->channelDirCreate($this->getId(), $cpw, $dirname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the level of the channel.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->getParent()->channelGetLevel($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pathway of the channel which can be used as a clients default channel.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathway()
|
||||
{
|
||||
return $this->getParent()->channelGetPathway($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the possible spacer type of the channel.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function spacerGetType()
|
||||
{
|
||||
return $this->getParent()->channelSpacerGetType($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the possible spacer alignment of the channel.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function spacerGetAlign()
|
||||
{
|
||||
return $this->getParent()->channelSpacerGetAlign($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the channel is a spacer.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSpacer()
|
||||
{
|
||||
return $this->getParent()->channelIsSpacer($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the channels icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("channel_icon_id") || $this["channel_icon_id"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("channel_icon_id"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the channel configuration using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modify(array $properties)
|
||||
{
|
||||
$properties["cid"] = $this->getId();
|
||||
|
||||
$this->execute("channeledit", $properties);
|
||||
$this->resetNodeInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients in the channel.
|
||||
*
|
||||
* @param string $msg
|
||||
* @param string $cpw
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg, $cpw = null)
|
||||
{
|
||||
if($this->getId() != $this->getParent()->whoamiGet("client_channel_id"))
|
||||
{
|
||||
$this->getParent()->clientMove($this->getParent()->whoamiGet("client_id"), $this->getId(), $cpw);
|
||||
}
|
||||
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(), "targetmode" => TeamSpeak3::TEXTMSG_CHANNEL));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the channel.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->channelDelete($this->getId(), $force);
|
||||
|
||||
unset($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the channel to the parent channel specified with $pid.
|
||||
*
|
||||
* @param integer $pid
|
||||
* @param integer $order
|
||||
* @return void
|
||||
*/
|
||||
public function move($pid, $order = null)
|
||||
{
|
||||
$this->getParent()->channelMove($this->getId(), $pid, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a plugin command to all clients in the channel.
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $data
|
||||
* @param string $cpw
|
||||
* @param boolean $subscribed
|
||||
* @return void
|
||||
*/
|
||||
public function sendPluginCmd($plugin, $data, $cpw = null, $subscribed = FALSE)
|
||||
{
|
||||
if($this->getId() != $this->getParent()->whoamiGet("client_channel_id"))
|
||||
{
|
||||
$this->getParent()->clientMove($this->getParent()->whoamiGet("client_id"), $this->getId(), $cpw);
|
||||
}
|
||||
|
||||
$this->execute("plugincmd", array("name" => $plugin, "data" => $data, "targetmode" => $subscribed ? TeamSpeak3::PLUGINCMD_CHANNEL_SUBSCRIBED : TeamSpeak3::PLUGINCMD_CHANNEL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
if($this->getParent()->getLoadClientlistFirst())
|
||||
{
|
||||
foreach($this->clientList() as $client)
|
||||
{
|
||||
if($client["cid"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->subChannelList() as $channel)
|
||||
{
|
||||
if($channel["pid"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $channel;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($this->subChannelList() as $channel)
|
||||
{
|
||||
if($channel["pid"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $channel;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->clientList() as $client)
|
||||
{
|
||||
if($client["cid"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeInfo()
|
||||
{
|
||||
$this->nodeInfo = array_merge($this->nodeInfo, $this->execute("channelinfo", array("cid" => $this->getId()))->toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_ch" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
if($this["channel_maxclients"] != -1 && $this["channel_maxclients"] <= $this["total_clients"])
|
||||
{
|
||||
return "channel_full";
|
||||
}
|
||||
elseif($this["channel_flag_password"])
|
||||
{
|
||||
return "channel_pass";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "channel_open";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "#";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["channel_name"];
|
||||
}
|
||||
}
|
||||
|
276
lib/ts3phpframework/libraries/TeamSpeak3/Node/Channelgroup.php
Normal file
276
lib/ts3phpframework/libraries/TeamSpeak3/Node/Channelgroup.php
Normal file
@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Channelgroup.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Channelgroup
|
||||
* @brief Class describing a TeamSpeak 3 channel group and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Channelgroup extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Channelgroup constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Channelgroup
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "cgid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid groupID", 0xA00);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the channel group specified.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function rename($name)
|
||||
{
|
||||
$this->getParent()->channelGroupRename($this->getId(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the channel group. If $force is set to TRUE, the channel group will be
|
||||
* deleted even if there are clients within.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->channelGroupDelete($this->getId(), $force);
|
||||
|
||||
unset($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the channel group and returns the new groups ID.
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer $tcgid
|
||||
* @param integer $type
|
||||
* @return integer
|
||||
*/
|
||||
public function copy($name = null, $tcgid = 0, $type = TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
{
|
||||
return $this->getParent()->channelGroupCopy($this->getId(), $name, $tcgid, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions assigned to the channel group.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->channelGroupPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the channel group. Multiple permissions
|
||||
* can be added by providing the two parameters of each permission in separate arrays.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue)
|
||||
{
|
||||
$this->getParent()->channelGroupPermAssign($this->getId(), $permid, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the channel group. Multiple
|
||||
* permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->channelGroupPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of clients assigned to the server group specified.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function clientList()
|
||||
{
|
||||
return $this->getParent()->channelGroupClientList($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for privilegeKeyCreate().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function tokenCreate($cid, $description = null, $customset = null)
|
||||
{
|
||||
return $this->privilegeKeyCreate($cid, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new privilege key (token) for the channel group and returns the key.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param string $description
|
||||
* @param string $customset
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function privilegeKeyCreate($cid, $description = null, $customset = null)
|
||||
{
|
||||
return $this->getParent()->privilegeKeyCreate(TeamSpeak3::TOKEN_CHANNELGROUP, $this->getId(), $cid, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients residing in the channel group on the virtual server.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
foreach($this as $client)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
catch(TeamSpeak3_Adapter_ServerQuery_Exception $e)
|
||||
{
|
||||
/* ERROR_client_invalid_id */
|
||||
if($e->getCode() != 0x0200) throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the channel groups icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("iconid") || $this["iconid"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if($client["client_channel_group_id"] == $this->getId())
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_cg" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return "group_channel";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["name"];
|
||||
}
|
||||
}
|
||||
|
441
lib/ts3phpframework/libraries/TeamSpeak3/Node/Client.php
Normal file
441
lib/ts3phpframework/libraries/TeamSpeak3/Node/Client.php
Normal file
@ -0,0 +1,441 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Client.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Client
|
||||
* @brief Class describing a TeamSpeak 3 client and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Client extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Client constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Adapter_ServerQuery_Exception
|
||||
* @return TeamSpeak3_Node_Client
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "clid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the clients properties using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modify(array $properties)
|
||||
{
|
||||
$properties["clid"] = $this->getId();
|
||||
|
||||
$this->execute("clientedit", $properties);
|
||||
$this->resetNodeInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the clients properties using given properties.
|
||||
*
|
||||
* @param array $properties
|
||||
* @return void
|
||||
*/
|
||||
public function modifyDb(array $properties)
|
||||
{
|
||||
$this->getParent()->clientModifyDb($this["client_database_id"], $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the clients properties from the database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteDb()
|
||||
{
|
||||
$this->getParent()->clientDeleteDb($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of properties from the database for the client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function infoDb()
|
||||
{
|
||||
return $this->getParent()->clientInfoDb($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to the client.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(), "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the client to another channel.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param string $cpw
|
||||
* @return void
|
||||
*/
|
||||
public function move($cid, $cpw = null)
|
||||
{
|
||||
$this->getParent()->clientMove($this->getId(), $cid, $cpw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks the client from his currently joined channel or from the server.
|
||||
*
|
||||
* @param integer $reasonid
|
||||
* @param string $reasonmsg
|
||||
* @return void
|
||||
*/
|
||||
public function kick($reasonid = TeamSpeak3::KICK_CHANNEL, $reasonmsg = null)
|
||||
{
|
||||
$this->getParent()->clientKick($this->getId(), $reasonid, $reasonmsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a poke message to the client.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function poke($msg)
|
||||
{
|
||||
$this->getParent()->clientPoke($this->getId(), $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param integer $timeseconds
|
||||
* @param string $reason
|
||||
* @return array
|
||||
*/
|
||||
public function ban($timeseconds = null, $reason = null)
|
||||
{
|
||||
return $this->getParent()->clientBan($this->getId(), $timeseconds, $reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of custom properties for the client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function customInfo()
|
||||
{
|
||||
return $this->getParent()->customInfo($this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the permission overview of the client.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @return array
|
||||
*/
|
||||
public function permOverview($cid)
|
||||
{
|
||||
return $this->execute("permoverview", array("cldbid" => $this["client_database_id"], "cid" => $cid, "permid" => 0))->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions defined for the client.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->clientPermList($this["client_database_id"], $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the client. Multiple permissions can be added by providing
|
||||
* the three parameters of each permission.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @param integer $permskip
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue, $permskip = FALSE)
|
||||
{
|
||||
$this->getParent()->clientPermAssign($this["client_database_id"], $permid, $permvalue, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue, $permskip = FALSE)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from a client. Multiple permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->clientPermRemove($this["client_database_id"], $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the channel group of a client to the ID specified.
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param integer $cgid
|
||||
* @return void
|
||||
*/
|
||||
public function setChannelGroup($cid, $cgid)
|
||||
{
|
||||
$this->getParent()->clientSetChannelGroup($this["client_database_id"], $cid, $cgid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the client to the server group specified with $sgid.
|
||||
*
|
||||
* @param integer $sgid
|
||||
* @return void
|
||||
*/
|
||||
public function addServerGroup($sgid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientAdd($sgid, $this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the client from the server group specified with $sgid.
|
||||
*
|
||||
* @param integer $sgid
|
||||
* @return void
|
||||
*/
|
||||
public function remServerGroup($sgid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientDel($sgid, $this["client_database_id"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the possible name of the clients avatar.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function avatarGetName()
|
||||
{
|
||||
return new TeamSpeak3_Helper_String("/avatar_" . $this["client_base64HashClientUID"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the clients avatar file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function avatarDownload()
|
||||
{
|
||||
if($this["client_flag_avatar"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->avatarGetName());
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of client connections using the same identity as this client.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getClones()
|
||||
{
|
||||
return $this->execute("clientgetids", array("cluid" => $this["client_unique_identifier"]))->toAssocArray("clid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the revision/build number from the clients version string.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getRev()
|
||||
{
|
||||
return $this["client_type"] ? null : $this["client_version"]->section("[", 1)->filterDigits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all server and channel groups the client is currently residing in.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function memberOf()
|
||||
{
|
||||
$groups = array($this->getParent()->channelGroupGetById($this["client_channel_group_id"]));
|
||||
|
||||
foreach(explode(",", $this["client_servergroups"]) as $sgid)
|
||||
{
|
||||
$groups[] = $this->getParent()->serverGroupGetById($sgid);
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the clients icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("client_icon_id") || $this["client_icon_id"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("client_icon_id"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a plugin command to the client.
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function sendPluginCmd($plugin, $data)
|
||||
{
|
||||
$this->execute("plugincmd", array("name" => $plugin, "data" => $data, "targetmode" => TeamSpeak3::PLUGINCMD_CLIENT, "target" => $this->getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeInfo()
|
||||
{
|
||||
if($this->offsetExists("client_type") && $this["client_type"] == 1) return;
|
||||
|
||||
$this->nodeInfo = array_merge($this->nodeInfo, $this->execute("clientinfo", array("clid" => $this->getId()))->toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_cl" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
if($this["client_type"])
|
||||
{
|
||||
return "client_query";
|
||||
}
|
||||
elseif($this["client_away"])
|
||||
{
|
||||
return "client_away";
|
||||
}
|
||||
elseif(!$this["client_output_hardware"])
|
||||
{
|
||||
return "client_snd_disabled";
|
||||
}
|
||||
elseif($this["client_output_muted"])
|
||||
{
|
||||
return "client_snd_muted";
|
||||
}
|
||||
elseif(!$this["client_input_hardware"])
|
||||
{
|
||||
return "client_mic_disabled";
|
||||
}
|
||||
elseif($this["client_input_muted"])
|
||||
{
|
||||
return "client_mic_muted";
|
||||
}
|
||||
elseif($this["client_is_channel_commander"])
|
||||
{
|
||||
return $this["client_flag_talking"] ? "client_cc_talk" : "client_cc_idle";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this["client_flag_talking"] ? "client_talk" : "client_idle";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "@";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["client_nickname"];
|
||||
}
|
||||
}
|
||||
|
32
lib/ts3phpframework/libraries/TeamSpeak3/Node/Exception.php
Normal file
32
lib/ts3phpframework/libraries/TeamSpeak3/Node/Exception.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Exception.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Exception
|
||||
* @brief Enhanced exception class for TeamSpeak3_Node_Abstract objects.
|
||||
*/
|
||||
class TeamSpeak3_Node_Exception extends TeamSpeak3_Exception {}
|
1202
lib/ts3phpframework/libraries/TeamSpeak3/Node/Host.php
Normal file
1202
lib/ts3phpframework/libraries/TeamSpeak3/Node/Host.php
Normal file
File diff suppressed because it is too large
Load Diff
2536
lib/ts3phpframework/libraries/TeamSpeak3/Node/Server.php
Normal file
2536
lib/ts3phpframework/libraries/TeamSpeak3/Node/Server.php
Normal file
File diff suppressed because it is too large
Load Diff
300
lib/ts3phpframework/libraries/TeamSpeak3/Node/Servergroup.php
Normal file
300
lib/ts3phpframework/libraries/TeamSpeak3/Node/Servergroup.php
Normal file
@ -0,0 +1,300 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* TeamSpeak 3 PHP Framework
|
||||
*
|
||||
* $Id: Servergroup.php 06/06/2016 22:27:13 scp@Svens-iMac $
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package TeamSpeak3
|
||||
* @version 1.1.24
|
||||
* @author Sven 'ScP' Paulsen
|
||||
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TeamSpeak3_Node_Servergroup
|
||||
* @brief Class describing a TeamSpeak 3 server group and all it's parameters.
|
||||
*/
|
||||
class TeamSpeak3_Node_Servergroup extends TeamSpeak3_Node_Abstract
|
||||
{
|
||||
/**
|
||||
* The TeamSpeak3_Node_Servergroup constructor.
|
||||
*
|
||||
* @param TeamSpeak3_Node_Server $server
|
||||
* @param array $info
|
||||
* @param string $index
|
||||
* @throws TeamSpeak3_Node_Exception
|
||||
* @return TeamSpeak3_Node_Servergroup
|
||||
*/
|
||||
public function __construct(TeamSpeak3_Node_Server $server, array $info, $index = "sgid")
|
||||
{
|
||||
$this->parent = $server;
|
||||
$this->nodeInfo = $info;
|
||||
|
||||
if(!array_key_exists($index, $this->nodeInfo))
|
||||
{
|
||||
throw new TeamSpeak3_Node_Exception("invalid groupID", 0xA00);
|
||||
}
|
||||
|
||||
$this->nodeId = $this->nodeInfo[$index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames the server group specified.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function rename($name)
|
||||
{
|
||||
$this->getParent()->serverGroupRename($this->getId(), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the server group. If $force is set to 1, the server group will be
|
||||
* deleted even if there are clients within.
|
||||
*
|
||||
* @param boolean $force
|
||||
* @return void
|
||||
*/
|
||||
public function delete($force = FALSE)
|
||||
{
|
||||
$this->getParent()->serverGroupDelete($this->getId(), $force);
|
||||
|
||||
unset($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the server group and returns the new groups ID.
|
||||
*
|
||||
* @param string $name
|
||||
* @param integer $tsgid
|
||||
* @param integer $type
|
||||
* @return integer
|
||||
*/
|
||||
public function copy($name = null, $tsgid = 0, $type = TeamSpeak3::GROUP_DBTYPE_REGULAR)
|
||||
{
|
||||
return $this->getParent()->serverGroupCopy($this->getId(), $name, $tsgid, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of permissions assigned to the server group.
|
||||
*
|
||||
* @param boolean $permsid
|
||||
* @return array
|
||||
*/
|
||||
public function permList($permsid = FALSE)
|
||||
{
|
||||
return $this->getParent()->serverGroupPermList($this->getId(), $permsid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of specified permissions to the server group. Multiple permissions
|
||||
* can be added by providing the four parameters of each permission in separate arrays.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @param integer $permvalue
|
||||
* @param integer $permnegated
|
||||
* @param integer $permskip
|
||||
* @return void
|
||||
*/
|
||||
public function permAssign($permid, $permvalue, $permnegated = FALSE, $permskip = FALSE)
|
||||
{
|
||||
$this->getParent()->serverGroupPermAssign($this->getId(), $permid, $permvalue, $permnegated, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permAssign().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permAssignByName($permname, $permvalue, $permnegated = FALSE, $permskip = FALSE)
|
||||
{
|
||||
$this->permAssign($permname, $permvalue, $permnegated, $permskip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a set of specified permissions from the server group. Multiple
|
||||
* permissions can be removed at once.
|
||||
*
|
||||
* @param integer $permid
|
||||
* @return void
|
||||
*/
|
||||
public function permRemove($permid)
|
||||
{
|
||||
$this->getParent()->serverGroupPermRemove($this->getId(), $permid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for permRemove().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function permRemoveByName($permname)
|
||||
{
|
||||
$this->permRemove($permname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of clients assigned to the server group specified.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function clientList()
|
||||
{
|
||||
return $this->getParent()->serverGroupClientList($this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a client to the server group specified. Please note that a client cannot be
|
||||
* added to default groups or template groups.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @return void
|
||||
*/
|
||||
public function clientAdd($cldbid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientAdd($this->getId(), $cldbid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a client from the server group.
|
||||
*
|
||||
* @param integer $cldbid
|
||||
* @return void
|
||||
*/
|
||||
public function clientDel($cldbid)
|
||||
{
|
||||
$this->getParent()->serverGroupClientDel($this->getId(), $cldbid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for privilegeKeyCreate().
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function tokenCreate($description = null, $customset = null)
|
||||
{
|
||||
return $this->privilegeKeyCreate($description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new privilege key (token) for the server group and returns the key.
|
||||
*
|
||||
* @param string $description
|
||||
* @param string $customset
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function privilegeKeyCreate($description = null, $customset = null)
|
||||
{
|
||||
return $this->getParent()->privilegeKeyCreate(TeamSpeak3::TOKEN_SERVERGROUP, $this->getId(), 0, $description, $customset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a text message to all clients residing in the server group on the virtual server.
|
||||
*
|
||||
* @param string $msg
|
||||
* @return void
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
foreach($this as $client)
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => TeamSpeak3::TEXTMSG_CLIENT));
|
||||
}
|
||||
catch(TeamSpeak3_Adapter_ServerQuery_Exception $e)
|
||||
{
|
||||
/* ERROR_client_invalid_id */
|
||||
if($e->getCode() != 0x0200) throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and returns the server groups icon file content.
|
||||
*
|
||||
* @return TeamSpeak3_Helper_String
|
||||
*/
|
||||
public function iconDownload()
|
||||
{
|
||||
if($this->iconIsLocal("iconid") || $this["iconid"] == 0) return;
|
||||
|
||||
$download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("iconid"));
|
||||
$transfer = TeamSpeak3::factory("filetransfer://" . (strstr($download["host"], ":") !== FALSE ? "[" . $download["host"] . "]" : $download["host"]) . ":" . $download["port"]);
|
||||
|
||||
return $transfer->download($download["ftkey"], $download["size"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
protected function fetchNodeList()
|
||||
{
|
||||
$this->nodeList = array();
|
||||
|
||||
foreach($this->getParent()->clientList() as $client)
|
||||
{
|
||||
if(in_array($this->getId(), explode(",", $client["client_servergroups"])))
|
||||
{
|
||||
$this->nodeList[] = $client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the node which can be used as a HTML property.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->getParent()->getUniqueId() . "_sg" . $this->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of a possible icon to display the node object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return "group_server";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a symbol representing the node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSymbol()
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this node.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this["name"];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user