X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Uplink%2FP10_User.class.php;h=752e8be6f856cc1ca0680447c5d948cb3b7b3d63;hp=a05f40bb664dded9c99a15c0e02b7ce08db4053d;hb=811bc0c7a1f583fb624a0f8c3601146e063c5a25;hpb=7b82a138057d641a0ce2205b611fba2079f7500e diff --git a/Uplink/P10_User.class.php b/Uplink/P10_User.class.php index a05f40b..752e8be 100644 --- a/Uplink/P10_User.class.php +++ b/Uplink/P10_User.class.php @@ -1,22 +1,19 @@ . * * * ************************************************************************ * @@ -24,23 +21,14 @@ * * 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 function getUserByNum($numeric) { - if(array_key_exists($numeric, self::$static_servers)) { - return self::$static_servers[$numeric]; + if(array_key_exists($numeric, self::$static_users)) { + return self::$static_users[$numeric]; } return NULL; } @@ -55,8 +43,13 @@ class P10_User { return NULL; } + public static function getAllUsers() { + return self::$static_users; + } + private $numeric; + private $server; private $nick; private $ident; private $host; @@ -64,6 +57,8 @@ class P10_User { private $connect_time; private $modes; private $realname; + private $channels = array(); + private $away = null; public function __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) { $this->nick = $nick; @@ -83,6 +78,10 @@ class P10_User { return $this->numeric; } + public function getServer() { + return $this->server; + } + public function setNick($nick) { $this->nick = $nick; } @@ -119,8 +118,48 @@ class P10_User { 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); } }