continued BotLoader, added ModManager.class.php & timers
[PHP-P10.git] / Uplink / Uplink.class.php
index d7d40fa86b3e4100ee10a4a42f4bf4907e111c89..867cb8587da7e40752c344a007e31276685a717d 100644 (file)
@@ -142,6 +142,15 @@ class Uplink {
                }
        }
        
+       public function shutdown() {
+               if($this->client->connected()) {
+                       if(($this->flags & self::FLAG_P10SESSION)) {
+                               $this->send("SQ", "Shutdown requested.");
+                       }
+                       $this->client->disconnect();
+               }
+       }
+       
        public function setUplinkHost($host, $port, $ssl = false, $bind = null) {
                $this->setSetting("host", $host);
                $this->setSetting("port", $port);
@@ -728,6 +737,7 @@ class Uplink {
                        $numeric = substr($this->server->getNumeric(),0,2).Numerics::intToNum($this->last_local_numeric, 3);
                }
                $this->last_local_numeric++;
+               $modes = new P10_UserModeSet($modes);
                $user = new P10_User($nick, $numeric, $this->server, time(), $ident, $host, $ip, $realname, $modes);
                if(($this->flags & self::FLAG_CONNECTED)) {
                        $ip = Numerics::numericFromIP($user->getIP());
@@ -756,7 +766,7 @@ class Uplink {
                }
        }
        
-       public function join($user, $chanName) {
+       public function join($user, $chanName, $privs = 0) {
                if(!is_a($user, "P10_User") || !($user->getServer() === $this->server))
                        return ERR_INVALID_USER;
                if($chanName[0] != "#")
@@ -767,6 +777,15 @@ class Uplink {
                $channel->joinUser($user);
                if(($this->flags & self::FLAG_CONNECTED))
                        $this->send("J", $user->getNumeric(), $chanName, time(), 0);
+               if($privs != 0) {
+                       $channel->setUserPrivs($user, $privs);
+                       if(($this->flags & self::FLAG_CONNECTED)) {
+                               $modestr = "+".(($privs & P10_Channel::USERPRIV_OPED) ? "o" : "").(($privs & P10_Channel::USERPRIV_VOICE) ? "v" : "");
+                               $modestr .= (($privs & P10_Channel::USERPRIV_OPED) ? " ".$user->getNumeric() : "");
+                               $modestr .= (($privs & P10_Channel::USERPRIV_VOICE) ? " ".$user->getNumeric() : "");
+                               $this->send("OM", $user->getNumeric(), $chanName, $modestr);
+                       }
+               }
                if($this->eventHandler)
                        $this->eventHandler->event_join($user, $channel, false);
        }