diff options
author | andreykproductengine <akleshchev@productengine.com> | 2014-06-25 20:09:33 +0300 |
---|---|---|
committer | andreykproductengine <akleshchev@productengine.com> | 2014-06-25 20:09:33 +0300 |
commit | 854c251feffe9bf194bc4e63fd0de28bd20ff995 (patch) | |
tree | 94f924d6cac726f03d2667e7c5d5b43a41006ea0 /indra | |
parent | be2f4ecdb4135256e3e513370614c1626e5a1354 (diff) |
MAINT-4178 FIXED [Group Bans] The viewer allows you to attempt to ban when the ban list already contains 500 entries, which fails.
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/newview/llgroupmgr.h | 2 | ||||
-rw-r--r-- | indra/newview/llpanelgroupbulkban.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llpanelgroupbulkban.h | 2 | ||||
-rw-r--r-- | indra/newview/llpanelgroupbulkimpl.h | 1 | ||||
-rwxr-xr-x | indra/newview/llpanelgrouproles.cpp | 33 | ||||
-rwxr-xr-x | indra/newview/llpanelgrouproles.h | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_group_bulk_ban.xml | 38 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/panel_group_roles.xml | 13 |
8 files changed, 119 insertions, 27 deletions
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<LLUUID> banned_agent_list; std::vector<LLScrollListItem*> agents = mImplementation->mBulkAgentList->getAllData(); std::vector<LLScrollListItem*>::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<LLAvatarName> banned_avatar_names; + std::vector<LLAvatarName> out_of_limit_names; bool banning_self = FALSE; std::vector<LLUUID>::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<LLUUID>::iterator exeedes_limit = banned_agent_list.begin() + GB_MAX_BANNED_AGENTS - group_datap->mBanList.size(); + for (std::vector<LLUUID>::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<LLAvatarName> 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<LLAvatarName> 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<LLUUID> 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<LLButton>("ban_create", recurse); mDeleteBanButton = parent->getChild<LLButton>("ban_delete", recurse); mRefreshBanListButton = parent->getChild<LLButton>("ban_refresh", recurse); + mBanCountText = parent->getChild<LLTextBase>("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. </panel.string> - <panel.string + <panel.string name="ban_not_permitted"> - Group ban not sent: you do not have 'Manage ban list' ability. - </panel.string> - <panel.string + Group ban not sent: you do not have 'Manage ban list' ability. + </panel.string> + <panel.string + name="ban_limit_fail"> + Group ban not sent: your group have reached limit of allowed ban records. + </panel.string> + <panel.string name="partial_ban"> - Some group bans were not sent: + Some group bans were not sent: [REASONS] - </panel.string> - <panel.string + </panel.string> + <panel.string name="ban_failed"> - Group bans were not sent: + Group bans were not sent: [REASONS] - </panel.string> - <panel.string + </panel.string> + <panel.string name="residents_already_banned"> - - The following resident(s) are already banned: [RESIDENTS]. - </panel.string> - <panel.string + - The following resident(s) are already banned: [RESIDENTS]. + </panel.string> + <panel.string + name="ban_limit_reached"> + - Ban limit reached, following agents not banned: [RESIDENTS]. + </panel.string> + <panel.string name="cant_ban_yourself"> - - You cannot ban yourself from a group. - </panel.string> + - You cannot ban yourself from a group. + </panel.string> <text type="string" length="1" diff --git a/indra/newview/skins/default/xui/en/panel_group_roles.xml b/indra/newview/skins/default/xui/en/panel_group_roles.xml index ea619e6319..dac4371a38 100755 --- a/indra/newview/skins/default/xui/en/panel_group_roles.xml +++ b/indra/newview/skins/default/xui/en/panel_group_roles.xml @@ -304,6 +304,10 @@ clicking on their names. name="help_text"> Any resident on the ban list will be unable to join the group. </panel.string> + <panel.string + name="ban_count_template"> + Ban count: [COUNT]/[LIMIT] + </panel.string> <name_list column_padding="0" draw_heading="true" @@ -355,6 +359,15 @@ clicking on their names. name="ban_refresh" tool_tip="Refresh the ban list" /> + <text + type="string" + height="18" + left_pad="5" + follows="top|left" + layout="topleft" + name="ban_count" + width="100"> + </text> </panel> </tab_container> <panel |