1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-22 21:40:08 +00:00

Check whether the user may write.

This commit is contained in:
Tim Düsterhus 2012-03-24 21:47:03 +01:00
parent 01be519230
commit 0cceabdb88
2 changed files with 24 additions and 12 deletions

View File

@ -37,6 +37,29 @@ public function __toString() {
return $this->getTitle();
}
/**
* Returns whether the user is allowed to enter the room.
*
* @return boolean
*/
public function canEnter() {
$ph = \wcf\system\chat\permission\ChatPermissionHandler::getInstance();
return $ph->getPermission($this, 'user.canEnter') || $ph->getPermission($this, 'mod.canAlwaysEnter');
}
/**
* Returns whether the user is allowed to write messages in this room.
*
* @return boolean
*/
public function canWrite() {
$ph = \wcf\system\chat\permission\ChatPermissionHandler::getInstance();
return $ph->getPermission($this, 'user.canWrite') || $ph->getPermission($this, 'mod.canAlwaysWrite');
}
/**
* Returns the number of users currently active in this room.
*
@ -136,15 +159,4 @@ public function getUsers() {
return $stmt->fetchObjects('\wcf\data\user\User');
}
/**
* Returns whether the user is allowed to enter the room
*
* @return boolean
*/
public function canEnter() {
$ph = \wcf\system\chat\permission\ChatPermissionHandler::getInstance();
return $ph->getPermission($this, 'user.canEnter') || $ph->getPermission($this, 'mod.canAlwaysEnter');
}
}

View File

@ -38,7 +38,7 @@ public function readData() {
$this->room = chat\room\ChatRoom::getCache()->search($this->userData['roomID']);
if (!$this->room) throw new \wcf\system\exception\IllegalLinkException();
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
if (!$this->room->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
parent::readData();
}