llpanelgroupgeneral.cpp 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034
  1. /**
  2. * @file llpanelgroupgeneral.cpp
  3. * @brief General information about a group.
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llpanelgroupgeneral.h"
  34. #include "llbutton.h"
  35. #include "llcheckboxctrl.h"
  36. #include "llcombobox.h"
  37. #include "lldbstrings.h"
  38. #include "lleconomy.h"
  39. #include "lllineeditor.h"
  40. #include "llnamebox.h"
  41. #include "llnamelistctrl.h"
  42. #include "llspinctrl.h"
  43. #include "lltextbox.h"
  44. #include "lltexteditor.h"
  45. #include "lltexturectrl.h"
  46. #include "lluictrlfactory.h"
  47. #include "roles_constants.h"
  48. #include "llagent.h"
  49. #include "llfloateravatarinfo.h"
  50. #include "llfloatergroupinfo.h"
  51. #include "llmutelist.h"
  52. //MK
  53. #include "mkrlinterface.h"
  54. //mk
  55. #include "llstatusbar.h" // can_afford_transaction()
  56. // consts
  57. constexpr S32 MATURE_CONTENT = 1;
  58. constexpr S32 NON_MATURE_CONTENT = 2;
  59. constexpr S32 DECLINE_TO_STATE = 0;
  60. // static
  61. void* LLPanelGroupGeneral::createTab(void* data)
  62. {
  63. LLUUID* group_id = static_cast<LLUUID*>(data);
  64. return new LLPanelGroupGeneral("panel group general", *group_id);
  65. }
  66. LLPanelGroupGeneral::LLPanelGroupGeneral(const std::string& name,
  67. const LLUUID& group_id)
  68. : LLPanelGroupTab(name, group_id),
  69. mChanged(false),
  70. mFirstUse(true),
  71. mPendingMemberUpdate(false),
  72. mUpdateInterval(0.5f),
  73. mSkipNextUpdate(false),
  74. mGroupNameEditor(NULL),
  75. mGroupName(NULL),
  76. mFounderName(NULL),
  77. mInsignia(NULL),
  78. mEditCharter(NULL),
  79. mBtnJoinGroup(NULL),
  80. mListVisibleMembers(NULL),
  81. mCtrlShowInGroupList(NULL),
  82. mComboMature(NULL),
  83. mCtrlOpenEnrollment(NULL),
  84. mCtrlEnrollmentFee(NULL),
  85. mSpinEnrollmentFee(NULL),
  86. mCtrlReceiveNotices(NULL),
  87. mCtrlReceiveChat(NULL),
  88. mCtrlListGroup(NULL),
  89. mActiveTitleLabel(NULL),
  90. mComboActiveTitle(NULL)
  91. {
  92. }
  93. bool LLPanelGroupGeneral::postBuild()
  94. {
  95. // General info
  96. mGroupNameEditor = getChild<LLLineEditor>("group_name_editor",
  97. true, false);
  98. mGroupName = getChild<LLTextBox>("group_name", true, false);
  99. mInsignia = getChild<LLTextureCtrl>("insignia", true, false);
  100. if (mInsignia)
  101. {
  102. mInsignia->setCommitCallback(onCommitAny);
  103. mInsignia->setCallbackUserData(this);
  104. mDefaultIconID = mInsignia->getImageAssetID();
  105. mInsignia->setAllowLocalTexture(false);
  106. }
  107. mEditCharter = getChild<LLTextEditor>("charter", true, false);
  108. if (mEditCharter)
  109. {
  110. mEditCharter->setCommitCallback(onCommitAny);
  111. mEditCharter->setFocusReceivedCallback(onFocusEdit, this);
  112. mEditCharter->setFocusChangedCallback(onFocusEdit, this);
  113. mEditCharter->setCallbackUserData(this);
  114. }
  115. mBtnJoinGroup = getChild<LLButton>("join_button", true, false);
  116. if (mBtnJoinGroup)
  117. {
  118. mBtnJoinGroup->setClickedCallback(onClickJoin);
  119. mBtnJoinGroup->setCallbackUserData(this);
  120. }
  121. mBtnInfo = getChild<LLButton>("info_button", true, false);
  122. if (mBtnInfo)
  123. {
  124. mBtnInfo->setClickedCallback(onClickInfo);
  125. mBtnInfo->setCallbackUserData(this);
  126. }
  127. LLTextBox* founder = getChild<LLTextBox>("founder_name", true, false);
  128. if (founder)
  129. {
  130. mFounderName = new LLNameBox(founder->getName(), founder->getRect(),
  131. LLUUID::null, false, founder->getFont(),
  132. founder->getMouseOpaque());
  133. removeChild(founder, true);
  134. addChild(mFounderName);
  135. }
  136. mListVisibleMembers = getChild<LLNameListCtrl>("visible_members",
  137. true, false);
  138. if (mListVisibleMembers)
  139. {
  140. mListVisibleMembers->setDoubleClickCallback(openProfile);
  141. mListVisibleMembers->setCallbackUserData(this);
  142. }
  143. // Options
  144. mCtrlShowInGroupList = getChild<LLCheckBoxCtrl>("show_in_group_list",
  145. true, false);
  146. if (mCtrlShowInGroupList)
  147. {
  148. mCtrlShowInGroupList->setCommitCallback(onCommitAny);
  149. mCtrlShowInGroupList->setCallbackUserData(this);
  150. }
  151. mComboMature = getChild<LLComboBox>("group_mature_check", true, false);
  152. if (mComboMature)
  153. {
  154. mComboMature->setCurrentByIndex(0);
  155. mComboMature->setCommitCallback(onCommitAny);
  156. mComboMature->setCallbackUserData(this);
  157. if (gAgent.isTeen())
  158. {
  159. // Teens don't get to set mature flag. JC
  160. mComboMature->setVisible(false);
  161. mComboMature->setCurrentByIndex(NON_MATURE_CONTENT);
  162. }
  163. }
  164. mCtrlOpenEnrollment = getChild<LLCheckBoxCtrl>("open_enrollement",
  165. true, false);
  166. if (mCtrlOpenEnrollment)
  167. {
  168. mCtrlOpenEnrollment->setCommitCallback(onCommitAny);
  169. mCtrlOpenEnrollment->setCallbackUserData(this);
  170. }
  171. mCtrlEnrollmentFee = getChild<LLCheckBoxCtrl>("check_enrollment_fee",
  172. true, false);
  173. if (mCtrlEnrollmentFee)
  174. {
  175. mCtrlEnrollmentFee->setCommitCallback(onCommitEnrollment);
  176. mCtrlEnrollmentFee->setCallbackUserData(this);
  177. }
  178. mSpinEnrollmentFee = getChild<LLSpinCtrl>("spin_enrollment_fee",
  179. true, false);
  180. if (mSpinEnrollmentFee)
  181. {
  182. mSpinEnrollmentFee->setCommitCallback(onCommitAny);
  183. mSpinEnrollmentFee->setCallbackUserData(this);
  184. mSpinEnrollmentFee->setPrecision(0);
  185. mSpinEnrollmentFee->resetDirty();
  186. }
  187. bool accept_notices = false;
  188. bool list_in_profile = false;
  189. LLGroupData data;
  190. if (gAgent.getGroupData(mGroupID, data))
  191. {
  192. accept_notices = data.mAcceptNotices;
  193. list_in_profile = data.mListInProfile;
  194. }
  195. mCtrlReceiveNotices = getChild<LLCheckBoxCtrl>("receive_notices",
  196. true, false);
  197. if (mCtrlReceiveNotices)
  198. {
  199. mCtrlReceiveNotices->setCommitCallback(onCommitUserOnly);
  200. mCtrlReceiveNotices->setCallbackUserData(this);
  201. mCtrlReceiveNotices->set(accept_notices);
  202. mCtrlReceiveNotices->setEnabled(data.mID.notNull());
  203. }
  204. mCtrlReceiveChat = getChild<LLCheckBoxCtrl>("receive_chat", true, false);
  205. if (mCtrlReceiveChat)
  206. {
  207. bool receive_chat = !LLMuteList::isMuted(mGroupID, "",
  208. LLMute::flagTextChat);
  209. mCtrlReceiveChat->setCommitCallback(onCommitUserOnly);
  210. mCtrlReceiveChat->setCallbackUserData(this);
  211. mCtrlReceiveChat->set(receive_chat);
  212. mCtrlReceiveChat->setEnabled(data.mID.notNull());
  213. mCtrlReceiveChat->resetDirty();
  214. }
  215. mCtrlListGroup = getChild<LLCheckBoxCtrl>("list_groups_in_profile",
  216. true, false);
  217. if (mCtrlListGroup)
  218. {
  219. mCtrlListGroup->setCommitCallback(onCommitUserOnly);
  220. mCtrlListGroup->setCallbackUserData(this);
  221. mCtrlListGroup->set(list_in_profile);
  222. mCtrlListGroup->setEnabled(data.mID.notNull());
  223. mCtrlListGroup->resetDirty();
  224. }
  225. mActiveTitleLabel = getChild<LLTextBox>("active_title_label",
  226. true, false);
  227. mComboActiveTitle = getChild<LLComboBox>("active_title", true, false);
  228. if (mComboActiveTitle)
  229. {
  230. mComboActiveTitle->setCommitCallback(onCommitTitle);
  231. mComboActiveTitle->setCallbackUserData(this);
  232. mComboActiveTitle->resetDirty();
  233. }
  234. mIncompleteMemberDataStr = getString("incomplete_member_data_str");
  235. LLLineEditor* group_id_line = getChild<LLLineEditor>("group_id_line",
  236. true, false);
  237. // If the group_id is null, then we are creating a new group
  238. if (mGroupID.isNull())
  239. {
  240. if (mGroupNameEditor) mGroupNameEditor->setEnabled(true);
  241. if (mEditCharter) mEditCharter->setEnabled(true);
  242. if (mCtrlShowInGroupList) mCtrlShowInGroupList->setEnabled(true);
  243. if (mComboMature) mComboMature->setEnabled(true);
  244. if (mCtrlOpenEnrollment) mCtrlOpenEnrollment->setEnabled(true);
  245. if (mCtrlEnrollmentFee) mCtrlEnrollmentFee->setEnabled(true);
  246. if (mSpinEnrollmentFee) mSpinEnrollmentFee->setEnabled(true);
  247. if (mBtnJoinGroup) mBtnJoinGroup->setVisible(false);
  248. if (mBtnInfo) mBtnInfo->setVisible(false);
  249. if (mGroupName) mGroupName->setVisible(false);
  250. if (group_id_line) group_id_line->setVisible(false);
  251. }
  252. else if (group_id_line)
  253. {
  254. group_id_line->setText(mGroupID.asString());
  255. }
  256. return LLPanelGroupTab::postBuild();
  257. }
  258. // static
  259. void LLPanelGroupGeneral::onFocusEdit(LLFocusableElement* ctrl, void* data)
  260. {
  261. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  262. if (self)
  263. {
  264. self->updateChanged();
  265. self->notifyObservers();
  266. }
  267. }
  268. // static
  269. void LLPanelGroupGeneral::onCommitAny(LLUICtrl* ctrl, void* data)
  270. {
  271. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  272. if (self)
  273. {
  274. self->updateChanged();
  275. self->notifyObservers();
  276. }
  277. }
  278. // static
  279. void LLPanelGroupGeneral::onCommitUserOnly(LLUICtrl* ctrl, void* data)
  280. {
  281. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  282. if (self)
  283. {
  284. self->mChanged = true;
  285. self->notifyObservers();
  286. }
  287. }
  288. // static
  289. void LLPanelGroupGeneral::onCommitEnrollment(LLUICtrl* ctrl, void* data)
  290. {
  291. onCommitAny(ctrl, data);
  292. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  293. // Make sure both enrollment related widgets are there.
  294. if (!self || !self->mCtrlEnrollmentFee || !self->mSpinEnrollmentFee)
  295. {
  296. return;
  297. }
  298. // Make sure the agent can change enrollment info.
  299. if (!gAgent.hasPowerInGroup(self->mGroupID, GP_MEMBER_OPTIONS) ||
  300. !self->mAllowEdit)
  301. {
  302. return;
  303. }
  304. if (self->mCtrlEnrollmentFee->get())
  305. {
  306. self->mSpinEnrollmentFee->setEnabled(true);
  307. }
  308. else
  309. {
  310. self->mSpinEnrollmentFee->setEnabled(false);
  311. self->mSpinEnrollmentFee->set(0);
  312. }
  313. }
  314. // static
  315. void LLPanelGroupGeneral::onCommitTitle(LLUICtrl* ctrl, void* data)
  316. {
  317. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  318. if (!self || self->mGroupID.isNull() || !self->mAllowEdit) return;
  319. gGroupMgr.sendGroupTitleUpdate(self->mGroupID,
  320. self->mComboActiveTitle->getCurrentID());
  321. self->update(GC_TITLES);
  322. self->mComboActiveTitle->resetDirty();
  323. }
  324. // static
  325. void LLPanelGroupGeneral::onClickInfo(void* userdata)
  326. {
  327. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)userdata;
  328. if (self)
  329. {
  330. LL_DEBUGS("GroupPanel") << "Opening group info for group: "
  331. << self->mGroupID << LL_ENDL;
  332. LLFloaterGroupInfo::showFromUUID(self->mGroupID);
  333. }
  334. }
  335. // static
  336. void LLPanelGroupGeneral::onClickJoin(void* userdata)
  337. {
  338. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)userdata;
  339. if (!self) return;
  340. LL_DEBUGS("GroupPanel") << "Joining group: " << self->mGroupID << LL_ENDL;
  341. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(self->mGroupID);
  342. if (gdatap)
  343. {
  344. S32 cost = gdatap->mMembershipFee;
  345. LLSD args;
  346. args["COST"] = llformat("%d", cost);
  347. LLSD payload;
  348. payload["group_id"] = self->mGroupID;
  349. if (can_afford_transaction(cost))
  350. {
  351. gNotifications.add("JoinGroupCanAfford", args, payload,
  352. LLPanelGroupGeneral::joinDlgCB);
  353. }
  354. else
  355. {
  356. gNotifications.add("JoinGroupCannotAfford", args, payload);
  357. }
  358. }
  359. else
  360. {
  361. llwarns << "getGroupData(" << self->mGroupID << ") was NULL" << llendl;
  362. }
  363. }
  364. // static
  365. bool LLPanelGroupGeneral::joinDlgCB(const LLSD& notif, const LLSD& response)
  366. {
  367. if (LLNotification::getSelectedOption(notif, response) == 1)
  368. {
  369. // User clicked cancel
  370. return false;
  371. }
  372. gGroupMgr.sendGroupMemberJoin(notif["payload"]["group_id"].asUUID());
  373. return false;
  374. }
  375. // static
  376. void LLPanelGroupGeneral::openProfile(void* data)
  377. {
  378. LLPanelGroupGeneral* self = (LLPanelGroupGeneral*)data;
  379. if (self && self->mListVisibleMembers)
  380. {
  381. LLScrollListItem* selected =
  382. self->mListVisibleMembers->getFirstSelected();
  383. if (selected)
  384. {
  385. LLFloaterAvatarInfo::showFromDirectory(selected->getUUID());
  386. }
  387. }
  388. }
  389. bool LLPanelGroupGeneral::needsApply(std::string& mesg)
  390. {
  391. updateChanged();
  392. mesg = getString("group_info_unchanged");
  393. return mChanged || mGroupID.isNull();
  394. }
  395. void LLPanelGroupGeneral::activate()
  396. {
  397. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(mGroupID);
  398. if (mGroupID.notNull() && (!gdatap || mFirstUse))
  399. {
  400. gGroupMgr.sendGroupTitlesRequest(mGroupID);
  401. gGroupMgr.sendGroupPropertiesRequest(mGroupID);
  402. #if 0
  403. if (!gdatap || !gdatap->isMemberDataComplete())
  404. {
  405. gGroupMgr.sendCapGroupMembersRequest(mGroupID);
  406. }
  407. #endif
  408. mFirstUse = false;
  409. }
  410. mChanged = false;
  411. update(GC_ALL);
  412. }
  413. void LLPanelGroupGeneral::draw()
  414. {
  415. // Do not update every frame: that would be insane !
  416. if (mSkipNextUpdate)
  417. {
  418. // Compute the time the viewer took to 'digest' the update and come
  419. // back to us; the name list update takes time, and the avatar name
  420. // query takes even more time when the name is not cached !
  421. mUpdateInterval = (mUpdateInterval + 3.f *
  422. mUpdateTimer.getElapsedTimeF32()) * 0.5f;
  423. mSkipNextUpdate = false;
  424. LL_DEBUGS("GroupPanel") << "Interval for next update = "
  425. << mUpdateInterval << "s" << LL_ENDL;
  426. mUpdateTimer.reset();
  427. }
  428. else if (mPendingMemberUpdate &&
  429. mUpdateTimer.getElapsedTimeF32() > mUpdateInterval)
  430. {
  431. mUpdateTimer.reset();
  432. updateMembers();
  433. mSkipNextUpdate = true;
  434. }
  435. LLPanelGroupTab::draw();
  436. }
  437. bool LLPanelGroupGeneral::apply(std::string& mesg)
  438. {
  439. bool has_power_in_group = gAgent.hasPowerInGroup(mGroupID,
  440. GP_GROUP_CHANGE_IDENTITY);
  441. if (has_power_in_group || mGroupID.isNull())
  442. {
  443. // Check to make sure mature has been set
  444. if (mComboMature &&
  445. mComboMature->getCurrentIndex() == DECLINE_TO_STATE)
  446. {
  447. gNotifications.add("SetGroupMature", LLSD(), LLSD(),
  448. boost::bind(&LLPanelGroupGeneral::confirmMatureApply,
  449. this, _1, _2));
  450. return false;
  451. }
  452. if (mGroupID.isNull())
  453. {
  454. // We need all these for the callback
  455. if (mGroupNameEditor && mEditCharter && mCtrlShowInGroupList &&
  456. mInsignia && mCtrlOpenEnrollment && mComboMature)
  457. {
  458. // Validate the group name length.
  459. S32 group_name_len = mGroupNameEditor->getText().size();
  460. if (group_name_len < DB_GROUP_NAME_MIN_LEN ||
  461. group_name_len > DB_GROUP_NAME_STR_LEN)
  462. {
  463. std::ostringstream temp_error;
  464. temp_error << "A group name must be between "
  465. << DB_GROUP_NAME_MIN_LEN << " and "
  466. << DB_GROUP_NAME_STR_LEN << " characters.";
  467. mesg = temp_error.str();
  468. return false;
  469. }
  470. LLSD args;
  471. args["COST"] = LLEconomy::getInstance()->getCreateGroupCost();
  472. gNotifications.add("CreateGroupCost", args, LLSD(),
  473. boost::bind(&LLPanelGroupGeneral::createGroupCallback,
  474. this, _1, _2));
  475. }
  476. else
  477. {
  478. mesg = "Missing UI elements in the group panel !";
  479. }
  480. return false;
  481. }
  482. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(mGroupID);
  483. if (!gdatap)
  484. {
  485. // *TODO: Translate
  486. mesg = std::string("No group data found for group ");
  487. mesg.append(mGroupID.asString());
  488. return false;
  489. }
  490. bool can_change_ident = gAgent.hasPowerInGroup(mGroupID,
  491. GP_GROUP_CHANGE_IDENTITY);
  492. if (can_change_ident)
  493. {
  494. if (mEditCharter)
  495. {
  496. gdatap->mCharter = mEditCharter->getText();
  497. }
  498. if (mInsignia)
  499. {
  500. gdatap->mInsigniaID = mInsignia->getImageAssetID();
  501. }
  502. if (mComboMature)
  503. {
  504. if (!gAgent.isTeen())
  505. {
  506. gdatap->mMaturePublish =
  507. (mComboMature->getCurrentIndex() == MATURE_CONTENT);
  508. }
  509. else
  510. {
  511. gdatap->mMaturePublish = false;
  512. }
  513. }
  514. if (mCtrlShowInGroupList)
  515. {
  516. gdatap->mShowInList = mCtrlShowInGroupList->get();
  517. }
  518. }
  519. bool can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,
  520. GP_MEMBER_OPTIONS);
  521. if (can_change_member_opts)
  522. {
  523. if (mCtrlOpenEnrollment)
  524. {
  525. gdatap->mOpenEnrollment = mCtrlOpenEnrollment->get();
  526. }
  527. if (mCtrlEnrollmentFee && mSpinEnrollmentFee)
  528. {
  529. gdatap->mMembershipFee = (mCtrlEnrollmentFee->get()) ?
  530. (S32)mSpinEnrollmentFee->get() : 0;
  531. // Set to the used value, and reset initial value used for
  532. // isdirty check
  533. mSpinEnrollmentFee->set((F32)gdatap->mMembershipFee);
  534. }
  535. }
  536. if (can_change_ident || can_change_member_opts)
  537. {
  538. gGroupMgr.sendUpdateGroupInfo(mGroupID);
  539. }
  540. }
  541. bool receive_notices = false;
  542. bool list_in_profile = false;
  543. if (mCtrlReceiveNotices)
  544. {
  545. receive_notices = mCtrlReceiveNotices->get();
  546. mCtrlReceiveNotices->resetDirty();
  547. }
  548. if (mCtrlListGroup)
  549. {
  550. list_in_profile = mCtrlListGroup->get();
  551. mCtrlListGroup->resetDirty();
  552. }
  553. if (mCtrlReceiveChat)
  554. {
  555. LLGroupData data;
  556. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(mGroupID);
  557. if (gdatap)
  558. {
  559. LLMute mute(mGroupID, gdatap->mName, LLMute::GROUP);
  560. if (mCtrlReceiveChat->get())
  561. {
  562. if (LLMuteList::isMuted(mGroupID, "", LLMute::flagTextChat))
  563. {
  564. LLMuteList::remove(mute, LLMute::flagTextChat);
  565. }
  566. }
  567. else
  568. {
  569. if (!LLMuteList::isMuted(mGroupID, "", LLMute::flagTextChat))
  570. {
  571. LLMuteList::add(mute, LLMute::flagTextChat);
  572. }
  573. }
  574. }
  575. mCtrlReceiveChat->resetDirty();
  576. }
  577. gAgent.setUserGroupFlags(mGroupID, receive_notices, list_in_profile);
  578. mChanged = false;
  579. return true;
  580. }
  581. void LLPanelGroupGeneral::cancel()
  582. {
  583. mChanged = false;
  584. // Cancel out all of the click changes to, although since we are shifting
  585. // tabs or closing the floater, this need not be done... yet.
  586. notifyObservers();
  587. }
  588. // Invoked from callbackConfirmMature
  589. bool LLPanelGroupGeneral::confirmMatureApply(const LLSD& notification,
  590. const LLSD& response)
  591. {
  592. S32 option = LLNotification::getSelectedOption(notification, response);
  593. // 0 == Yes
  594. // 1 == No
  595. // 2 == Cancel
  596. switch (option)
  597. {
  598. case 0:
  599. mComboMature->setCurrentByIndex(MATURE_CONTENT);
  600. break;
  601. case 1:
  602. mComboMature->setCurrentByIndex(NON_MATURE_CONTENT);
  603. break;
  604. default:
  605. return false;
  606. }
  607. // If we got here it means they set a valid value
  608. std::string mesg = "";
  609. apply(mesg);
  610. return false;
  611. }
  612. // static
  613. bool LLPanelGroupGeneral::createGroupCallback(const LLSD& notification,
  614. const LLSD& response)
  615. {
  616. if (LLNotification::getSelectedOption(notification, response) == 0)
  617. {
  618. U32 enrollment_fee = (mCtrlEnrollmentFee->get() ?
  619. (U32) mSpinEnrollmentFee->get() : 0);
  620. gGroupMgr.sendCreateGroupRequest(mGroupNameEditor->getText(),
  621. mEditCharter->getText(),
  622. mCtrlShowInGroupList->get(),
  623. mInsignia->getImageAssetID(),
  624. enrollment_fee,
  625. mCtrlOpenEnrollment->get(), false,
  626. mComboMature->getCurrentIndex() == MATURE_CONTENT);
  627. }
  628. return false;
  629. }
  630. // virtual
  631. void LLPanelGroupGeneral::update(LLGroupChange gc)
  632. {
  633. if (mGroupID.isNull()) return;
  634. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(mGroupID);
  635. if (!gdatap) return;
  636. LLGroupData agent_gdatap;
  637. bool is_member = false;
  638. if (gAgent.getGroupData(mGroupID, agent_gdatap)) is_member = true;
  639. if (mComboActiveTitle)
  640. {
  641. mComboActiveTitle->setVisible(is_member);
  642. mComboActiveTitle->setEnabled(mAllowEdit);
  643. if (mActiveTitleLabel) mActiveTitleLabel->setVisible(is_member);
  644. if (is_member)
  645. {
  646. LLUUID current_title_role;
  647. mComboActiveTitle->clear();
  648. mComboActiveTitle->removeall();
  649. bool has_selected_title = false;
  650. if (1 == gdatap->mTitles.size())
  651. {
  652. // Only the everyone title. Don't bother letting them try
  653. // changing this.
  654. mComboActiveTitle->setEnabled(false);
  655. }
  656. else
  657. {
  658. mComboActiveTitle->setEnabled(true);
  659. }
  660. for (std::vector<LLGroupTitle>::const_iterator
  661. citer = gdatap->mTitles.begin(),
  662. end = gdatap->mTitles.end();
  663. citer != end; ++citer)
  664. {
  665. mComboActiveTitle->add(citer->mTitle, citer->mRoleID,
  666. citer->mSelected ? ADD_TOP
  667. : ADD_BOTTOM);
  668. if (citer->mSelected)
  669. {
  670. mComboActiveTitle->setCurrentByID(citer->mRoleID);
  671. has_selected_title = true;
  672. }
  673. }
  674. if (!has_selected_title)
  675. {
  676. mComboActiveTitle->setCurrentByID(LLUUID::null);
  677. }
  678. }
  679. mComboActiveTitle->resetDirty();
  680. }
  681. // If this was just a titles update, we are done.
  682. if (gc == GC_TITLES) return;
  683. bool can_change_ident = false;
  684. bool can_change_member_opts = false;
  685. can_change_ident = gAgent.hasPowerInGroup(mGroupID,
  686. GP_GROUP_CHANGE_IDENTITY);
  687. can_change_member_opts = gAgent.hasPowerInGroup(mGroupID,
  688. GP_MEMBER_OPTIONS);
  689. if (mCtrlShowInGroupList)
  690. {
  691. mCtrlShowInGroupList->set(gdatap->mShowInList);
  692. mCtrlShowInGroupList->setEnabled(mAllowEdit && can_change_ident);
  693. mCtrlShowInGroupList->resetDirty();
  694. }
  695. if (mComboMature)
  696. {
  697. if (gdatap->mMaturePublish)
  698. {
  699. mComboMature->setCurrentByIndex(MATURE_CONTENT);
  700. }
  701. else
  702. {
  703. mComboMature->setCurrentByIndex(NON_MATURE_CONTENT);
  704. }
  705. mComboMature->setEnabled(mAllowEdit && can_change_ident);
  706. mComboMature->setVisible(!gAgent.isTeen());
  707. mComboMature->resetDirty();
  708. }
  709. if (mCtrlOpenEnrollment)
  710. {
  711. mCtrlOpenEnrollment->set(gdatap->mOpenEnrollment);
  712. mCtrlOpenEnrollment->setEnabled(mAllowEdit && can_change_member_opts);
  713. mCtrlOpenEnrollment->resetDirty();
  714. }
  715. if (mCtrlEnrollmentFee)
  716. {
  717. mCtrlEnrollmentFee->set(gdatap->mMembershipFee > 0);
  718. mCtrlEnrollmentFee->setEnabled(mAllowEdit && can_change_member_opts);
  719. mCtrlEnrollmentFee->resetDirty();
  720. }
  721. if (mSpinEnrollmentFee)
  722. {
  723. S32 fee = gdatap->mMembershipFee;
  724. mSpinEnrollmentFee->set((F32)fee);
  725. mSpinEnrollmentFee->setEnabled(mAllowEdit && fee > 0 &&
  726. can_change_member_opts);
  727. mSpinEnrollmentFee->resetDirty();
  728. }
  729. if (mBtnJoinGroup)
  730. {
  731. bool visible = !is_member && gdatap->mOpenEnrollment;
  732. //MK
  733. if (gRLenabled && gRLInterface.contains("setgroup"))
  734. {
  735. visible = false;
  736. }
  737. //mk
  738. mBtnJoinGroup->setVisible(visible);
  739. if (visible)
  740. {
  741. // *TODO: translate
  742. std::string fee = llformat("Join (L$%d)", gdatap->mMembershipFee);
  743. mBtnJoinGroup->setLabelSelected(fee);
  744. mBtnJoinGroup->setLabelUnselected(fee);
  745. }
  746. }
  747. if (mBtnInfo)
  748. {
  749. mBtnInfo->setVisible(is_member && !mAllowEdit);
  750. }
  751. if (mCtrlReceiveNotices && gc == GC_ALL)
  752. {
  753. mCtrlReceiveNotices->set(agent_gdatap.mAcceptNotices);
  754. mCtrlReceiveNotices->setVisible(is_member);
  755. mCtrlReceiveNotices->setEnabled(mAllowEdit && is_member);
  756. mCtrlReceiveNotices->resetDirty();
  757. }
  758. if (mCtrlReceiveChat && gc == GC_ALL)
  759. {
  760. bool receive_chat = !LLMuteList::isMuted(mGroupID, "",
  761. LLMute::flagTextChat);
  762. mCtrlReceiveChat->set(receive_chat);
  763. mCtrlReceiveChat->setVisible(is_member);
  764. mCtrlReceiveChat->setEnabled(mAllowEdit);
  765. mCtrlReceiveChat->resetDirty();
  766. }
  767. if (mCtrlListGroup && gc == GC_ALL)
  768. {
  769. mCtrlListGroup->set(agent_gdatap.mListInProfile);
  770. mCtrlListGroup->setVisible(is_member);
  771. mCtrlListGroup->setEnabled(mAllowEdit);
  772. mCtrlListGroup->resetDirty();
  773. }
  774. if (mGroupName)
  775. {
  776. mGroupName->setText(gdatap->mName);
  777. }
  778. if (mGroupNameEditor)
  779. {
  780. mGroupNameEditor->setVisible(false);
  781. }
  782. if (mFounderName)
  783. {
  784. mFounderName->setNameID(gdatap->mFounderID, false);
  785. }
  786. if (mInsignia)
  787. {
  788. mInsignia->setEnabled(mAllowEdit && can_change_ident);
  789. if (gdatap->mInsigniaID.notNull())
  790. {
  791. mInsignia->setImageAssetID(gdatap->mInsigniaID);
  792. }
  793. else
  794. {
  795. mInsignia->setImageAssetID(mDefaultIconID);
  796. }
  797. }
  798. if (mEditCharter)
  799. {
  800. mEditCharter->setEnabled(mAllowEdit && can_change_ident);
  801. mEditCharter->setText(gdatap->mCharter);
  802. mEditCharter->resetDirty();
  803. }
  804. if (mListVisibleMembers)
  805. {
  806. mListVisibleMembers->deleteAllItems();
  807. if (gdatap->isMemberDataComplete())
  808. {
  809. mMemberProgress = gdatap->mMembers.begin();
  810. mPendingMemberUpdate = true;
  811. }
  812. else
  813. {
  814. std::stringstream pending;
  815. pending << "Retrieving member list (" << gdatap->mMembers.size()
  816. << "\\" << gdatap->mMemberCount << ")";
  817. LLSD row;
  818. row["columns"][0]["value"] = pending.str();
  819. mListVisibleMembers->setEnabled(false);
  820. mListVisibleMembers->addElement(row);
  821. }
  822. }
  823. }
  824. void LLPanelGroupGeneral::updateMembers()
  825. {
  826. mPendingMemberUpdate = false;
  827. LLGroupMgrGroupData* gdatap = gGroupMgr.getGroupData(mGroupID);
  828. if (!mListVisibleMembers || !gdatap || !gdatap->isMemberDataComplete() ||
  829. gdatap->mMembers.empty())
  830. {
  831. return;
  832. }
  833. mListVisibleMembers->setAllowRefresh(false);
  834. mListVisibleMembers->setLazyUpdateInterval(5.f);
  835. LLGroupMgrGroupData::member_list_t::iterator end = gdatap->mMembers.end();
  836. U32 i;
  837. LLTimer update_time;
  838. update_time.setTimerExpirySec(UPDATE_MEMBERS_SECONDS_PER_FRAME);
  839. for (i = 0; mMemberProgress != end && !update_time.hasExpired();
  840. ++mMemberProgress, ++i)
  841. {
  842. LLGroupMemberData* member = mMemberProgress->second;
  843. if (!member)
  844. {
  845. continue;
  846. }
  847. // Owners show up in bold.
  848. std::string style = "NORMAL";
  849. if (member->isOwner())
  850. {
  851. style = "BOLD";
  852. }
  853. LLSD row;
  854. row["id"] = member->getID();
  855. LLSD& columns = row["columns"];
  856. columns[0]["column"] = "name";
  857. columns[0]["font-style"] = style;
  858. // value is filled in by name list control
  859. columns[1]["column"] = "title";
  860. columns[1]["value"] = member->getTitle();
  861. columns[1]["font-style"] = style;
  862. columns[2]["column"] = "online";
  863. columns[2]["value"] = member->getOnlineStatus();
  864. columns[2]["font-style"] = style;
  865. mListVisibleMembers->addElement(row); //, ADD_SORTED);
  866. }
  867. if (mMemberProgress == end)
  868. {
  869. mListVisibleMembers->setEnabled(true);
  870. mListVisibleMembers->setAllowRefresh(true);
  871. LL_DEBUGS("GroupPanel") << i
  872. << " members added to the list. No more member pending."
  873. << LL_ENDL;
  874. }
  875. else
  876. {
  877. mPendingMemberUpdate = true;
  878. mListVisibleMembers->setEnabled(false);
  879. mListVisibleMembers->setLazyUpdateInterval(1.f);
  880. LL_DEBUGS("GroupPanel") << i
  881. << " members added to the list. There are still pending members."
  882. << LL_ENDL;
  883. }
  884. }
  885. void LLPanelGroupGeneral::updateChanged()
  886. {
  887. // List all the controls we want to check for changes...
  888. LLUICtrl* check_list[] = {
  889. mGroupNameEditor,
  890. mGroupName,
  891. mFounderName,
  892. mInsignia,
  893. mEditCharter,
  894. mCtrlShowInGroupList,
  895. mComboMature,
  896. mCtrlOpenEnrollment,
  897. mCtrlEnrollmentFee,
  898. mSpinEnrollmentFee,
  899. mCtrlReceiveNotices,
  900. mCtrlReceiveChat,
  901. mCtrlListGroup,
  902. mActiveTitleLabel,
  903. mComboActiveTitle
  904. };
  905. constexpr S32 num_ctrls = LL_ARRAY_SIZE(check_list);
  906. mChanged = false;
  907. for (S32 i = 0; i < num_ctrls; ++i)
  908. {
  909. if (check_list[i] && check_list[i]->isDirty())
  910. {
  911. mChanged = true;
  912. break;
  913. }
  914. }
  915. }