getPermission('mod.chat.canBan') || PermissionHandler::get($user)->getPermission($room, 'mod.canBan'); } /** * @inheritDoc */ public function getObjectTypeName() { return 'be.bastelstu.chat.suspension.ban'; } /** * @inheritDoc */ protected function checkPermissions($parameters, Room $room, UserProfile $user) { $permission = $user->getPermission('mod.chat.canBan'); if (!$this->isGlobally($parameters)) { $permission = $permission || PermissionHandler::get($user)->getPermission($room, 'mod.canBan'); } if (!$permission) throw new PermissionDeniedException(); } /** * @inheritDoc */ protected function afterCreate(Suspension $suspension, $parameters, Room $room, UserProfile $user) { parent::afterCreate($suspension, $parameters, $room, $user); $user = new \chat\data\user\User($suspension->getUser()); $rooms = [ ]; if ($suspension->getRoom() === null) { $rooms = $user->getRooms(); } else { if ($user->isInRoom($suspension->getRoom())) { $rooms = [ $suspension->getRoom() ]; } } foreach ($rooms as $room) { $parameters = [ 'user' => $suspension->getUser() , 'roomID' => $room->roomID ]; try { (new \chat\data\room\RoomAction([ ], 'leave', $parameters))->executeAction(); } catch (UserInputException $e) { // User already left } } } }