Skip to content

Commit c0f58a9

Browse files
committed
Override max user restriction for mods
1 parent 4790a3d commit c0f58a9

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

file/lib/data/room/Room.class.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ class Room extends \chat\data\CHATDatabaseObject implements \wcf\system\request\
4141
public function __toString() {
4242
return $this->getTitle();
4343
}
44-
44+
4545
/**
46-
* Returns whether the user is allowed to enter the room.
46+
* Returns whther the user is allowed to always enter the room.
4747
*
4848
* @param \wcf\data\user\User $user
4949
* @return boolean
5050
*/
51-
public function canEnter(\wcf\data\user\User $user = null) {
51+
public function canAlwaysEnter(\wcf\data\user\User $user = null) {
5252
if ($user === null) $user = WCF::getUser();
5353
if (!$user->userID) return false;
5454
$user = new \wcf\data\user\UserProfile($user);
@@ -59,7 +59,23 @@ public function canEnter(\wcf\data\user\User $user = null) {
5959
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
6060
if ($ph->getPermission($this, 'mod.canAlwaysEnter')) return true;
6161
if ($ph->getPermission($this, 'mod.canBan')) return true;
62+
63+
return false;
64+
}
65+
66+
/**
67+
* Returns whether the user is allowed to enter the room.
68+
*
69+
* @param \wcf\data\user\User $user
70+
* @return boolean
71+
*/
72+
public function canEnter(\wcf\data\user\User $user = null) {
73+
if ($user === null) $user = WCF::getUser();
74+
if (!$user->userID) return false;
75+
if ($this->canAlwaysEnter($user)) return true;
76+
$user = new \wcf\data\user\UserProfile($user);
6277

78+
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
6379
if (!$ph->getPermission($this, 'user.canEnter')) return false;
6480

6581
$suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject());

file/lib/data/room/RoomAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function validateJoin() {
171171
if ($room === null) throw new exception\UserInputException('roomID');
172172
if (!$room->canEnter()) throw new exception\PermissionDeniedException();
173173

174-
if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers) {
174+
if ($room->maxUsers && count($room->getUsers()) >= $room->maxUsers && !$room->canAlwaysEnter()) {
175175
$errorMessage = WCF::getLanguage()->getDynamicVariable('chat.global.error.join.full', array('room' => $room));
176176

177177
throw new exception\UserInputException('room', $errorMessage);

template/chat.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>{if $room}{$room} - {/if}{lang}chat.global.title{/lang} - {PAGE_TITLE|language}</title>
55

66
{include file='headInclude'}
7-
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers)}
7+
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers || $room->canAlwaysEnter())}
88
{include file='javascriptInclude' application='chat'}
99
<script data-relocate="true">
1010
//<![CDATA[
@@ -97,7 +97,7 @@
9797
</head>
9898
9999
<body id="tpl{$templateName|ucfirst}">
100-
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers)}
100+
{if $room && (!$room->maxUsers || $room->getUsers()|count < $room->maxUsers || $room->canAlwaysEnter())}
101101
{capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture}
102102
{include file='header' sandbox=false sidebarOrientation='right'}
103103

0 commit comments

Comments
 (0)