added recv_join & recv_part
authorpk910 <philipp@zoelle1.de>
Tue, 26 Jul 2011 18:28:27 +0000 (20:28 +0200)
committerpk910 <philipp@zoelle1.de>
Tue, 26 Jul 2011 18:28:27 +0000 (20:28 +0200)
Uplink/P10_Channel.class.php
Uplink/Uplink.class.php

index d38015b4a658e52e74f61917c568bce5035f6c32..a15548166c719916e28ea5ffaf2e9140bfc38aac 100644 (file)
@@ -83,6 +83,10 @@ class P10_Channel {
                return $this->topic;
        }
        
+       public function setCreateTime($time) {
+               $this->create_time = $time;
+       }
+       
        public function getCreateTime() {
                return $this->create_time;
        }
index b91bf8a993b99e8fa55cea3a5bdfa60fa4feda58..cf9b34fab94a767b8dd228802eaa59b9d27cf49f 100644 (file)
@@ -214,6 +214,13 @@ class Uplink {
                        case "B":
                                $this->recv_burst($from, $arguments);
                                break;
+                       case "J":
+                       case "C":
+                               $this->recv_join($from, $arguments);
+                               break;
+                       case "L":
+                               $this->recv_part($from, $arguments);
+                               break;
                //default
                        default:
                                //unknown cmd
@@ -358,6 +365,7 @@ class Uplink {
                $channel = P10_Channel::getChannelByName($name);
                if($channel == null)
                        $channel = new P10_Channel($name);
+               $channel->setCreateTime($create_time);
                $modes = $channel->getModes();
                $userstr = $args[count($args)-1];
                $modeparamcount = count($args)-3;
@@ -400,6 +408,30 @@ class Uplink {
                $modes->parseModes(implode(array_slice($args, 2, $modeparamcount)));
        }
        
+       private function recv_join($from, $args) {
+               $user = P10_User::getUserByNum($from);
+               if($user == null) {
+                       trigger_error("Server tries to join an user that does not exist or was not found on recv_join.", E_USER_ERROR);
+                       return;
+               }
+               $channel = P10_Channel::getChannelByName($args[0]);
+               if($channel == null)
+                       $channel = new P10_Channel($args[0]);
+               $channel->joinUser($user);
+       }
+       
+       private function recv_part($from, $args) {
+               $user = P10_User::getUserByNum($from);
+               if($user == null) {
+                       trigger_error("Server tries to part an user that does not exist or was not found on recv_join.", E_USER_ERROR);
+                       return;
+               }
+               $channel = P10_Channel::getChannelByName($args[0]);
+               if($channel == null)
+                       $channel = new P10_Channel($args[0]);
+               $channel->partUser($user, $args[1]);
+       }
+       
        /********************************************************************************************
         *                                     SERVER FUNCTIONS                                     *
         ********************************************************************************************/