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:
parent
01be519230
commit
0cceabdb88
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user