burst only channels we've users in
[PHP-P10.git] / Uplink / Uplink.class.php
index 14585f6901fc5a7b11b253ad7a97b299c1143358..041d1c6efac13850f1245c11298a82c5425403cd 100644 (file)
@@ -276,6 +276,13 @@ class Uplink {
                        case "W":
                                $this->recv_whois($from, $arguments);
                                break;
+                       case "A":
+                               $this->recv_away($from, $arguments);
+                               break;
+                       case "M":
+                       case "OM":
+                               $this->recv_mode($from, $arguments);
+                               break;
                //default
                        default:
                                //unknown cmd
@@ -356,6 +363,7 @@ class Uplink {
        
        private function recv_ping($from, $args) {
                $this->send("Z", $args[0]); //simply PONG
+               P10_Channel::recheckAllChannels();
        }
        
        private function recv_nick($from, $args) {
@@ -654,6 +662,45 @@ class Uplink {
                $this->send("318", $from, $args[1]);
        }
        
+       private function recv_away($from, $args) {
+               $user = P10_User::getUserByNum($from);
+               if($user == null) {
+                       trigger_error("Server tries to send an away command from an user that does not exist or was not found on recv_away.", E_USER_ERROR);
+                       return;
+               }
+               if(count($args) > 0) {
+                       $user->setAway($args[0]);
+               } else {
+                       $user->setAway(null);
+               }
+       }
+       
+       private function recv_mode($from, $args) {
+               $user = P10_User::getUserByNum($from);
+               if($user == null) {
+                       trigger_error("Server tries to send a modechange from an user that does not exist or was not found on recv_mode.", E_USER_ERROR);
+                       return;
+               }
+               $modes = implode(" ",array_slice($args,1));
+               if($args[0][0] == "#") {
+                       $channel = P10_Channel::getChannelByName($args[0]);
+                       if($channel == null)
+                               $channel = new P10_Channel($args[0]);
+                       $channel->getModes()->setModes($modes);
+                       if($this->eventHandler)
+                               $this->eventHandler->event_chanmode($user, $channel, $modes);
+               } else {
+                       $targetUser = P10_User::getUserByNum($args[0]);
+                       if($targetUser == null) {
+                               trigger_error("Server tries to send a mode to an user that does not exist or was not found on recv_mode.", E_USER_ERROR);
+                               return;
+                       }
+                       $targetUser->getModes()->setModes($modes);
+                       if($this->eventHandler)
+                               $this->eventHandler->event_usermode($targetUser, $modes);
+               }
+       }
+       
        /********************************************************************************************
         *                                     SERVER FUNCTIONS                                     *
         ********************************************************************************************/
@@ -683,7 +730,7 @@ class Uplink {
                                $local_users = true;
                                $sorted_users[$strPrivs][] = $user;
                        }
-                       if(!$local_users && !$channel->getModes()->hasMode("z")) continue;
+                       if(!$local_users) continue;
                        $userStr = "";
                        foreach($sorted_users['-'] as $user) {
                                if($userStr != "") $userStr.=",";