X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=Uplink%2FP10_User.class.php;h=651c6ccd4b87139a4c67063ed4a1ac47f5d0d261;hb=ba724f8fe4ffd71406db9faa3612ef6fc5da612f;hp=bdc84e3bf157bd2e79430907831a7c782b83fcdc;hpb=8fc32c585446865b73c89859c35d1387fadbf9af;p=PHP-P10.git diff --git a/Uplink/P10_User.class.php b/Uplink/P10_User.class.php index bdc84e3..651c6cc 100644 --- a/Uplink/P10_User.class.php +++ b/Uplink/P10_User.class.php @@ -1,12 +1,10 @@ . * * * ************************************************************************ - * + * * Uplink/P10_User.class.php * * This class represents a IRC User * - ************************************************************************ - * accessable methods: - * - * static P10_User getUserByNum(String $numeric) - * searches and returns the User with the provided Numeric - * - * __construct(String $nick, String $numeric, P10_Server $server, int $connect_time, String $ident, String $realname, P10_ModeSet $modes) - * *** nothing to say here *** - * */ class P10_User { private static $static_users = array(); - - public static getUserByNum($numeric) { - if(array_key_exists($numeric, self::$static_servers)) { - return self::$static_servers[$numeric]; + + public static function getUserByNum($numeric) { + if(array_key_exists($numeric, self::$static_users)) { + return self::$static_users[$numeric]; } return NULL; } - - public static getUserByNick($nick) { + + public static function getUserByNick($nick) { $nick = strtolower($nick); foreach(self::$static_users as $user) { if(strtolower($user->getNick()) == $nick) { @@ -54,9 +42,14 @@ class P10_User { } return NULL; } - - + + public static function getAllUsers() { + return self::$static_users; + } + + private $numeric; + private $server; private $nick; private $ident; private $host; @@ -64,8 +57,10 @@ class P10_User { private $connect_time; private $modes; private $realname; - - public __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) { + private $channels = array(); + private $away = null; + + public function __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) { $this->nick = $nick; $this->numeric = $numeric; $this->server = $server; @@ -78,49 +73,104 @@ class P10_User { $server->addUser($this); self::$static_users[$numeric] = $this; } - + public function getNumeric() { return $this->numeric; } - + + public function getServer() { + return $this->server; + } + public function setNick($nick) { $this->nick = $nick; } - + public function getNick() { return $this->nick; } - + public function setIdent($ident) { $this->ident = $ident; } - + public function getIdent() { return $this->ident; } - + public function getHost() { return $this->host; } - + public function getIP() { return $this->ip; } - + public function getConnectTime() { return $this->connect_time; } - + public function getModes() { return $this->modes; } - + public function getRealname() { return $this->realname; } - + + public function setAway($away) { + $this->away = $away; + } + + public function getAway() { + return $this->away; + } + + public function isAway() { + return ($this->away != null); + } + public function quit($reason) { $this->server->delUser($this); + unset(self::$static_users[$this->numeric]); + foreach($this->channels as $channel) { + $channel->quitUser($this); + } + } + + public function addChannel($channel) { + $this->channels[strtolower($channel->getName())] = $channel; + } + + public function delChannel($channel) { + if(array_key_exists(strtolower($channel->getName()), $this->channels)) { + unset($this->channels[strtolower($channel->getName())]); + } else { + trigger_error("Tried to remove a Channel, that does NOT exist.", E_USER_WARNING); + } + } + + public function getChannels() { + return $this->channels; + } + + public function getChannelCount() { + return count($this->channels); + } + + public function isOnChannel($channel) { + return array_key_exists(strtolower($channel->getName()),$this->channels); + } + + public function getAuthNick() { + $authData = $this->getModes()->hasMode('r'); + $authnick = false; + if($authData) { + $authData = explode(':', $authData); + $authnick = $authData[0]; + } + + return $authnick; } }