1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2025-01-22 02:00:40 +00:00

Add $user parameter to canMute() and canBan()

This commit is contained in:
Tim Düsterhus 2014-07-29 03:12:51 +02:00
parent 850bfacfbb
commit 64d2242cde

View File

@ -116,26 +116,36 @@ class Room extends \chat\data\CHATDatabaseObject implements \wcf\system\request\
/** /**
* Returns whether the user is allowed to mute other users in this room. * Returns whether the user is allowed to mute other users in this room.
* *
* @param \wcf\data\user\User $user
* @return boolean * @return boolean
*/ */
public function canMute() { public function canMute(\wcf\data\user\User $user = null) {
if (WCF::getSession()->getPermission('admin.chat.canManageSuspensions')) return true; if ($user === null) $user = WCF::getUser();
if (WCF::getSession()->getPermission('mod.chat.canGmute')) return true; if (!$user->userID) return false;
$user = new \wcf\data\user\UserProfile($user);
$ph = new \chat\system\permission\PermissionHandler(); if ($user->getPermission('admin.chat.canManageSuspensions')) return true;
if ($user->getPermission('mod.chat.canGmute')) return true;
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
return $ph->getPermission($this, 'mod.canMute'); return $ph->getPermission($this, 'mod.canMute');
} }
/** /**
* Returns whether the user is allowed to ban other users in this room. * Returns whether the user is allowed to ban other users in this room.
* *
* @param \wcf\data\user\User $user
* @return boolean * @return boolean
*/ */
public function canBan() { public function canBan(\wcf\data\user\User $user = null) {
if (WCF::getSession()->getPermission('admin.chat.canManageSuspensions')) return true; if ($user === null) $user = WCF::getUser();
if (WCF::getSession()->getPermission('mod.chat.canGban')) return true; if (!$user->userID) return false;
$user = new \wcf\data\user\UserProfile($user);
$ph = new \chat\system\permission\PermissionHandler(); if ($user->getPermission('admin.chat.canManageSuspensions')) return true;
if ($user->getPermission('mod.chat.canGban')) return true;
$ph = new \chat\system\permission\PermissionHandler($user->getDecoratedObject());
return $ph->getPermission($this, 'mod.canBan'); return $ph->getPermission($this, 'mod.canBan');
} }