X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=Uplink%2FP10_Channel.class.php;h=e58882a7b8b2695508105c1cd06a7388381b79a2;hb=35ca2c6a291ed20b1a8cf073a8cd4d579ed48aff;hp=d38015b4a658e52e74f61917c568bce5035f6c32;hpb=7ee52d8a44c982d62baecf92cea6b266e8c2eb26;p=PHP-P10.git diff --git a/Uplink/P10_Channel.class.php b/Uplink/P10_Channel.class.php index d38015b..e58882a 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; @@ -57,7 +54,8 @@ class P10_Channel { private $create_time; private $users = array(); const USERPRIV_OPED = 0x0001; - const USERPRIV_VOICE = 0x0002; + const USERPRIV_HALFOP = 0x0002; + const USERPRIV_VOICE = 0x0004; private $userPrivs = array(); public function __construct($name) { @@ -83,6 +81,10 @@ class P10_Channel { return $this->topic; } + public function setCreateTime($time) { + $this->create_time = $time; + } + public function getCreateTime() { return $this->create_time; } @@ -93,17 +95,24 @@ class P10_Channel { $user->addChannel($this); } - public function burstUser($user, $opped, $voiced) { + public function burstUser($user, $opped, $halfopped, $voiced) { $this->users[$user->getNumeric()] = $user; - $this->userPrivs[$user->getNumeric()] = ($opped ? self::USERPRIV_OPED : 0) | ($voiced ? self::USERPRIV_VOICE : 0); + $this->userPrivs[$user->getNumeric()] = ($opped ? self::USERPRIV_OPED : 0) | ($halfopped ? self::USERPRIV_HALFOP : 0) | ($voiced ? self::USERPRIV_VOICE : 0); $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); } @@ -114,6 +123,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); } @@ -132,6 +142,10 @@ class P10_Channel { } } + public function getUserCount() { + return count($this->users); + } + public function getUsers() { return $this->users; }