automatically assign default (HIS) fakehost when user gets registered with umode...
[PHP-P10.git] / Uplink / Uplink.class.php
index 387f32406e207c71966fabda389990a0b783c4a5..6d73c62afd31105fe9b4a384d06b8402d5c5dd0a 100644 (file)
@@ -722,8 +722,17 @@ class Uplink {
                                return;
                        }
                        $targetUser->getModes()->setModes($modes);
-                       if($this->eventHandler)
+            $fakemodes = NULL;
+            if($targetUser->getModes()->hasMode("x") && $targetUser->getModes()->hasMode("r") && !$targetUser->getModes()->hasMode("f")) {
+                //user is registered and has umode +x set (automatically assign default fakehost)
+                $fakemodes = "+f ".$targetUser->getModes()->hasMode("r").".".$this->getSetting("his_usermask");
+                $targetUser->getModes()->setModes($fakemodes);
+            }
+                       if($this->eventHandler) {
                                $this->eventHandler->event_usermode($targetUser, $modes);
+                if($fakemodes)
+                    $this->eventHandler->event_usermode($targetUser, $fakemodes);
+            }
                }
        }
     
@@ -735,8 +744,17 @@ class Uplink {
                }
                $auth = $args[1];
                $user->getModes()->setModes("+r ".$auth);
-        if($this->eventHandler)
+        $fakemodes = NULL;
+        if($user->getModes()->hasMode("x") && !$user->getModes()->hasMode("f")) {
+            //user is registered and has umode +x set (automatically assign default fakehost)
+            $fakemodes = "+f ".$auth.".".$this->getSetting("his_usermask");
+            $user->getModes()->setModes($fakemodes);
+        }
+        if($this->eventHandler) {
             $this->eventHandler->event_usermode($user, "+r ".$auth);
+            if($fakemodes)
+                $this->eventHandler->event_usermode($user, $fakemodes);
+        }
        }
     
     private function recv_fakehost($from, $args) {
@@ -786,7 +804,7 @@ class Uplink {
             $priv_values =    array(P10_Channel::USERPRIV_OPED, P10_Channel::USERPRIV_HALFOP, P10_Channel::USERPRIV_VOICE );
             $priv_combinations = array();
             $sorted_users = array();
-            $combinations = expr(2, count($privs_to_burst)); //binary possibilities => 2^count($privs_to_burst)
+            $combinations = pow(2, count($privs_to_burst)); //binary possibilities => 2^count($privs_to_burst)
             for($i = 0; $i < $combinations; $i++) {
                 //make a binary number out of $i
                 $binary = decbin($i);
@@ -797,7 +815,7 @@ class Uplink {
                 for($j = 0; $j < count($privs_to_burst); $j++) {
                     if($binary[$j] == '1') {
                         $combination_name .= $privs_to_burst[$j];
-                        $combination_value .= $priv_values[$j];
+                        $combination_value += $priv_values[$j];
                     }
                 }
                 $priv_combinations[] = array("name" => $combination_name, "value" => $combination_value);
@@ -818,7 +836,7 @@ class Uplink {
                     if($userStr != "") $userStr.=",";
                     $userStr .= $user->getNumeric();
                     if(($i++) == 0 && $combination['value'] > 0) {
-                        $userStr .= $combination['name'];
+                        $userStr .= ":".$combination['name'];
                     }
                 }
             }
@@ -949,7 +967,7 @@ class Uplink {
                        $this->eventHandler->event_kick($user, $target, $channel, $reason);
                $channel->partUser($target, $reason);
                if(($this->flags & self::FLAG_CONNECTED))
-                       $this->send("K", $user->getNumeric(), $chanName, $target->getNumeric(), $reason);
+                       $this->send("K", $user->getNumeric(), $channel->getName(), $target->getNumeric(), $reason);
        }
        
        public function privmsg($user, $target, $message) {