fixed some warnings
[PHP-P10.git] / Uplink / P10_User.class.php
index a05f40bb664dded9c99a15c0e02b7ce08db4053d..f18080a576a9fa5e5f58980acb6b1f178eeb4768 100644 (file)
@@ -39,8 +39,8 @@ 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 +55,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 +69,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 +90,10 @@ class P10_User {
                return $this->numeric;
        }
        
+       public function getServer() {
+               return $this->server;
+       }
+       
        public function setNick($nick) {
                $this->nick = $nick;
        }
@@ -119,8 +130,47 @@ 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);
+               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);
        }
 }