X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Uplink%2FP10_Channel.class.php;h=bc8c152f690d086ca9dd36c634643296d14655d8;hp=a15548166c719916e28ea5ffaf2e9140bfc38aac;hb=5c6c3365d28144516f0ade183189b256d8de03bc;hpb=c695e03034950c4ccea2c6fcc1ee525116df96e0 diff --git a/Uplink/P10_Channel.class.php b/Uplink/P10_Channel.class.php index a155481..bc8c152 100644 --- a/Uplink/P10_Channel.class.php +++ b/Uplink/P10_Channel.class.php @@ -48,8 +48,17 @@ class P10_Channel { public static function getChannels() { return self::$static_channels; - } + } + public static function getChannelCount() { + return count(self::$static_channels); + } + + public static function recheckAllChannels() { + foreach(self::$static_channels as $channel) { + $channel->checkChannel(); + } + } private $name; private $topic; @@ -103,11 +112,18 @@ class P10_Channel { $user->addChannel($this); } + private function checkChannel() { + if(count($this->users) == 0 && !$this->modes->hasMode('z')) { + unset(self::$static_channels[strtolower($name)]); //drop empty channel + } + } + public function quitUser($user) { if(array_key_exists($user->getNumeric(), $this->users)) { unset($this->users[$user->getNumeric()]); unset($this->userPrivs[$user->getNumeric()]); //$user->delChannel($this) is not necessary because the user quits (the whole Object gets removed later) + $this->checkChannel(); } else { trigger_error("Tried to quit a User from a Channel it is not joined.", E_USER_WARNING); } @@ -118,6 +134,7 @@ class P10_Channel { unset($this->users[$user->getNumeric()]); unset($this->userPrivs[$user->getNumeric()]); $user->delChannel($this); + $this->checkChannel(); } else { trigger_error("Tried to part a User from a Channel it is not joined.", E_USER_WARNING); }