checkChannel(); } } private $name; private $topic; private $modes; private $create_time; private $users = array(); const USERPRIV_OPED = 0x0001; const USERPRIV_VOICE = 0x0002; private $userPrivs = array(); public function __construct($name) { $this->name = $name; $this->modes = new P10_ChannelModeSet($this); $this->create_time = time(); self::$static_channels[strtolower($name)] = $this; } public function getName() { return $this->name; } public function getModes() { return $this->modes; } public function setTopic($topic) { $this->topic = $topic; } public function getTopic() { return $this->topic; } public function setCreateTime($time) { $this->create_time = $time; } public function getCreateTime() { return $this->create_time; } public function joinUser($user) { $this->users[$user->getNumeric()] = $user; $this->userPrivs[$user->getNumeric()] = 0; $user->addChannel($this); } public function burstUser($user, $opped, $voiced) { $this->users[$user->getNumeric()] = $user; $this->userPrivs[$user->getNumeric()] = ($opped ? self::USERPRIV_OPED : 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); } } public function partUser($user) { if(array_key_exists($user->getNumeric(), $this->users)) { 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); } } public function getUserPrivs($user) { if(array_key_exists($user->getNumeric(), $this->users)) { return $this->userPrivs[$user->getNumeric()]; } else return 0; } public function setUserPrivs($user, $privs) { if(array_key_exists($user->getNumeric(), $this->users)) { $this->userPrivs[$user->getNumeric()] = $privs; } } public function getUsers() { return $this->users; } } ?>