Core/RBAC: Create new permissions 'Allow channel chat between factions', 'Join channels without announce' (both need config option enabled and permission set) and 'Change channel settings without being channel moderator'
This commit is contained in:
1 parent
18562a43ba
commit
f67330e2ad
3 files changed
+58
-20
No files matched your search
@@ -0,0 +1,34 @@
|
||||
-- Add new permissions
|
||||
DELETE FROM `rbac_permissions` WHERE `id` IN (26, 46, 46);
|
||||
INSERT INTO `rbac_permissions` (`id`, `name`) VALUES
|
||||
(26, 'Allow channel chat between factions'),
|
||||
(46, 'Join channels without announce'),
|
||||
(46, 'Change channel settings without being channel moderator');
|
||||
|
||||
-- Add new role
|
||||
DELETE FROM `rbac_roles` WHERE `id` IN (30, 31, 32);
|
||||
INSERT INTO `rbac_roles` (`id`, `name`) VALUES
|
||||
(30, 'Allow channel chat between factions'),
|
||||
(31, 'Join channels without announce'),
|
||||
(32, 'Change channel settings without being channel moderator');
|
||||
|
||||
-- Add the permission to the role
|
||||
DELETE FROM `rbac_role_permissions` WHERE `roleId` IN (30, 31, 32);
|
||||
INSERT INTO `rbac_role_permissions` (`roleId`, `permissionId`) VALUES
|
||||
(30, 26),
|
||||
(31, 46),
|
||||
(32, 4645);
|
||||
|
||||
-- Add it to all GM+ groups
|
||||
DELETE FROM `rbac_role_permissions` WHERE `roleId` IN (30, 31, 32);
|
||||
INSERT INTO `rbac_group_roles` (`groupId`, `roleId`) VALUES
|
||||
(1, 30),
|
||||
(2, 30),
|
||||
(3, 30),
|
||||
(4, 30),
|
||||
(2, 31),
|
||||
(3, 31),
|
||||
(4, 31),
|
||||
(2, 32),
|
||||
(3, 32),
|
||||
(4, 32);
|
||||
@@ -66,6 +66,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_SKIP_CHECK_CHAT_SPAM = 22,
|
||||
RBAC_PERM_SKIP_CHECK_OVERSPEED_PING = 23,
|
||||
RBAC_PERM_TWO_SIDE_INTERACTION_CHAT = 25,
|
||||
RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL = 26,
|
||||
RBAC_PERM_TWO_SIDE_INTERACTION_MAIL = 27,
|
||||
RBAC_PERM_COMMANDS_SAVE_WITHOUT_DELAY = 30,
|
||||
RBAC_PERM_COMMANDS_USE_UNSTUCK_WITH_ARGS = 31,
|
||||
@@ -80,6 +81,8 @@ enum RBACPermissions
|
||||
RBAC_PERM_OPCODE_WORLD_TELEPORT = 42,
|
||||
RBAC_PERM_OPCODE_WHOIS = 43,
|
||||
RBAC_PERM_RECEIVE_GLOBAL_GM_TEXTMESSAGE = 44,
|
||||
RBAC_PERM_SILENTLY_JOIN_CHANNEL = 45,
|
||||
RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR = 46,
|
||||
RBAC_PERM_CHECK_FOR_LOWER_SECURITY = 47,
|
||||
RBAC_PERM_MAX
|
||||
};
|
||||
|
||||
@@ -180,7 +180,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
||||
|
||||
if (HasFlag(CHANNEL_FLAG_LFG) &&
|
||||
sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
|
||||
AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) &&
|
||||
AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && //FIXME: Move to RBAC
|
||||
player->GetGroup())
|
||||
{
|
||||
WorldPacket data;
|
||||
@@ -191,8 +191,8 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
||||
|
||||
player->JoinedChannel(this);
|
||||
|
||||
if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
|
||||
!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
|
||||
if (_announce && (!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ||
|
||||
!player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL)))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeJoined(&data, guid);
|
||||
@@ -252,8 +252,9 @@ void Channel::LeaveChannel(Player* player, bool send)
|
||||
bool changeowner = playersStore[guid].IsOwner();
|
||||
|
||||
playersStore.erase(guid);
|
||||
if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
|
||||
!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
|
||||
|
||||
if (_announce && (!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ||
|
||||
!player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL)))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeLeft(&data, guid);
|
||||
@@ -279,7 +280,6 @@ void Channel::LeaveChannel(Player* player, bool send)
|
||||
|
||||
void Channel::KickOrBan(Player const* player, std::string const& badname, bool ban)
|
||||
{
|
||||
AccountTypes sec = player->GetSession()->GetSecurity();
|
||||
uint64 good = player->GetGUID();
|
||||
|
||||
if (!IsOn(good))
|
||||
@@ -290,7 +290,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec))
|
||||
if (!playersStore[good].IsModerator() && !player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
@@ -310,7 +310,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
||||
|
||||
bool changeowner = _ownerGUID == victim;
|
||||
|
||||
if (!AccountMgr::IsGMAccount(sec) && changeowner && good != _ownerGUID)
|
||||
if (!player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && changeowner && good != _ownerGUID)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotOwner(&data);
|
||||
@@ -318,7 +318,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
||||
return;
|
||||
}
|
||||
|
||||
bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
|
||||
bool notify = !sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) || !player->GetSession()->HasPermission(RBAC_PERM_SILENTLY_JOIN_CHANNEL);
|
||||
|
||||
if (ban && !IsBanned(victim))
|
||||
{
|
||||
@@ -404,7 +404,7 @@ void Channel::Password(Player const* player, std::string const& pass)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()))
|
||||
if (!playersStore[guid].IsModerator() && !player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
@@ -424,7 +424,6 @@ void Channel::Password(Player const* player, std::string const& pass)
|
||||
void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bool set)
|
||||
{
|
||||
uint64 guid = player->GetGUID();
|
||||
uint32 sec = player->GetSession()->GetSecurity();
|
||||
|
||||
if (!IsOn(guid))
|
||||
{
|
||||
@@ -434,7 +433,7 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec))
|
||||
if (!playersStore[guid].IsModerator() && !player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
@@ -449,10 +448,11 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
|
||||
uint64 victim = newp ? newp->GetGUID() : 0;
|
||||
|
||||
if (!victim || !IsOn(victim) ||
|
||||
(player->GetTeam() != newp->GetTeam() && (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) ||
|
||||
!player->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL) ||
|
||||
!newp->GetSession()->HasPermission(RBAC_PERM_TWO_SIDE_INTERACTION_CHANNEL))))
|
||||
// allow make moderator from another team only if both is GMs
|
||||
// at this moment this only way to show channel post for GM from another team
|
||||
((!AccountMgr::IsGMAccount(sec) || !AccountMgr::IsGMAccount(newp->GetSession()->GetSecurity())) &&
|
||||
player->GetTeam() != newp->GetTeam() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakePlayerNotFound(&data, p2n);
|
||||
@@ -477,7 +477,6 @@ void Channel::SetMode(Player const* player, std::string const& p2n, bool mod, bo
|
||||
void Channel::SetOwner(Player const* player, std::string const& newname)
|
||||
{
|
||||
uint64 guid = player->GetGUID();
|
||||
uint32 sec = player->GetSession()->GetSecurity();
|
||||
|
||||
if (!IsOn(guid))
|
||||
{
|
||||
@@ -487,7 +486,7 @@ void Channel::SetOwner(Player const* player, std::string const& newname)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID)
|
||||
if (!player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR) && guid != _ownerGUID)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotOwner(&data);
|
||||
@@ -570,7 +569,6 @@ void Channel::List(Player const* player)
|
||||
void Channel::Announce(Player const* player)
|
||||
{
|
||||
uint64 guid = player->GetGUID();
|
||||
uint32 sec = player->GetSession()->GetSecurity();
|
||||
|
||||
if (!IsOn(guid))
|
||||
{
|
||||
@@ -580,7 +578,7 @@ void Channel::Announce(Player const* player)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec))
|
||||
if (!playersStore[guid].IsModerator() && !player->GetSession()->HasPermission(RBAC_PERM_CHANGE_CHANNEL_NOT_MODERATOR))
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotModerator(&data);
|
||||
@@ -605,6 +603,10 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
|
||||
if (what.empty())
|
||||
return;
|
||||
|
||||
uint8 chatTag = 0;
|
||||
if (Player* player = ObjectAccessor::FindPlayer(guid))
|
||||
chatTag = player->GetChatTag();
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
lang = LANG_UNIVERSAL;
|
||||
|
||||
@@ -633,8 +635,7 @@ void Channel::Say(uint64 guid, std::string const& what, uint32 lang)
|
||||
data << uint64(guid);
|
||||
data << uint32(what.size() + 1);
|
||||
data << what;
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
data << uint8(player ? player->GetChatTag() : 0);
|
||||
data << uint8(chatTag);
|
||||
|
||||
SendToAll(&data, !playersStore[guid].IsModerator() ? guid : false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user