From e09b416674809f8c7bae60c496f5e2fce97e881e Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 24 Dec 2018 11:44:57 +0100 Subject: [PATCH] automatically add moderator rights to the owner of a forum --- libretroshare/src/retroshare/rsgxsforums.h | 4 ++++ retroshare-gui/src/gui/gxs/GxsGroupDialog.ui | 12 ++++++------ .../src/gui/gxsforums/GxsForumGroupDialog.cpp | 1 + retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp | 2 +- .../src/gui/gxsforums/GxsForumThreadWidget.cpp | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index 3b130fa52..1c95bed87 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -74,6 +74,10 @@ struct RsGxsForumGroup : RsSerializable RS_SERIAL_PROCESS(mAdminList); RS_SERIAL_PROCESS(mPinnedPosts); } + + // utility functions + + bool canEditPosts(const RsGxsId& id) const { return mAdminList.ids.find(id) != mAdminList.ids.end() || id == mMeta.mAuthorId; } }; struct RsGxsForumMsg : RsSerializable diff --git a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui index 56519718e..43b351edc 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsGroupDialog.ui @@ -7,7 +7,7 @@ 0 0 1237 - 1189 + 1206 @@ -44,7 +44,7 @@ QFrame::Raised - 1 + 0 @@ -169,10 +169,10 @@ - Will be used to send feedback + <html><head/><body><p>The identity here can be used to send feedback.</p></body></html> - Contact: + Owner: @@ -399,7 +399,7 @@ - Required + Re&quired @@ -855,8 +855,8 @@ - + diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp index 168cfe463..20ab13c52 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumGroupDialog.cpp @@ -62,6 +62,7 @@ GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenQueue, QWidget *parent : GxsGroupDialog(tokenQueue, ForumCreateEnabledFlags, ForumCreateDefaultsFlags, parent) { ui.pubKeyShare_cb->setEnabled(true) ; + ui.label_2->setToolTip(tr("

Put one of your identities here to allow others to send feedback and also have moderator rights on the forum. You may as well leave that field blank and keep the forum anonymously administrated.

")); } GxsForumGroupDialog::GxsForumGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index 35edee9ff..0ed34a75e 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -927,7 +927,7 @@ void RsGxsForumModel::computeMessagesHierarchy(const RsGxsForumGroup& forum_grou if( !IS_FORUM_MSG_MODERATION(msgIt->second.mMsgFlags) ) // if authors are different the moderation flag needs to be set on the editing msg continue ; - if( forum_group.mAdminList.ids.find(msgIt->second.mAuthorId)==forum_group.mAdminList.ids.end()) // if author is not a moderator, continue + if( !forum_group.canEditPosts(msgIt->second.mAuthorId)) // if author is not a moderator, continue continue ; } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 5b017a6a1..62c85c74b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -843,7 +843,7 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) rsIdentity->getOwnIds(own_ids) ; for(auto it(own_ids.begin());it!=own_ids.end();++it) - if(mForumGroup.mAdminList.ids.find(*it) != mForumGroup.mAdminList.ids.end()) + if(mForumGroup.canEditPosts(*it)) { contextMnu.addAction(editAct); break ; @@ -1137,7 +1137,7 @@ void GxsForumThreadWidget::updateForumDescription() } forum_description += QString("%1: \t%2
").arg(tr("Distribution"), distrib_string); - forum_description += QString("%1: \t%2
").arg(tr("Contact"), author); + forum_description += QString("%1: \t%2
").arg(tr("Owner"), author); if(!anti_spam_features1.isNull()) forum_description += QString("%1: \t%2
").arg(tr("Anti-spam")).arg(anti_spam_features1);