1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

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 a6cb0e1e0a
3 changed files with 22 additions and 6 deletions

View File

@ -43,12 +43,12 @@ public function __toString() {
} }
/** /**
* 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 * @param \wcf\data\user\User $user
* @return boolean * @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 === null) $user = WCF::getUser();
if (!$user->userID) return false; if (!$user->userID) return false;
$user = new \wcf\data\user\UserProfile($user); $user = new \wcf\data\user\UserProfile($user);
@ -60,6 +60,22 @@ public function canEnter(\wcf\data\user\User $user = null) {
if ($ph->getPermission($this, 'mod.canAlwaysEnter')) return true; if ($ph->getPermission($this, 'mod.canAlwaysEnter')) return true;
if ($ph->getPermission($this, 'mod.canBan')) 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; if (!$ph->getPermission($this, 'user.canEnter')) return false;
$suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject()); $suspensions = Suspension::getSuspensionsForUser($user->getDecoratedObject());

View File

@ -171,7 +171,7 @@ public function validateJoin() {
if ($room === null) throw new exception\UserInputException('roomID'); if ($room === null) throw new exception\UserInputException('roomID');
if (!$room->canEnter()) throw new exception\PermissionDeniedException(); 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)); $errorMessage = WCF::getLanguage()->getDynamicVariable('chat.global.error.join.full', array('room' => $room));
throw new exception\UserInputException('room', $errorMessage); 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> <title>{if $room}{$room} - {/if}{lang}chat.global.title{/lang} - {PAGE_TITLE|language}</title>
{include file='headInclude'} {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'} {include file='javascriptInclude' application='chat'}
<script data-relocate="true"> <script data-relocate="true">
//<![CDATA[ //<![CDATA[
@ -97,7 +97,7 @@
</head> </head>
<body id="tpl{$templateName|ucfirst}"> <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} {capture assign='sidebar'}{include application='chat' file='sidebar'}{/capture}
{include file='header' sandbox=false sidebarOrientation='right'} {include file='header' sandbox=false sidebarOrientation='right'}