diff options
author | Mnikolenko ProductEngine <mnikolenko@productengine.com> | 2014-07-14 12:31:16 +0300 |
---|---|---|
committer | Mnikolenko ProductEngine <mnikolenko@productengine.com> | 2014-07-14 12:31:16 +0300 |
commit | b4df05d21af49ab7195b77d44fb0e53b070e79bd (patch) | |
tree | 70facbed78557616076010cb8e82dd7027324893 /indra | |
parent | 3b5b6e35c4f1d5412349766deff7bf573ac1a301 (diff) |
MAINT-4226 Group ban option is added to participant menu in Group chat.
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/newview/llconversationmodel.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llconversationmodel.h | 2 | ||||
-rwxr-xr-x | indra/newview/llfloaterimcontainer.cpp | 87 | ||||
-rwxr-xr-x | indra/newview/llfloaterimcontainer.h | 4 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/menu_conversation.xml | 8 |
5 files changed, 110 insertions, 0 deletions
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp index 74b77f760d..6e32ce60ec 100755 --- a/indra/newview/llconversationmodel.cpp +++ b/indra/newview/llconversationmodel.cpp @@ -51,6 +51,7 @@ LLConversationItem::LLConversationItem(std::string display_name, const LLUUID& u mConvType(CONV_UNKNOWN), mLastActiveTime(0.0), mDisplayModeratorOptions(false), + mDisplayGroupBanOptions(false), mAvatarNameCacheConnection() { } @@ -63,6 +64,7 @@ LLConversationItem::LLConversationItem(const LLUUID& uuid, LLFolderViewModelInte mConvType(CONV_UNKNOWN), mLastActiveTime(0.0), mDisplayModeratorOptions(false), + mDisplayGroupBanOptions(false), mAvatarNameCacheConnection() { } @@ -75,6 +77,7 @@ LLConversationItem::LLConversationItem(LLFolderViewModelInterface& root_view_mod mConvType(CONV_UNKNOWN), mLastActiveTime(0.0), mDisplayModeratorOptions(false), + mDisplayGroupBanOptions(false), mAvatarNameCacheConnection() { } @@ -159,6 +162,12 @@ void LLConversationItem::buildParticipantMenuOptions(menuentry_vec_t& items, U32 items.push_back(std::string("ModerateVoiceMute")); items.push_back(std::string("ModerateVoiceUnmute")); } + + if ((getType() != CONV_SESSION_1_ON_1) && mDisplayGroupBanOptions) + { + items.push_back(std::string("Group Ban Separator")); + items.push_back(std::string("BanMember")); + } } } diff --git a/indra/newview/llconversationmodel.h b/indra/newview/llconversationmodel.h index dc74506c53..56e1a26709 100644 --- a/indra/newview/llconversationmodel.h +++ b/indra/newview/llconversationmodel.h @@ -143,6 +143,7 @@ protected: bool mNeedsRefresh; // Flag signaling to the view that something changed for this item F64 mLastActiveTime; bool mDisplayModeratorOptions; + bool mDisplayGroupBanOptions; boost::signals2::connection mAvatarNameCacheConnection; }; @@ -206,6 +207,7 @@ public: void dumpDebugData(); void setModeratorOptionsVisible(bool visible) { mDisplayModeratorOptions = visible; } void setDisplayModeratorRole(bool displayRole); + void setGroupBanVisible(bool visible) { mDisplayGroupBanOptions = visible; } private: void onAvatarNameCache(const LLAvatarName& av_name); // callback used by fetchAvatarName diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index a0df37b309..8ebe268d81 100755 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -532,6 +532,7 @@ void LLFloaterIMContainer::draw() { LLConversationItemParticipant* participant_model = dynamic_cast<LLConversationItemParticipant*>(*current_participant_model); participant_model->setModeratorOptionsVisible(isGroupModerator() && participant_model->getUUID() != gAgentID); + participant_model->setGroupBanVisible(haveAbilityToBan() && participant_model->getUUID() != gAgentID); current_participant_model++; } @@ -1150,6 +1151,10 @@ void LLFloaterIMContainer::doToParticipants(const std::string& command, uuid_vec { toggleAllowTextChat(userID); } + else if ("ban_member" == command) + { + banSelectedMember(userID); + } } else if (selectedIDS.size() > 1) { @@ -1408,6 +1413,10 @@ bool LLFloaterIMContainer::enableContextMenuItem(const std::string& item, uuid_v { return LLAvatarActions::canOfferTeleport(uuids); } + else if ("can_ban_member" == item) + { + return canBanSelectedMember(single_id); + } else if (("can_moderate_voice" == item) || ("can_allow_text_chat" == item) || ("can_mute" == item) || ("can_unmute" == item)) { // *TODO : get that out of here... @@ -1830,6 +1839,84 @@ bool LLFloaterIMContainer::isGroupModerator() return false; } +bool LLFloaterIMContainer::haveAbilityToBan() +{ + LLSpeakerMgr * speaker_manager = getSpeakerMgrForSelectedParticipant(); + if (NULL == speaker_manager) + { + LL_WARNS() << "Speaker manager is missing" << LL_ENDL; + return false; + } + LLUUID group_uuid = speaker_manager->getSessionID(); + + return gAgent.isInGroup(group_uuid) && gAgent.hasPowerInGroup(group_uuid, GP_GROUP_BAN_ACCESS); +} + +bool LLFloaterIMContainer::canBanSelectedMember(const LLUUID& participant_uuid) +{ + LLSpeakerMgr * speaker_manager = getSpeakerMgrForSelectedParticipant(); + if (NULL == speaker_manager) + { + LL_WARNS() << "Speaker manager is missing" << LL_ENDL; + return false; + } + LLUUID group_uuid = speaker_manager->getSessionID(); + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(group_uuid); + if(!gdatap) + { + LL_WARNS("Groups") << "Unable to get group data for group " << group_uuid << LL_ENDL; + return false; + } + + LLGroupMgrGroupData::member_list_t::iterator mi = gdatap->mMembers.find((participant_uuid)); + LLGroupMemberData* member_data = (*mi).second; + // Is the member an owner? + if ( member_data && member_data->isInRole(gdatap->mOwnerRole) ) + { + return false; + } + if( gAgent.hasPowerInGroup(group_uuid, GP_ROLE_REMOVE_MEMBER) && + gAgent.hasPowerInGroup(group_uuid, GP_GROUP_BAN_ACCESS) ) + { + return true; + } + + return false; +} + +void LLFloaterIMContainer::banSelectedMember(const LLUUID& participant_uuid) +{ + LLSpeakerMgr * speaker_manager = getSpeakerMgrForSelectedParticipant(); + if (NULL == speaker_manager) + { + LL_WARNS() << "Speaker manager is missing" << LL_ENDL; + return; + } + + LLUUID group_uuid = speaker_manager->getSessionID(); + LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(group_uuid); + if(!gdatap) + { + LL_WARNS("Groups") << "Unable to get group data for group " << group_uuid << LL_ENDL; + return; + } + std::vector<LLUUID> ids; + ids.push_back(participant_uuid); + + LLGroupBanData ban_data; + gdatap->createBanEntry(participant_uuid, ban_data); + LLGroupMgr::getInstance()->sendGroupBanRequest(LLGroupMgr::REQUEST_POST, group_uuid, LLGroupMgr::BAN_CREATE, ids); + LLGroupMgr::getInstance()->sendGroupMemberEjects(group_uuid, ids); + LLGroupMgr::getInstance()->sendGroupMembersRequest(group_uuid); + LLSD args; + std::string name; + gCacheName->getFullName(participant_uuid, name); + args["AVATAR_NAME"] = name; + args["GROUP_NAME"] = gdatap->mName; + LLNotifications::instance().add(LLNotification::Params("EjectAvatarFromGroup").substitutions(args)); + +} + void LLFloaterIMContainer::moderateVoice(const std::string& command, const LLUUID& userID) { if (!gAgent.getRegion()) return; diff --git a/indra/newview/llfloaterimcontainer.h b/indra/newview/llfloaterimcontainer.h index f6d973b9b3..5ea9fd399b 100755 --- a/indra/newview/llfloaterimcontainer.h +++ b/indra/newview/llfloaterimcontainer.h @@ -167,12 +167,16 @@ private: LLSpeaker * getSpeakerOfSelectedParticipant(LLSpeakerMgr * speaker_managerp); LLSpeakerMgr * getSpeakerMgrForSelectedParticipant(); bool isGroupModerator(); + bool haveAbilityToBan(); + bool canBanSelectedMember(const LLUUID& participant_uuid); + LLUUID getGroupUIIDForSelectedParticipant(); bool isMuted(const LLUUID& avatar_id); void moderateVoice(const std::string& command, const LLUUID& userID); void moderateVoiceAllParticipants(bool unmute); void moderateVoiceParticipant(const LLUUID& avatar_id, bool unmute); void toggleAllowTextChat(const LLUUID& participant_uuid); void toggleMute(const LLUUID& participant_id, U32 flags); + void banSelectedMember(const LLUUID& participant_uuid); void openNearbyChat(); bool isParticipantListExpanded(); diff --git a/indra/newview/skins/default/xui/en/menu_conversation.xml b/indra/newview/skins/default/xui/en/menu_conversation.xml index f5a493c064..ed362b36e5 100755 --- a/indra/newview/skins/default/xui/en/menu_conversation.xml +++ b/indra/newview/skins/default/xui/en/menu_conversation.xml @@ -214,4 +214,12 @@ <on_enable function="Avatar.EnableItem" parameter="can_moderate_voice" /> </menu_item_call> </context_menu> + <menu_item_separator layout="topleft" name="Group Ban Separator"/> + <menu_item_call + label="Ban member" + layout="topleft" + name="BanMember"> + <on_click function="Avatar.DoToSelected" parameter="ban_member" /> + <on_enable function="Avatar.EnableItem" parameter="can_ban_member" /> + </menu_item_call> </toggleable_menu> |