2 /********************************* PHP-P10 ******************************
3 * P10 uplink class by pk910 (c)2011 pk910 *
4 ************************************************************************
7 * PHP-P10 is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with PHP-P10; if not, write to the Free Software Foundation, *
19 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 ************************************************************************
23 * Uplink/P10_User.class.php
25 * This class represents a IRC User
27 ************************************************************************
30 * static P10_User getUserByNum(String $numeric)
31 * searches and returns the User with the provided Numeric
33 * __construct(String $nick, String $numeric, P10_Server $server, int $connect_time, String $ident, String $realname, P10_ModeSet $modes)
34 * *** nothing to say here ***
39 private static $static_users = array();
41 public static function getUserByNum($numeric) {
42 if(array_key_exists($numeric, self::$static_users)) {
43 return self::$static_users[$numeric];
48 public static function getUserByNick($nick) {
49 $nick = strtolower($nick);
50 foreach(self::$static_users as $user) {
51 if(strtolower($user->getNick()) == $nick) {
65 private $connect_time;
70 public function __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) {
72 $this->numeric = $numeric;
73 $this->server = $server;
74 $this->connect_time = $connect_time;
75 $this->ident = $ident;
78 $this->realname = $realname;
79 $this->modes = $modes;
80 $server->addUser($this);
81 self::$static_users[$numeric] = $this;
84 public function getNumeric() {
85 return $this->numeric;
88 public function getServer() {
92 public function setNick($nick) {
96 public function getNick() {
100 public function setIdent($ident) {
101 $this->ident = $ident;
104 public function getIdent() {
108 public function getHost() {
112 public function getIP() {
116 public function getConnectTime() {
117 return $this->connect_time;
120 public function getModes() {
124 public function getRealname() {
125 return $this->realname;
128 public function quit($reason) {
129 $this->server->delUser($this);
130 foreach($this->channels as $channel) {
131 $channel->quitUser($this);
135 public function addChannel($channel) {
136 $this->channels[strtolower($channel->getName())] = $channel;
139 public function delChannel($channel) {
140 if(array_key_exists(strtolower($channel->getName()), $this->channels)) {
141 unset($this->channels[strtolower($channel->getName())]);
143 trigger_error("Tried to remove a Channel, that does NOT exist.", E_USER_WARNING);
147 public function getChannels() {
148 return $this->channels;
151 public function isOnChannel($channel) {
152 return array_key_exists(strtolower($channel->getName()),$this->channels);