Override max user restriction for mods

This commit is contained in:
Tim Düsterhus 2015-03-22 00:10:49 +01:00
parent 4790a3ddb8
commit c0f58a9ddb
3 changed files with 22 additions and 6 deletions

View File

@ -41,14 +41,14 @@ class Room extends \chat\data\CHATDatabaseObject implements \wcf\system\request\
public function __toString() {
return $this->getTitle();
}
/**
* Returns whether the user is allowed to enter the room.
* Returns whther the user is allowed to always enter the room.
*
* @param \wcf\data\user\User $user
* @return boolean
*/
public function canEnter(\wcf\data\user\User $user = null) {
public function canAlwaysEnter(\wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser();
if (!$user->userID) return false;
$user = new \wcf\data\user\UserProfile($user);
@ -59,7 +59,23 @@ class Room extends \chat\data\CHATDatabaseObject implements \wcf\system\request\
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
if ($ph->getPermission($this, 'mod.canAlwaysEnter')) return true;
if ($ph->getPermission($this, 'mod.canBan')) return true;
return false;
}
/**
* Returns whether the user is allowed to enter the room.
*
* @param \wcf\data\user\User $user
* @return boolean
*/
public function canEnter(\wcf\data\user\User $user = null) {
if ($user === null) $user = WCF::getUser();
if (!$user->userID) return false;
if ($this->canAlwaysEnter($user)) return true;
$user = new \wcf\data\user\UserProfile($user);
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
if (!$ph->getPermission($this, 'user.canEnter')) return false;
$suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject());

View File

@ -171,7 +171,7 @@ class RoomAction extends \wcf\data\AbstractDatabaseObjectAction implements \wcf\
if ($room === null) throw new exception\UserInputException('roomID');
if (!$room->canEnter()) throw new exception\PermissionDeniedException();
if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers) {
if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers && !$room->canAlwaysEnter()) {
$errorMessage = WCF::getLanguage()->getDynamicVariable('chat.global.error.join.full', array('room' => $room));
throw new exception\UserInputException('room', $errorMessage);

View File

@ -4,7 +4,7 @@
<title>{if $room}{$room} - {/if}{lang}chat.global.title{/lang} - {PAGE_TITLE|language}</title>
{include file='headInclude'}
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers)}
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers || $room->canAlwaysEnter())}
{include file='javascriptInclude' application='chat'}
<script data-relocate="true">
//<![CDATA[
@ -97,7 +97,7 @@
</head>
<body id="tpl{$templateName|ucfirst}">
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers)}
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers || $room->canAlwaysEnter())}
{capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture}
{include file='header' sandbox=false sidebarOrientation='right'}