X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Uplink%2FP10_Channel.class.php;h=4fe3a205ae27552f402a1d6e735e675d4f66d983;hp=a15548166c719916e28ea5ffaf2e9140bfc38aac;hb=0f30e96ae37491aee19e72b89cc54a6798d1f254;hpb=695da943d0443abe58d4c7bd7d171ca0107d83bc diff --git a/Uplink/P10_Channel.class.php b/Uplink/P10_Channel.class.php index a155481..4fe3a20 100644 --- a/Uplink/P10_Channel.class.php +++ b/Uplink/P10_Channel.class.php @@ -1,22 +1,19 @@ . * * * ************************************************************************ * @@ -24,15 +21,6 @@ * * This class represents a IRC Channel * - ************************************************************************ - * accessable methods: - * - * static P10_User getChannelByName(String $name) - * searches and returns the Channel with the provided name - * - * __construct(String $name) - * *** nothing to say here *** - * */ class P10_Channel { @@ -48,8 +36,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 +100,18 @@ class P10_Channel { $user->addChannel($this); } + private function checkChannel() { + if(count($this->users) == 0 && !$this->modes->hasMode('z')) { + unset(self::$static_channels[strtolower($this->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 +122,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); } @@ -136,6 +141,10 @@ class P10_Channel { } } + public function getUserCount() { + return count($this->users); + } + public function getUsers() { return $this->users; }