From 4945ae17d3692f089ce6c996f6585a5e5b308e4d Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Thu, 29 Aug 2013 11:36:45 -0700 Subject: Initial commit for GroupBan - Lots of crap isn't working as intended yet. --- indra/newview/llpanelgroupbulkimpl.h | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 indra/newview/llpanelgroupbulkimpl.h (limited to 'indra/newview/llpanelgroupbulkimpl.h') diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h new file mode 100644 index 0000000000..74da542eb8 --- /dev/null +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -0,0 +1,87 @@ +/** +* @file llpanelgroupbulkimpl.h +* @brief Header file for llpanelgroupbulkimpl +* @author Baker@lindenlab.com +* +* $LicenseInfo:firstyear=2013&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2013, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ +#ifndef LL_LLPANELGROUPBULKIMPL_H +#define LL_LLPANELGROUPBULKIMPL_H + +#include "llpanel.h" +#include "lluuid.h" + +class LLAvatarName; +class LLNameListCtrl; +class LLTextBox; +class LLComboBox; + +class LLPanelGroupBulkImpl +{ +public: + LLPanelGroupBulkImpl(const LLUUID& group_id); + ~LLPanelGroupBulkImpl(); + + static void callbackClickAdd(void* userdata); + static void callbackClickRemove(void* userdata); + + static void callbackClickCancel(void* userdata); + + static void callbackSelect(LLUICtrl* ctrl, void* userdata); + static void callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data); + + static void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, void* user_data); + + void handleRemove(); + void handleSelection(); + + void addUsers(const std::vector& names, const uuid_vec_t& agent_ids); + void setGroupName(std::string name); + + +public: + LLUUID mGroupID; + + LLNameListCtrl* mBulkAgentList; + LLButton* mOKButton; + LLButton* mRemoveButton; + LLTextBox* mGroupName; + + std::string mLoadingText; + std::string mTooManySelected; + + void (*mCloseCallback)(void* data); + void* mCloseCallbackUserData; + boost::signals2::connection mAvatarNameCacheConnection; + + // The following are for the LLPanelGroupInvite subclass only. + // These aren't needed for LLPanelGroupBulkBan, but if we have to add another + // group bulk floater for some reason, we'll have these objects too. +public: + LLComboBox* mRoleNames; + std::string mOwnerWarning; + std::string mAlreadyInGroup; + bool mConfirmedOwnerInvite; +}; + +#endif // LL_LLPANELGROUPBULKIMPL_H + -- cgit v1.3 From 8bf4760552b61808d403885b6f9d562b1b8f7e6c Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Tue, 1 Oct 2013 15:58:39 -0700 Subject: Hand-merge of some viewer-release code --- indra/newview/llpanelgroupbulk.cpp | 36 +++++++++++++++++++++--------------- indra/newview/llpanelgroupbulkimpl.h | 23 +++++++++++++++-------- indra/newview/llpanelgroupinvite.cpp | 5 ++--- 3 files changed, 38 insertions(+), 26 deletions(-) (limited to 'indra/newview/llpanelgroupbulkimpl.h') diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index ed05a5c7d1..86ac1867df 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -172,6 +172,12 @@ void LLPanelGroupBulkImpl::handleRemove() if (selection.empty()) return; + std::vector::iterator iter; + for(iter = selection.begin(); iter != selection.end(); ++iter) + { + mInviteeIDs.erase((*iter)->getUUID()); + } + mBulkAgentList->deleteSelectedItems(); mRemoveButton->setEnabled(FALSE); @@ -195,26 +201,23 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector& names, const { std::string name; LLUUID id; + + if(names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES) + { + // Fail! Show a warning and don't add any names. + LLSD msg; + msg["MESSAGE"] = mTooManySelected; + LLNotificationsUtil::add("GenericAlert", msg); + return; + } + for (S32 i = 0; i < (S32)names.size(); ++i) { name = names[i]; id = agent_ids[i]; - // Make sure this agent isn't already in the list. - bool already_in_list = false; - std::vector items = mBulkAgentList->getAllData(); - std::vector::iterator iter = items.begin(); - for (; iter != items.end(); ++iter) - { - LLScrollListItem* item = *iter; - if (item->getUUID() == id) - { - already_in_list = true; - break; - } - } - if (already_in_list) + if(mInviteeIDs.find(id) != mInviteeIDs.end()) { continue; } @@ -225,7 +228,8 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector& names, const row["columns"][0]["value"] = name; mBulkAgentList->addElement(row); - + mInviteeIDs.insert(id); + // We've successfully added someone to the list. if(mOKButton && !mOKButton->getEnabled()) mOKButton->setEnabled(TRUE); @@ -254,6 +258,8 @@ LLPanelGroupBulk::~LLPanelGroupBulk() void LLPanelGroupBulk::clear() { + mImplementation->mInviteeIDs.clear(); + if(mImplementation->mBulkAgentList) mImplementation->mBulkAgentList->deleteAllItems(); diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 74da542eb8..3241c019de 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -1,6 +1,6 @@ /** * @file llpanelgroupbulkimpl.h -* @brief Header file for llpanelgroupbulkimpl +* @brief Class definition for implementation class of LLPanelGroupBulk * @author Baker@lindenlab.com * * $LicenseInfo:firstyear=2013&license=viewerlgpl$ @@ -35,6 +35,9 @@ class LLNameListCtrl; class LLTextBox; class LLComboBox; +////////////////////////////////////////////////////////////////////////// +// Implementation found in llpanelgroupbulk.cpp +////////////////////////////////////////////////////////////////////////// class LLPanelGroupBulkImpl { public: @@ -59,15 +62,19 @@ public: public: - LLUUID mGroupID; + static const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. - LLNameListCtrl* mBulkAgentList; - LLButton* mOKButton; - LLButton* mRemoveButton; - LLTextBox* mGroupName; + LLUUID mGroupID; - std::string mLoadingText; - std::string mTooManySelected; + LLNameListCtrl* mBulkAgentList; + LLButton* mOKButton; + LLButton* mRemoveButton; + LLTextBox* mGroupName; + + std::string mLoadingText; + std::string mTooManySelected; + + std::set mInviteeIDs; void (*mCloseCallback)(void* data); void* mCloseCallbackUserData; diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp index 43d94b36fc..19689e7f4b 100755 --- a/indra/newview/llpanelgroupinvite.cpp +++ b/indra/newview/llpanelgroupinvite.cpp @@ -80,7 +80,7 @@ LLPanelGroupInvite::LLPanelGroupInvite(const LLUUID& group_id) : LLPanelGroupBul void LLPanelGroupInvite::clear() { LLPanelGroupBulk::clear(); - + if(mImplementation->mRoleNames) { mImplementation->mRoleNames->clear(); @@ -225,8 +225,7 @@ void LLPanelGroupInvite::submit() role_member_pairs[item->getUUID()] = role_id; } - const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. - if (role_member_pairs.size() > MAX_GROUP_INVITES) + if (role_member_pairs.size() > LLPanelGroupBulkImpl::MAX_GROUP_INVITES) { // Fail! LLSD msg; -- cgit v1.3 From bfc274741ad97a2885a26ae35108e158aeb9525e Mon Sep 17 00:00:00 2001 From: Baker Linden Date: Tue, 6 May 2014 11:01:59 -0700 Subject: [MAINT-3834] Banning more than 100 residents causes multiple floaters - Removed superfluous floater dialogs from displaying Reviewer: Simon --- indra/newview/llpanelgroupbulk.cpp | 17 +++++++++++++---- indra/newview/llpanelgroupbulkimpl.h | 2 ++ .../skins/default/xui/en/panel_group_bulk_ban.xml | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpanelgroupbulkimpl.h') diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index 9d02b9b45a..1eafc5bd64 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -66,7 +66,8 @@ LLPanelGroupBulkImpl::LLPanelGroupBulkImpl(const LLUUID& group_id) : mRoleNames(NULL), mOwnerWarning(), mAlreadyInGroup(), - mConfirmedOwnerInvite(false) + mConfirmedOwnerInvite(false), + mListFullNotificationSent(false) {} LLPanelGroupBulkImpl::~LLPanelGroupBulkImpl() @@ -201,17 +202,24 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector& names, const { std::string name; LLUUID id; - - if(names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES) + if(mListFullNotificationSent) + { + return; + } + + if( !mListFullNotificationSent && + (names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES)) { + mListFullNotificationSent = true; + // Fail! Show a warning and don't add any names. LLSD msg; msg["MESSAGE"] = mTooManySelected; LLNotificationsUtil::add("GenericAlert", msg); return; } - + for (S32 i = 0; i < (S32)names.size(); ++i) { name = names[i]; @@ -407,6 +415,7 @@ void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) } } } + mImplementation->mListFullNotificationSent = false; mImplementation->addUsers(names, agent_ids); } diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 3241c019de..0bc834d67e 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -63,6 +63,7 @@ public: public: static const S32 MAX_GROUP_INVITES = 100; // Max invites per request. 100 to match server cap. + LLUUID mGroupID; @@ -88,6 +89,7 @@ public: std::string mOwnerWarning; std::string mAlreadyInGroup; bool mConfirmedOwnerInvite; + bool mListFullNotificationSent; }; #endif // LL_LLPANELGROUPBULKIMPL_H diff --git a/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml b/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml index bdea79f79d..8dd2719926 100644 --- a/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml +++ b/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml @@ -13,7 +13,7 @@ - Group Invitations not sent: too many Residents selected. Group Invitations are limited to 100 per request. + Group bans not sent: too many Residents selected. Group bans are limited to 100 per request. Date: Mon, 23 Jun 2014 18:39:53 +0300 Subject: MAINT-4175 FIXED [Group Bans] When banning a list of multiple avatars, if an already banned avatar is included in the list, no avatars are added to the ban list and those avatars already group members are not ejected from the group. --- indra/newview/llpanelgroupbulkban.cpp | 78 ++++++++++++++++++---- indra/newview/llpanelgroupbulkimpl.h | 2 + .../skins/default/xui/en/panel_group_bulk_ban.xml | 26 ++++++-- 3 files changed, 90 insertions(+), 16 deletions(-) (limited to 'indra/newview/llpanelgroupbulkimpl.h') diff --git a/indra/newview/llpanelgroupbulkban.cpp b/indra/newview/llpanelgroupbulkban.cpp index a31396737d..3499b45949 100644 --- a/indra/newview/llpanelgroupbulkban.cpp +++ b/indra/newview/llpanelgroupbulkban.cpp @@ -31,6 +31,7 @@ #include "llagent.h" #include "llavatarnamecache.h" +#include "llavataractions.h" #include "llfloateravatarpicker.h" #include "llbutton.h" #include "llcallingcard.h" @@ -100,6 +101,8 @@ BOOL LLPanelGroupBulkBan::postBuild() } mImplementation->mTooManySelected = getString("ban_selection_too_large"); + mImplementation->mBanNotPermitted = getString("ban_not_permitted"); + mImplementation->mCannotBanYourself = getString("cant_ban_yourself"); update(); return TRUE; @@ -117,6 +120,15 @@ void LLPanelGroupBulkBan::callbackClickSubmit(void* userdata) void LLPanelGroupBulkBan::submit() { + if (!gAgent.hasPowerInGroup(mImplementation->mGroupID, GP_GROUP_BAN_ACCESS)) + { + // Fail! Agent no longer have ban rights. + LLSD msg; + msg["MESSAGE"] = mImplementation->mBanNotPermitted; + LLNotificationsUtil::add("GenericAlert", msg); + (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); + return; + } std::vector banned_agent_list; std::vector agents = mImplementation->mBulkAgentList->getAllData(); std::vector::iterator iter = agents.begin(); @@ -137,32 +149,74 @@ void LLPanelGroupBulkBan::submit() return; } + // remove already banned users and yourself from request. + std::vector banned_avatar_names; + bool banning_self = FALSE; + std::vector::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), gAgent.getID()); + if (conflict != banned_agent_list.end()) + { + banned_agent_list.erase(conflict); + banning_self = TRUE; + } LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); if (group_datap) { BOOST_FOREACH(const LLGroupMgrGroupData::ban_list_t::value_type& group_ban_pair, group_datap->mBanList) { const LLUUID& group_ban_agent_id = group_ban_pair.first; - if (std::find(banned_agent_list.begin(), banned_agent_list.end(), group_ban_agent_id) != banned_agent_list.end()) + std::vector::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), group_ban_agent_id); + if (conflict != banned_agent_list.end()) { - // Fail! LLAvatarName av_name; LLAvatarNameCache::get(group_ban_agent_id, &av_name); + banned_avatar_names.push_back(av_name); - LLStringUtil::format_map_t string_args; - string_args["[RESIDENT]"] = av_name.getDisplayName(); - - LLSD msg; - msg["MESSAGE"] = getString("already_banned", string_args); - LLNotificationsUtil::add("GenericAlert", msg); - (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); - return; + banned_agent_list.erase(conflict); + if (banned_agent_list.size() == 0) + { + break; + } } } } - LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE | LLGroupMgr::BAN_UPDATE, banned_agent_list); - LLGroupMgr::getInstance()->sendGroupMemberEjects(mImplementation->mGroupID, banned_agent_list); + if (banned_agent_list.size() != 0) + { + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE | LLGroupMgr::BAN_UPDATE, banned_agent_list); + LLGroupMgr::getInstance()->sendGroupMemberEjects(mImplementation->mGroupID, banned_agent_list); + } + + // building notification + if (banned_avatar_names.size() > 0 || banning_self) + { + std::string reasons; + if(banned_avatar_names.size() > 0) + { + std::string names_string; + LLAvatarActions::buildResidentsString(banned_avatar_names, names_string); + LLStringUtil::format_map_t reason_args; + reason_args["[RESIDENTS]"] = names_string; + reasons = "\n " + getString("residents_already_banned", reason_args); + } + + if(banning_self) + { + reasons += "\n " + mImplementation->mCannotBanYourself; + } + + LLStringUtil::format_map_t msg_args; + msg_args["[REASONS]"] = reasons; + LLSD msg; + if (banned_agent_list.size() == 0) + { + msg["MESSAGE"] = getString("ban_failed", msg_args); + } + else + { + msg["MESSAGE"] = getString("partial_ban", msg_args); + } + LLNotificationsUtil::add("GenericAlert", msg); + } //then close (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 0bc834d67e..585b48c68f 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -74,6 +74,8 @@ public: std::string mLoadingText; std::string mTooManySelected; + std::string mBanNotPermitted; + std::string mCannotBanYourself; std::set mInviteeIDs; diff --git a/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml b/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml index 43449df1fd..31989f2e16 100644 --- a/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml +++ b/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml @@ -15,10 +15,28 @@ name="ban_selection_too_large"> Group bans not sent: too many Residents selected. Group bans are limited to 100 per request. - - Group Invitations not sent: resident '[RESIDENT]' already banned. - + + Group ban not sent: you do not have 'Manage ban list' ability. + + + Some group bans were not sent: +[REASONS] + + + Group bans were not sent: +[REASONS] + + + - The following resident(s) are already banned: [RESIDENTS]. + + + - You cannot ban yourself from a group. + Date: Wed, 25 Jun 2014 20:09:33 +0300 Subject: MAINT-4178 FIXED [Group Bans] The viewer allows you to attempt to ban when the ban list already contains 500 entries, which fails. --- indra/newview/llgroupmgr.h | 2 + indra/newview/llpanelgroupbulkban.cpp | 55 ++++++++++++++++++---- indra/newview/llpanelgroupbulkban.h | 2 + indra/newview/llpanelgroupbulkimpl.h | 1 + indra/newview/llpanelgrouproles.cpp | 33 ++++++++++++- indra/newview/llpanelgrouproles.h | 2 + .../skins/default/xui/en/panel_group_bulk_ban.xml | 38 +++++++++------ .../skins/default/xui/en/panel_group_roles.xml | 13 +++++ 8 files changed, 119 insertions(+), 27 deletions(-) (limited to 'indra/newview/llpanelgroupbulkimpl.h') diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 970d6d5a2d..2e94e8d9a0 100755 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -49,6 +49,8 @@ enum LLGroupChange GC_ALL }; +const U32 GB_MAX_BANNED_AGENTS = 500; + class LLGroupMgrObserver { public: diff --git a/indra/newview/llpanelgroupbulkban.cpp b/indra/newview/llpanelgroupbulkban.cpp index 3499b45949..cf1f0bc32f 100644 --- a/indra/newview/llpanelgroupbulkban.cpp +++ b/indra/newview/llpanelgroupbulkban.cpp @@ -102,6 +102,7 @@ BOOL LLPanelGroupBulkBan::postBuild() mImplementation->mTooManySelected = getString("ban_selection_too_large"); mImplementation->mBanNotPermitted = getString("ban_not_permitted"); + mImplementation->mBanLimitFail = getString("ban_limit_fail"); mImplementation->mCannotBanYourself = getString("cant_ban_yourself"); update(); @@ -122,13 +123,23 @@ void LLPanelGroupBulkBan::submit() { if (!gAgent.hasPowerInGroup(mImplementation->mGroupID, GP_GROUP_BAN_ACCESS)) { - // Fail! Agent no longer have ban rights. + // Fail! Agent no longer have ban rights. Permissions could have changed after button was pressed. LLSD msg; msg["MESSAGE"] = mImplementation->mBanNotPermitted; LLNotificationsUtil::add("GenericAlert", msg); (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); return; } + LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); + if (group_datap && group_datap->mBanList.size() >= GB_MAX_BANNED_AGENTS) + { + // Fail! Size limit exceeded. List could have updated after button was pressed. + LLSD msg; + msg["MESSAGE"] = mImplementation->mBanLimitFail; + LLNotificationsUtil::add("GenericAlert", msg); + (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); + return; + } std::vector banned_agent_list; std::vector agents = mImplementation->mBulkAgentList->getAllData(); std::vector::iterator iter = agents.begin(); @@ -138,8 +149,8 @@ void LLPanelGroupBulkBan::submit() banned_agent_list.push_back(agent->getUUID()); } - const S32 MAX_GROUP_BANS = 100; // Max invites per request. 100 to match server cap. - if (banned_agent_list.size() > MAX_GROUP_BANS) + const S32 MAX_BANS_PER_REQUEST = 100; // Max bans per request. 100 to match server cap. + if (banned_agent_list.size() > MAX_BANS_PER_REQUEST) { // Fail! LLSD msg; @@ -151,6 +162,7 @@ void LLPanelGroupBulkBan::submit() // remove already banned users and yourself from request. std::vector banned_avatar_names; + std::vector out_of_limit_names; bool banning_self = FALSE; std::vector::iterator conflict = std::find(banned_agent_list.begin(), banned_agent_list.end(), gAgent.getID()); if (conflict != banned_agent_list.end()) @@ -158,7 +170,6 @@ void LLPanelGroupBulkBan::submit() banned_agent_list.erase(conflict); banning_self = TRUE; } - LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); if (group_datap) { BOOST_FOREACH(const LLGroupMgrGroupData::ban_list_t::value_type& group_ban_pair, group_datap->mBanList) @@ -178,8 +189,23 @@ void LLPanelGroupBulkBan::submit() } } } + // this check should always be the last one before we send the request. + // Otherwise we have a possibility of cutting more then we need to. + if (banned_agent_list.size() > GB_MAX_BANNED_AGENTS - group_datap->mBanList.size()) + { + std::vector::iterator exeedes_limit = banned_agent_list.begin() + GB_MAX_BANNED_AGENTS - group_datap->mBanList.size(); + for (std::vector::iterator itor = exeedes_limit ; + itor != banned_agent_list.end(); ++itor) + { + LLAvatarName av_name; + LLAvatarNameCache::get(*itor, &av_name); + out_of_limit_names.push_back(av_name); + } + banned_agent_list.erase(exeedes_limit,banned_agent_list.end()); + } } + // sending request and ejecting members if (banned_agent_list.size() != 0) { LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mImplementation->mGroupID, LLGroupMgr::BAN_CREATE | LLGroupMgr::BAN_UPDATE, banned_agent_list); @@ -187,16 +213,12 @@ void LLPanelGroupBulkBan::submit() } // building notification - if (banned_avatar_names.size() > 0 || banning_self) + if (banned_avatar_names.size() > 0 || banning_self || out_of_limit_names.size() > 0) { std::string reasons; if(banned_avatar_names.size() > 0) { - std::string names_string; - LLAvatarActions::buildResidentsString(banned_avatar_names, names_string); - LLStringUtil::format_map_t reason_args; - reason_args["[RESIDENTS]"] = names_string; - reasons = "\n " + getString("residents_already_banned", reason_args); + reasons = "\n " + buildResidentsArgument(banned_avatar_names, "residents_already_banned"); } if(banning_self) @@ -204,6 +226,11 @@ void LLPanelGroupBulkBan::submit() reasons += "\n " + mImplementation->mCannotBanYourself; } + if(out_of_limit_names.size() > 0) + { + reasons += "\n " + buildResidentsArgument(out_of_limit_names, "ban_limit_reached"); + } + LLStringUtil::format_map_t msg_args; msg_args["[REASONS]"] = reasons; LLSD msg; @@ -222,3 +249,11 @@ void LLPanelGroupBulkBan::submit() (*(mImplementation->mCloseCallback))(mImplementation->mCloseCallbackUserData); } +std::string LLPanelGroupBulkBan::buildResidentsArgument(std::vector avatar_names, const std::string &format) +{ + std::string names_string; + LLAvatarActions::buildResidentsString(avatar_names, names_string); + LLStringUtil::format_map_t args; + args["[RESIDENTS]"] = names_string; + return getString(format, args); +} diff --git a/indra/newview/llpanelgroupbulkban.h b/indra/newview/llpanelgroupbulkban.h index 0684f365a0..9060d275f9 100644 --- a/indra/newview/llpanelgroupbulkban.h +++ b/indra/newview/llpanelgroupbulkban.h @@ -42,6 +42,8 @@ public: static void callbackClickSubmit(void* userdata); virtual void submit(); +private: + std::string buildResidentsArgument(std::vector avatar_names, const std::string &format); }; #endif // LL_LLPANELGROUPBULKBAN_H diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 585b48c68f..d3a48e5a9a 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -75,6 +75,7 @@ public: std::string mLoadingText; std::string mTooManySelected; std::string mBanNotPermitted; + std::string mBanLimitFail; std::string mCannotBanYourself; std::set mInviteeIDs; diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index b21e1747b3..68022ef343 100755 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -2844,8 +2844,9 @@ BOOL LLPanelGroupBanListSubTab::postBuildSubTab(LLView* root) mCreateBanButton = parent->getChild("ban_create", recurse); mDeleteBanButton = parent->getChild("ban_delete", recurse); mRefreshBanListButton = parent->getChild("ban_refresh", recurse); + mBanCountText = parent->getChild("ban_count", recurse); - if(!mBanList || !mCreateBanButton || !mDeleteBanButton || !mRefreshBanListButton) + if(!mBanList || !mCreateBanButton || !mDeleteBanButton || !mRefreshBanListButton || !mBanCountText) return FALSE; mBanList->setCommitOnSelectionChange(TRUE); @@ -2860,6 +2861,8 @@ BOOL LLPanelGroupBanListSubTab::postBuildSubTab(LLView* root) mRefreshBanListButton->setClickedCallback(onRefreshBanList, this); mRefreshBanListButton->setEnabled(FALSE); + setBanCount(0); + mBanList->setOnNameListCompleteCallback(boost::bind(&LLPanelGroupBanListSubTab::onBanListCompleted, this, _1)); populateBanList(); @@ -2875,7 +2878,18 @@ void LLPanelGroupBanListSubTab::activate() mBanList->deselectAllItems(); mDeleteBanButton->setEnabled(FALSE); - mCreateBanButton->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_GROUP_BAN_ACCESS)); + LLGroupMgrGroupData * group_datap = LLGroupMgr::getInstance()->getGroupData(mGroupID); + if (group_datap) + { + mCreateBanButton->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_GROUP_BAN_ACCESS) && + group_datap->mBanList.size() < GB_MAX_BANNED_AGENTS); + setBanCount(group_datap->mBanList.size()); + } + else + { + mCreateBanButton->setEnabled(FALSE); + setBanCount(0); + } // BAKER: Should I really request everytime activate() is called? // Perhaps I should only do it on a force refresh, or if an action on the list happens... @@ -2993,6 +3007,10 @@ void LLPanelGroupBanListSubTab::handleDeleteBanEntry() // the button anymore until we reselect another entry. mDeleteBanButton->setEnabled(FALSE); } + + // update ban-count related elements + mCreateBanButton->setEnabled(TRUE); + setBanCount(gdatap->mBanList.size()); LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, mGroupID, LLGroupMgr::BAN_DELETE, ban_ids); } @@ -3021,6 +3039,14 @@ void LLPanelGroupBanListSubTab::onBanListCompleted(bool isComplete) } } +void LLPanelGroupBanListSubTab::setBanCount(U32 ban_count) +{ + LLStringUtil::format_map_t args; + args["[COUNT]"] = llformat("%d", ban_count); + args["[LIMIT]"] = llformat("%d", GB_MAX_BANNED_AGENTS); + mBanCountText->setText(getString("ban_count_template", args)); +} + void LLPanelGroupBanListSubTab::populateBanList() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); @@ -3060,6 +3086,9 @@ void LLPanelGroupBanListSubTab::populateBanList() } mRefreshBanListButton->setEnabled(TRUE); + mCreateBanButton->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_GROUP_BAN_ACCESS) && + gdatap->mBanList.size() < GB_MAX_BANNED_AGENTS); + setBanCount(gdatap->mBanList.size()); } void LLPanelGroupBanListSubTab::setGroupID(const LLUUID& id) diff --git a/indra/newview/llpanelgrouproles.h b/indra/newview/llpanelgrouproles.h index 052f1d2071..b9697a1d3a 100755 --- a/indra/newview/llpanelgrouproles.h +++ b/indra/newview/llpanelgrouproles.h @@ -347,6 +347,7 @@ public: void onBanListCompleted(bool isComplete); protected: + void setBanCount(U32 ban_count); void populateBanList(); public: @@ -357,6 +358,7 @@ protected: LLButton* mCreateBanButton; LLButton* mDeleteBanButton; LLButton* mRefreshBanListButton; + LLTextBase* mBanCountText; }; diff --git a/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml b/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml index 31989f2e16..509dcf354e 100644 --- a/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml +++ b/indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml @@ -15,28 +15,36 @@ name="ban_selection_too_large"> Group bans not sent: too many Residents selected. Group bans are limited to 100 per request. - - Group ban not sent: you do not have 'Manage ban list' ability. - - + + Group ban not sent: your group have reached limit of allowed ban records. + + - Some group bans were not sent: + Some group bans were not sent: [REASONS] - - + - Group bans were not sent: + Group bans were not sent: [REASONS] - - + - - The following resident(s) are already banned: [RESIDENTS]. - - + + - Ban limit reached, following agents not banned: [RESIDENTS]. + + - - You cannot ban yourself from a group. - + - You cannot ban yourself from a group. + Any resident on the ban list will be unable to join the group. + + Ban count: [COUNT]/[LIMIT] + + +