added recv_nick and P10_User
[PHP-P10.git] / Uplink / P10_User.class.php
diff --git a/Uplink/P10_User.class.php b/Uplink/P10_User.class.php
new file mode 100644 (file)
index 0000000..bdc84e3
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/********************************* PHP-P10 ******************************
+ *    P10 uplink class by pk910   (c)2011 pk910                         *
+ ************************************************************************
+ *                          Version 2 (OOP)                             *
+ *                                                                      *
+ * PHP-P10 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 2 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 PHP-P10; if not, write to the Free Software Foundation,   *
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.       *
+ *                                                                      *
+ ************************************************************************
+ * 
+ *  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];
+               }
+               return NULL;
+       }
+       
+       public static getUserByNick($nick) {
+               $nick = strtolower($nick);
+               foreach(self::$static_users as $user) {
+                       if(strtolower($user->getNick()) == $nick) {
+                               return $user;
+                       }
+               }
+               return NULL;
+       }
+       
+       
+       private $numeric;
+       private $nick;
+       private $ident;
+       private $host;
+       private $ip;
+       private $connect_time;
+       private $modes;
+       private $realname;
+       
+       public __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) {
+               $this->nick = $nick;
+               $this->numeric = $numeric;
+               $this->server = $server;
+               $this->connect_time = $connect_time;
+               $this->ident = $ident;
+               $this->host = $host;
+               $this->ip = $ip;
+               $this->realname = $realname;
+               $this->modes = $modes;
+               $server->addUser($this);
+               self::$static_users[$numeric] = $this;
+       }
+       
+       public function getNumeric() {
+               return $this->numeric;
+       }
+       
+       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 quit($reason) {
+               $this->server->delUser($this);
+       }
+}
+
+?>
\ No newline at end of file