/// <summary> /// Creates forum. Called when the "Create forum" button is pressed. /// </summary> private bool CreateForum() { // Get the forum group ForumGroupInfo group = ForumGroupInfoProvider.GetForumGroupInfo("MyNewGroup", CMSContext.CurrentSiteID); if (group != null) { // Create new forum object ForumInfo newForum = new ForumInfo(); // Set the properties newForum.ForumDisplayName = "My new forum"; newForum.ForumName = "MyNewForum"; newForum.ForumGroupID = group.GroupID; newForum.ForumSiteID = group.GroupSiteID; newForum.AllowAccess = SecurityAccessEnum.AllUsers; newForum.AllowAttachFiles = SecurityAccessEnum.AuthenticatedUsers; newForum.AllowPost = SecurityAccessEnum.AllUsers; newForum.AllowReply = SecurityAccessEnum.AllUsers; newForum.AllowSubscribe = SecurityAccessEnum.AllUsers; newForum.ForumOpen = true; newForum.ForumModerated = false; newForum.ForumThreads = 0; newForum.ForumPosts = 0; // Save the forum ForumInfoProvider.SetForumInfo(newForum); return true; } return false; }
public void GetForumEvent_ReturnsNull_WhenForumIdIsInvalid() { // Arrange var infos = new List<ForumInfo>(); var forumInfo = new ForumInfo { Active = true, Description = "Awesome", ForumId = 1 }; infos.Add(forumInfo); infos.Add(new ForumInfo { Active = true, Description = "What?", ForumId = 2 }); forumsController.Setup(x => x.GetForum(1)).Returns(forumInfo); presenter = new ForumsServicePresenter(view.Object, forumsController.Object); // Act var getForumCalledEventArgs = new GetForumCalledEventArgs(6); view.Raise(x => x.ForumGetCalled += null, getForumCalledEventArgs); // Assert Assert.IsNull(getForumCalledEventArgs.Result); }
protected void Page_Load(object sender, EventArgs e) { UpdateButton.Click+=new EventHandler(UpdateButton_Click); ModeratedCheckBox.CheckedChanged += new EventHandler(ModeratedCheckBox_CheckedChanged); Slider1.TextChanged += new EventHandler(Slider1_TextChanged); DeleteForumButton.Click +=new EventHandler(DeleteForumButton_Click); string forumId = Request.QueryString["forum"]; if (string.IsNullOrEmpty(forumId)) Response.Redirect("Default.aspx"); _forum = Forums.GetForumByID(int.Parse(forumId)); if (_forum == null) Response.Redirect("Default.aspx"); if (!IsPostBack) { DataBind(); } }
/// <summary> /// Reloads the form data. /// </summary> public override void ReloadData(bool forceReload) { currentValues = GetModerators(); if (forceReload) { forum = ForumInfoProvider.GetForumInfo(ForumID); if (forum != null) { userSelector.CurrentValues = currentValues; userSelector.ReloadData(); } } if (!RequestHelper.IsPostBack() || forceReload) { chkForumModerated.Checked = forum.ForumModerated; // Load current values to uniselector userSelector.CurrentValues = currentValues; userSelector.ReloadData(); } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check MODIFY permission for forums if (!CheckPermissions("cms.forums", CMSAdminControl.PERMISSION_MODIFY)) { return; } string codeName = txtForumName.Text.Trim(); // Get safe code name for simple display mode if (DisplayMode == ControlDisplayModeEnum.Simple) { codeName = ValidationHelper.GetCodeName(txtForumDisplayName.Text.Trim(), 50) + "_group_" + this.CommunityGroupGUID; } // Check required fields string errorMessage = new Validator().NotEmpty(txtForumDisplayName.Text, GetString("Forum_General.EmptyDisplayName")).NotEmpty(codeName, GetString("Forum_General.EmptyCodeName")).Result; if (errorMessage == String.Empty && !ValidationHelper.IsCodeName(codeName)) { errorMessage = GetString("general.errorcodenameinidentificatorformat"); } if (errorMessage == "") { if (CMSContext.CurrentSite != null) { // If forum with given name already exists show error message if (ForumInfoProvider.GetForumInfo(codeName, CMSContext.CurrentSiteID, CommunityGroupID) != null) { lblError.Visible = true; lblError.Text = GetString("Forum_Edit.ForumAlreadyExists"); return; } // Create new object ForumInfo forumObj = new ForumInfo(); // Set new properties forumObj.ForumSiteID = CMSContext.CurrentSite.SiteID; forumObj.ForumIsLocked = chkForumLocked.Checked; forumObj.ForumOpen = chkForumOpen.Checked; forumObj.ForumDisplayEmails = chkForumDisplayEmails.Checked; forumObj.ForumDescription = txtForumDescription.Text.Trim(); forumObj.ForumRequireEmail = chkForumRequireEmail.Checked; forumObj.ForumDisplayName = txtForumDisplayName.Text.Trim(); forumObj.ForumName = codeName; forumObj.ForumGroupID = this.mGroupId; forumObj.ForumModerated = chkForumModerated.Checked; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = chkCaptcha.Checked; forumObj.ForumCommunityGroupID = CommunityGroupID; // For simple display mode skip some properties if (DisplayMode != ControlDisplayModeEnum.Simple) { forumObj.ForumBaseUrl = txtBaseUrl.Text.Trim(); forumObj.ForumUnsubscriptionUrl = txtUnsubscriptionUrl.Text.Trim(); forumObj.ForumHTMLEditor = chkUseHTML.Checked; if (chkInheritBaseUrl.Checked) { forumObj.ForumBaseUrl = null; } if (chkInheritUnsubscribeUrl.Checked) { forumObj.ForumUnsubscriptionUrl = null; } } // Clear inherited values if (chkInheritUseHTML.Checked) { forumObj.SetValue("ForumHTMLEditor", null); } if (chkInheritForumDisplayEmails.Checked) { forumObj.SetValue("ForumDisplayEmails", null); } if (chkInheritForumRequireEmail.Checked) { forumObj.SetValue("ForumRequireEmail", null); } if (chkInheritCaptcha.Checked) { forumObj.SetValue("ForumUseCAPTCHA", null); } // Check licence if (ForumInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Forums, VersionActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); this.mForumId = forumObj.ForumID; this.RaiseOnSaved(); } else { lblError.Visible = true; lblError.Text = GetString("LicenseVersionCheck.Forums"); } } } else { lblError.Visible = true; lblError.Text = errorMessage; } }
protected void Page_Load(object sender, EventArgs e) { process = true; if (!Visible || StopProcessing) { EnableViewState = false; process = false; } chkChangeName.CheckedChanged += chkChangeName_CheckedChanged; if (ForumID > 0) { // Get information on current forum forum = ForumInfoProvider.GetForumInfo(ForumID); // Check whether the forum still exists EditedObject = forum; } // Get forum resource resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); if ((resForums != null) && (forum != null)) { QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ID", resForums.ResourceId); parameters.Add("@ForumID", forum.ForumID); parameters.Add("@SiteID", SiteContext.CurrentSiteID); string where = string.Empty; int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Build where condition if (groupId > 0) { where = "RoleGroupID=" + groupId + " AND PermissionDisplayInMatrix = 0"; } else { where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0"; } // Setup matrix control gridMatrix.IsLiveSite = IsLiveSite; gridMatrix.QueryParameters = parameters; gridMatrix.WhereCondition = where; gridMatrix.CssClass = "permission-matrix"; gridMatrix.OnItemChanged += gridMatrix_OnItemChanged; // Disable permission matrix if user has no MANAGE rights if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { Enable = false; gridMatrix.Enabled = false; ShowError(String.Format(GetString("general.accessdeniedonpermissionname"), "Manage")); } } }
/// <summary> /// 批理设置论坛信息 /// </summary> /// <param name="__foruminfo">复制的论坛信息</param> /// <param name="bsp">是否要批量设置的信息字段</param> /// <param name="fidlist">目标论坛(fid)串</param> /// <returns></returns> public static bool BatchSetForumInf(ForumInfo __foruminfo, BatchSetParams bsp, string fidlist) { return(DatabaseProvider.GetInstance().BatchSetForumInf(__foruminfo, bsp, fidlist)); }
private void RunForumStatic_Click(object sender, EventArgs e) { #region 运行论坛统计 if (this.CheckCookie()) { forumsstatic.Text = ViewState["forumsstatic"].ToString(); int fid = DNTRequest.GetInt("fid", -1); if (fid > 0) { forumInfo = Forums.GetForumInfo(fid); } else { return; } int topiccount = 0; int postcount = 0; int lasttid = 0; string lasttitle = ""; string lastpost = ""; int lastposterid = 0; string lastposter = ""; int replypost = 0; AdminForumStats.ReSetFourmTopicAPost(fid, out topiccount, out postcount, out lasttid, out lasttitle, out lastpost, out lastposterid, out lastposter, out replypost); runforumsstatic = string.Format("<br /><br />运行结果<hr style=\"height:1px; width:600; color:#CCCCCC; background:#CCCCCC; border: 0; \" align=\"left\" />主题总数:{0}<br />帖子总数:{1}<br />今日回帖数总数:{2}<br />最后提交日期:{3}", topiccount, postcount, replypost, lastpost); if ((forumInfo.Topics == topiccount) && (forumInfo.Posts == postcount) && (forumInfo.Todayposts == replypost) && (forumInfo.Lastpost.Trim() == lastpost)) { runforumsstatic += "<br /><br /><br />结果一致"; } else { runforumsstatic += "<br /><br /><br />比较<hr style=\"height:1px; width:600; color:#CCCCCC; background:#CCCCCC; border: 0; \" align=\"left\" />"; if (forumInfo.Topics != topiccount) { runforumsstatic += "主题总数有差异<br />"; } if (forumInfo.Posts != postcount) { runforumsstatic += "帖子总数有差异<br />"; } if (forumInfo.Todayposts != replypost) { runforumsstatic += "今日回帖数总数有差异<br />"; } if (forumInfo.Lastpost != lastpost) { runforumsstatic += "最后提交日期有差异<br />"; } } } this.TabControl1.SelectedIndex = 5; DataGridBind(""); BindTopicType(); #endregion }
/// <summary> /// OK click hadler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { #region "Security" // Check whether forum exists if (ForumContext.CurrentForum == null) { return; } // Check security bool securityCheck = true; switch (ForumContext.CurrentState) { case ForumStateEnum.NewThread: securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.NewThread); break; case ForumStateEnum.ReplyToPost: securityCheck = IsAvailable(ForumContext.CurrentForum, ForumActionType.Reply); break; case ForumStateEnum.EditPost: securityCheck = ForumContext.CurrentPost != null && IsAvailable(ForumContext.CurrentPost, ForumActionType.Edit); break; } if (!securityCheck) { ShowError(GetString("ForumNewPost.PermissionDenied")); return; } #region "Captcha" // Check security code if is required if ((ForumContext.CurrentForum.ForumUseCAPTCHA) && (!SecurityCode1.IsValid()) && (ForumContext.CurrentState != ForumStateEnum.EditPost)) { ShowError(GetString("ForumNewPost.InvalidCaptcha")); return; } #endregion #region "Email field" // Check if email is set when it is required. Email format must be valid when it is set. var isEmailRequired = ForumContext.CurrentForum.ForumRequireEmail || chkSubscribe.Checked; var isEmailInvalid = (isEmailRequired && String.IsNullOrWhiteSpace(txtEmail.Text)) || !txtEmail.IsValid(); if (isEmailInvalid) { ShowError(GetString("Forums_WebInterface_ForumNewPost.emailErrorMsg")); return; } #endregion #region "Subject" // Check whether subject is filled if (txtSubject.Text.Trim() == "") { ShowError(rfvSubject.ErrorMessage); return; } #endregion #region "Text" var validator = new Validator(); string result; // Check post text in HTML editor or text area if (!ForumContext.CurrentForum.ForumHTMLEditor) { // Check whether post text is added in text area if ((result = validator.NotEmpty(DiscussionMacroResolver.RemoveTags(ucBBEditor.Text), rfvText.ErrorMessage).Result) != "") { ShowError(result); return; } } else { // Check whether post text is added in HTML editor if ((result = validator.NotEmpty(htmlTemplateBody.ResolvedValue, rfvText.ErrorMessage).Result) != "") { ShowError(result); return; } } #endregion #region "User name" // Check whether user name is filled if user name field is visible if (ForumContext.CurrentForum.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ((ForumContext.CurrentForum != null) && (ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, ForumContext.CommunityGroupID)))) { validator = new Validator(); if (!String.IsNullOrEmpty(result = validator.NotEmpty(txtUserName.Text, rfvUserName.ErrorMessage).Result)) { ShowError(result); return; } } #endregion #endregion #region "Forum post properties" bool newPost = false; // Current forum info object ForumInfo fi = ForumContext.CurrentForum; // Forum post info object ForumPostInfo fp; // Get forum post info with dependence on current state if (ForumContext.CurrentState == ForumStateEnum.EditPost) { // Get existing object fp = ForumContext.CurrentPost; fp.PostLastEdit = DateTime.Now; } else { // Create new forum post info object fp = new ForumPostInfo(); newPost = true; } fp.SiteId = fi.ForumSiteID; #region "Ad-hoc forum" if (IsAdHocForum && (ForumContext.CurrentForum.ForumID == 0)) { if (DocumentContext.CurrentDocument == null) { ShowError(GetString("forums.documentdoesnotexist")); return; } fi.ForumGroupID = ForumGroupInfoProvider.GetAdHocGroupInfo(SiteID).GroupID; fi.ForumName = "AdHoc-" + Guid.NewGuid(); fi.ForumDisplayName = TextHelper.LimitLength(DocumentContext.CurrentDocument.GetDocumentName(), POST_USERNAME_LENGTH, String.Empty); fi.ForumOpen = true; fi.ForumModerated = false; fi.ForumAccess = 040000; fi.ForumThreads = 0; fi.ForumPosts = 0; fi.ForumLogActivity = LogActivity; ForumInfoProvider.SetForumInfo(fi); ForumContext.CurrentForum.ForumID = fi.ForumID; ForumContext.ForumID = fi.ForumID; ForumID = fi.ForumID; } #endregion // Post forum fp.PostForumID = ForumContext.CurrentForum.ForumID; // Get forum post info with dependence on current state if (ForumContext.CurrentState != ForumStateEnum.EditPost) { // Post time fp.PostTime = DateTime.Now; // User IP address fp.PostInfo.IPAddress = RequestContext.UserHostAddress; // User agent fp.PostInfo.Agent = Request.UserAgent; // Post user id if (!MembershipContext.AuthenticatedUser.IsPublic()) { fp.PostUserID = MembershipContext.AuthenticatedUser.UserID; } // Post signature fp.PostUserSignature = txtSignature.Text; } // Post subject fp.PostSubject = txtSubject.Text; // Post user email fp.PostUserMail = txtEmail.Text; // Post type int forumType = ForumContext.CurrentForum.ForumType; if (forumType == 0) { if (ForumContext.CurrentReplyThread == null) { // New thread - use type which user chosen fp.PostType = (radTypeDiscussion.Checked ? 0 : 1); } else { // Reply - use parent type fp.PostType = ForumContext.CurrentReplyThread.PostType; } } else { // Fixed type - use the forum setting fp.PostType = forumType - 1; } // Set username if change name is allowed if (fi.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ForumContext.UserIsModerator(fp.PostForumID, ForumContext.CommunityGroupID)) { fp.PostUserName = TextHelper.LimitLength(txtUserName.Text, POST_USERNAME_LENGTH, ""); } else { // Get forum post info with dependence on current state if (ForumContext.CurrentState != ForumStateEnum.EditPost) { fp.PostUserName = UserName; } } // Post parent id -> reply to if (ForumContext.CurrentReplyThread != null) { fp.PostParentID = ForumContext.CurrentReplyThread.PostId; // Check max relative level if ((MaxRelativeLevel > -1) && (ForumContext.CurrentReplyThread.PostLevel >= MaxRelativeLevel)) { ShowError(GetString("Forums.MaxRelativeLevelError")); return; } } // Get post text from HTML editor if is enabled fp.PostText = ForumContext.CurrentForum.ForumHTMLEditor ? htmlTemplateBody.ResolvedValue : ucBBEditor.Text; // Approve post if forum is not moderated if (newPost) { if (!ForumContext.CurrentForum.ForumModerated) { fp.PostApproved = true; } else { if (ForumContext.UserIsModerator(fp.PostForumID, CommunityGroupID)) { fp.PostApproved = true; fp.PostApprovedByUserID = MembershipContext.AuthenticatedUser.UserID; } } } // If signature is enabled then if (EnableSignature) { fp.PostUserSignature = MembershipContext.AuthenticatedUser.UserSignature; } #endregion if (!BadWordInfoProvider.CanUseBadWords(MembershipContext.AuthenticatedUser, SiteContext.CurrentSiteName)) { // Prepare columns to check Dictionary <string, int> columns = new Dictionary <string, int>(); columns.Add("PostText", 0); columns.Add("PostSubject", 450); columns.Add("PostUserSignature", 0); columns.Add("PostUserName", 200); // Perform bad words check string badMessage = BadWordsHelper.CheckBadWords(fp, columns, "PostApproved", "PostApprovedByUserID", fp.PostText, MembershipContext.AuthenticatedUser.UserID, () => { return(ValidatePost(fp)); }); if (String.IsNullOrEmpty(badMessage)) { if (!ValidatePost(fp)) { badMessage = GetString("ForumNewPost.EmptyBadWord"); } } if (!String.IsNullOrEmpty(badMessage)) { ShowError(badMessage); return; } } // Flood protection if (FloodProtectionHelper.CheckFlooding(SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { ShowError(GetString("General.FloodProtection")); return; } // Check banned ip if (!BannedIPInfoProvider.IsAllowed(SiteContext.CurrentSiteName, BanControlEnum.AllNonComplete)) { ShowError(GetString("General.BannedIP")); return; } string baseUrl = ForumContext.CurrentForum.ForumBaseUrl; if (String.IsNullOrEmpty(baseUrl)) { baseUrl = FriendlyBaseURL; } string unsubscriptionUrl = ForumContext.CurrentForum.ForumUnsubscriptionUrl; if (String.IsNullOrEmpty(unsubscriptionUrl)) { unsubscriptionUrl = UnsubscriptionURL; } // USe parent post id for new post int subscibePostId = newPost ? fp.PostParentID : fp.PostId; // Check subscriptions if ((chkSubscribe.Checked) && (!String.IsNullOrEmpty(txtEmail.Text)) && (ForumSubscriptionInfoProvider.IsSubscribed(txtEmail.Text.Trim(), fp.PostForumID, subscibePostId))) { // Post of the forum is already subscribed to this email -> show an error chkSubscribe.Checked = false; ShowError(GetString("Forums.EmailAlreadySubscribed")); return; } // Save post object ForumPostInfoProvider.SetForumPostInfo(fp, baseUrl, unsubscriptionUrl); LogPostActivity(fp, fi); #region "Subscription" // If subscribe is checked create new subscription to the current post if ((chkSubscribe.Checked) && (!ForumSubscriptionInfoProvider.IsSubscribed(fp.PostUserMail, fp.PostForumID, fp.PostId))) { // Create new subscription info object ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(); // Set info properties fsi.SubscriptionForumID = fp.PostForumID; fsi.SubscriptionEmail = fp.PostUserMail; fsi.SubscriptionPostID = fp.PostId; fsi.SubscriptionUserID = fp.PostUserID; fsi.SubscriptionGUID = Guid.NewGuid(); // Save subscription ForumSubscriptionInfoProvider.Subscribe(fsi, DateTime.Now, true, true); if (fsi.SubscriptionApproved) { LogSubscriptionActivity(fsi, fi); } } #endregion bool moderationRequired = false; if ((!fp.PostApproved) && (!ForumContext.UserIsModerator(fp.PostForumID, CommunityGroupID))) { moderationRequired = true; if (OnModerationRequired != null) { OnModerationRequired(this, null); } } // Keep current user info var currentUser = MembershipContext.AuthenticatedUser; if (AuthenticationHelper.IsAuthenticated() && chkAttachFile.Checked && (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || ForumContext.CurrentForum.AllowAttachFiles != SecurityAccessEnum.Nobody)) { // Redirect to the post attachments string attachmentUrl = GetURL(fp, ForumActionType.Attachment); if (moderationRequired) { attachmentUrl = URLHelper.AddParameterToUrl(attachmentUrl, "moderated", "1"); } URLHelper.Redirect(UrlResolver.ResolveUrl(attachmentUrl)); } else { if (!StopProcessing) { // Redirect back to the forum or forum thread URLHelper.Redirect(ClearURL()); } } }
/// <summary> /// Creates department forum group. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentForumGroup(TreeNode departmentNode) { // Set general values string departmentName = departmentNode.DocumentName; string suffix = ""; #region "Create forum group" // Get forum group code name string groupCodeName = "Department_" + departmentNode.NodeGUID; // Check if forum group with given name already exists if (ForumGroupInfoProvider.GetForumGroupInfo(groupCodeName, CMSContext.CurrentSiteID) != null) { return; } // Create base URL for forums string baseUrl = CMSContext.GetUrl(departmentNode.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS); ForumGroupInfo forumGroupObj = new ForumGroupInfo(); forumGroupObj.GroupDescription = "Forum group for " + departmentName + " department."; suffix = " forum group"; forumGroupObj.GroupDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumGroupObj.GroupName = groupCodeName; forumGroupObj.GroupOrder = 0; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupSiteID = CMSContext.CurrentSiteID; forumGroupObj.GroupBaseUrl = baseUrl; // Additional settings forumGroupObj.GroupEnableCodeSnippet = true; forumGroupObj.GroupEnableFontBold = true; forumGroupObj.GroupEnableFontColor = true; forumGroupObj.GroupEnableFontItalics = true; forumGroupObj.GroupEnableFontStrike = true; forumGroupObj.GroupEnableFontUnderline = true; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupEnableURL = true; forumGroupObj.GroupEnableImage = true; ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj); #endregion #region "Create forum" string codeName = "Default_department_" + departmentNode.NodeGUID; // Check if forum with given name already exists if (ForumInfoProvider.GetForumInfo(codeName, CMSContext.CurrentSite.SiteID) != null) { return; } ForumInfo forumObj = new ForumInfo(); forumObj.ForumSiteID = CMSContext.CurrentSiteID; forumObj.ForumIsLocked = false; forumObj.ForumOpen = true; forumObj.ForumDisplayEmails = false; forumObj.ForumDescription = "Forum for " + departmentName + " department."; forumObj.ForumRequireEmail = false; suffix = " forum"; forumObj.ForumDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumObj.ForumName = codeName; forumObj.ForumGroupID = forumGroupObj.GroupID; forumObj.ForumModerated = false; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = false; forumObj.SetValue("ForumHTMLEditor", null); // Set security forumObj.AllowAccess = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowAttachFiles = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowMarkAsAnswer = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowPost = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowReply = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowSubscribe = SecurityAccessEnum.AuthorizedRoles; if (ForumInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Forums, VersionActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); } #endregion }
/// <summary> /// Reloads the form data. /// </summary> public override void ReloadData() { fi = ForumInfoProvider.GetForumInfo(ForumID); replyPi = ForumPostInfoProvider.GetForumPostInfo(ReplyToPostID); editPi = ForumPostInfoProvider.GetForumPostInfo(EditPostID); var cui = MembershipContext.AuthenticatedUser; // Edit post if (editPi != null) { ForumPost1.PostID = editPi.PostId; ForumPost1.DisplayOnly = true; if (DisableCancelButton) { btnCancel.Enabled = false; } ucBBEditor.Text = editPi.PostText; htmlTemplateBody.ResolvedValue = editPi.PostText; txtSubject.Text = editPi.PostSubject; txtSignature.Text = editPi.PostUserSignature; txtEmail.Text = editPi.PostUserMail; txtUserName.Text = editPi.PostUserName; plcIsAnswer.Visible = true; plcIsNotAnswer.Visible = true; txtPostIsAnswer.Text = editPi.PostIsAnswer.ToString(); txtPostIsNotAnswer.Text = editPi.PostIsNotAnswer.ToString(); if ((fi != null) && (fi.ForumType == 0) && (editPi.PostLevel == 0)) { if (editPi.PostType == 0) { radTypeDiscussion.Checked = true; } else { radTypeQuestion.Checked = true; } } else { plcThreadType.Visible = false; } } else { // Reply to post if (replyPi != null) { pnlReplyPost.Visible = true; ForumPost1.PostID = replyPi.PostId; ForumPost1.DisplayOnly = true; plcThreadType.Visible = false; txtSignature.Text = cui.UserSignature; txtEmail.Text = cui.Email; if (!String.IsNullOrEmpty(cui.UserNickName)) { txtUserName.Text = cui.UserNickName.Trim(); } else { txtUserName.Text = Functions.GetFormattedUserName(cui.UserName, IsLiveSite); } if (!replyPi.PostSubject.StartsWithCSafe(GetString("Forums.ReplyPrefix"))) { txtSubject.Text = GetString("Forums.ReplyPrefix") + replyPi.PostSubject; txtSubject.Text = TextHelper.LimitLength(txtSubject.Text, POST_SUBJECT_LENGTH, ""); } else { txtSubject.Text = replyPi.PostSubject; } btnCancel.Enabled = true; } // Create new thread else { btnCancel.Enabled = false; txtSignature.Text = cui.UserSignature; txtEmail.Text = cui.Email; if (!String.IsNullOrEmpty(cui.UserNickName)) { txtUserName.Text = cui.UserNickName.Trim(); } else { txtUserName.Text = Functions.GetFormattedUserName(cui.UserName, IsLiveSite); } } } }
protected override void ShowPage() { GetPostAds(forumid); if (userid > 0 && useradminid > 0) { AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid); if (admingroupinfo != null) { disablepostctrl = admingroupinfo.Disablepostctrl; } } #region 获取版块信息 if (forumid == -1) { AddLinkRss(forumpath + "tools/rss.aspx", "最新主题"); AddErrLine("无效的版块ID"); return; } forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Fid < 1) { if (config.Rssstatus == 1) { AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题"); } AddErrLine("不存在的版块ID"); return; } #endregion if (config.Rssstatus == 1) { AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题"); } if (JumpUrl(forum)) { return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo); // 检查是否具有版主的身份 if (useradminid > 0) { ismoder = Moderators.IsModer(useradminid, userid, forumid); } //设置搜索和排序条件 SetSearchCondition(); showforumlogin = IsShowForumLogin(forum); pagetitle = Utils.RemoveHtml(forum.Name); navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname); forumnav = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"), forumid, pageid); topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans()); bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans()); #region 主题分类设置 if (forum.Applytopictype == 1) //启用主题分类 { topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); } if (forum.Viewbytopictype == 1) //允许按类别浏览 { topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx"); } #endregion //更新页面Meta中的keyword,description项, 提高SEO友好性 UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords, Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription, config.Seohead); //设置编辑器状态 SetEditorState(); #region 访问和发帖权限校验 if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg)) { AddErrLine(msg); needlogin = userid == -1; return; } canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg); // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖 if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(config.Postbanperiods, out visittime)) { canposttopic = false; } isnewbie = UserAuthority.CheckNewbieSpan(userid); } //判断是否有快速发主题的权限 if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && canposttopic && !isnewbie) { canquickpost = true; } #endregion // 得到子版块列表 if (forum.Subforumcount > 0) { subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay); } if (!forum.Rules.Equals("")) { forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB } //获取主题总数 topiccount = Topics.GetTopicCount(forumid, true, condition); #region 设置分页及主题列表信息 // 得到Tpp设置 if (tpp <= 0) { tpp = config.Tpp; } // 得到Ppp设置 if (ppp <= 0) { ppp = config.Ppp; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } int toptopicpagecount = 0; if (forum.Layer > 0) { //获取当前页置顶主题列表 DataRow dr = Topics.GetTopTopicListID(forumid); if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]); } //获取总页数 pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1; if (pagecount == 0) { pagecount = 1; } if (pageid > pagecount) { pageid = pagecount; } if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString())) { toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]); if (toptopiccount > tpp * (pageid - 1)) { toptopiclist = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix); toptopicpagecount = toptopiccount / tpp; } if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount)) { topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0); } else { topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp); } } else { toptopicpagecount = 0; topiclist = GetTopicInfoList(tpp, pageid, 0); } //如果topiclist为空则更新当前论坛帖数 if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount) { Forums.SetRealCurrentTopics(forum.Fid); } SetPageNumber(); //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单 showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1); SetVisitedForumsCookie(); //保存查看版块的页数 Utils.WriteCookie("forumpageid", pageid.ToString(), 30); //判断是否需要生成游客缓存页面 IsGuestCachePage(); } #endregion #region 替换版规中的UBB forum.Description = UBB.ParseSimpleUBB(forum.Description); #endregion #region 更新在线信息 OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, ""); if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes") { showforumonline = true; onlineuserlist = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest, out forumtotalonlineuser, out forumtotalonlineinvisibleuser); } //if (DNTRequest.GetString("showonline") != "no") //{ // showforumonline = false; //} if (DNTRequest.GetString("showonline") == "no") { showforumonline = false; } #endregion //修正版主列表 if (forum.Moderators.Trim() != "") { string moderHtml = string.Empty; foreach (string m in forum.Moderators.Split(',')) { moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m); } forum.Moderators = moderHtml.TrimEnd(','); } ForumUtils.UpdateVisitedForumsOptions(forumid); }
/// <summary> /// 发帖权限控制 /// </summary> /// <param name="forum">版块信息</param> /// <param name="usergroupinfo">当前用户的用户组信息</param> /// <param name="userId">当前用户Id</param> /// <returns></returns> public static bool PostAuthority(ForumInfo forum, UserGroupInfo userGroupInfo, int userId, ref string msg) { if (!Forums.AllowPostByUserID(forum.Permuserlist, userId)) //判断当前用户在当前版块发主题权限 { if (string.IsNullOrEmpty(forum.Postperm)) //权限设置为空时,根据用户组权限判断 { // 验证用户是否有发表主题的权限 if (userGroupInfo.Allowpost != 1) { msg = "您当前的身份 \"" + userGroupInfo.Grouptitle + "\" 没有发表主题的权限"; return(false); } } else//权限设置不为空时,根据板块权限判断 { if (!Forums.AllowPost(forum.Postperm, userGroupInfo.Groupid)) { msg = "您没有在该版块发表主题的权限"; return(false); } } } //当用户拥有发帖权限但版块只允许发布特殊主题时,需要判断用户是否能发布特殊主题 if (forum.Allowspecialonly > 0) { //当版块设置了只允许特殊主题,但又没有开启任何特殊主题类型,则相当于关闭了版块的发主题功能 if (forum.Allowpostspecial <= 0) { msg = "您没有在该版块发表特殊主题的权限"; return(false); } if ((forum.Allowpostspecial & 1) == 1 && userGroupInfo.Allowpostpoll != 1) { msg = "您当前的身份 \"" + userGroupInfo.Grouptitle + "\" 没有发布投票的权限"; } else { return(true); } if ((forum.Allowpostspecial & 4) == 4 && userGroupInfo.Allowbonus != 1) { msg = "您当前的身份 \"" + userGroupInfo.Grouptitle + "\" 没有发布悬赏的权限"; } else { return(true); } if ((forum.Allowpostspecial & 16) == 16 && userGroupInfo.Allowdebate != 1) { msg = "您当前的身份 \"" + userGroupInfo.Grouptitle + "\" 没有发起辩论的权限"; } else { return(true); } return(false); } return(true); }
abstract public bool BuildForum(string name); //made changes abstract public void CancelForum(ForumInfo f);
/// <summary> /// Generates the permission matrix for the current forum. /// </summary> private void CreateMatrix() { // Get forum resource info if (resForums == null) { resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); } // Get forum object if ((forum == null) && (ForumID > 0)) { forum = ForumInfoProvider.GetForumInfo(ForumID); } if ((resForums != null) && (forum != null)) { // Get permissions for the current forum resource DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resForums.ResourceId); if (DataHelper.DataSourceIsEmpty(permissions)) { ShowInformation(GetString("general.emptymatrix")); } else { TableHeaderRow headerRow = new TableHeaderRow(); headerRow.CssClass = "unigrid-head"; headerRow.TableSection = TableRowSection.TableHeader; TableCell newCell = new TableCell(); TableHeaderCell newHeaderCell = new TableHeaderCell(); newHeaderCell.CssClass = "first-column"; headerRow.Cells.Add(newHeaderCell); foreach (string permission in allowedPermissions) { DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'"); if (drArray.Length > 0) { DataRow dr = drArray[0]; newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = dr["PermissionDisplayName"].ToString(); newHeaderCell.ToolTip = dr["PermissionDescription"].ToString(); headerRow.Cells.Add(newHeaderCell); } else { throw new Exception("[Security matrix] Column '" + permission + "' cannot be found."); } } tblMatrix.Rows.Add(headerRow); // Render forum access permissions object[,] accessNames = new object[5, 2]; accessNames[0, 0] = GetString("security.nobody"); accessNames[0, 1] = SecurityAccessEnum.Nobody; accessNames[1, 0] = GetString("security.allusers"); accessNames[1, 1] = SecurityAccessEnum.AllUsers; accessNames[2, 0] = GetString("security.authenticated"); accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers; accessNames[3, 0] = GetString("security.groupmembers"); accessNames[3, 1] = SecurityAccessEnum.GroupMembers; accessNames[4, 0] = GetString("security.authorizedroles"); accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles; TableRow newRow = null; for (int access = 0; access <= accessNames.GetUpperBound(0); access++) { SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]); // If the security isn't displayed as part of group section if ((currentAccess == SecurityAccessEnum.GroupMembers) && (!IsGroupForum)) { // Do not render this access item } else { // Generate cell holding access item name newRow = new TableRow(); newCell = new TableCell(); newCell.Text = accessNames[access, 0].ToString(); newCell.CssClass = "matrix-header"; newRow.Cells.Add(newCell); // Render the permissions access items bool isAllowed = false; bool isEnabled = true; int permissionIndex = 0; for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 1); permission++) { newCell = new TableCell(); // Check if the currently processed access is applied for permission isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text); isEnabled = ((currentAccess != SecurityAccessEnum.AllUsers) || (permission != 1)) && Enable; // Disable column in roles grid if needed if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed) { gridMatrix.DisableColumn(permissionIndex); } // Insert the radio button for the current permission var radio = new CMSRadioButton { Checked = isAllowed, Enabled = isEnabled, }; radio.Attributes.Add("onclick", ControlsHelper.GetPostBackEventReference(this, permission + ";" + Convert.ToInt32(currentAccess))); newCell.Controls.Add(radio); newRow.Cells.Add(newCell); permissionIndex++; } // Add the access row to the table tblMatrix.Rows.Add(newRow); } } // Check if forum has some roles assigned headTitle.Visible = gridMatrix.HasData; } } }
/// <summary> /// Creates department forum group. /// </summary> /// <param name="departmentNode">Department node</param> private void CreateDepartmentForumGroup(TreeNode departmentNode) { // Set general values string departmentName = departmentNode.GetDocumentName(); string suffix = ""; #region "Create forum group" // Get forum group code name string groupCodeName = "Department_" + departmentNode.NodeGUID; // Check if forum group with given name already exists if (ForumGroupInfoProvider.GetForumGroupInfo(groupCodeName, SiteContext.CurrentSiteID) != null) { return; } // Create base URL for forums string baseUrl = DocumentURLProvider.GetUrl(departmentNode.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS); ForumGroupInfo forumGroupObj = new ForumGroupInfo(); forumGroupObj.GroupDescription = "Forum group for " + departmentName + " department."; suffix = " forum group"; forumGroupObj.GroupDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumGroupObj.GroupName = groupCodeName; forumGroupObj.GroupOrder = 0; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupSiteID = SiteContext.CurrentSiteID; forumGroupObj.GroupBaseUrl = baseUrl; // Additional settings forumGroupObj.GroupEnableCodeSnippet = true; forumGroupObj.GroupEnableFontBold = true; forumGroupObj.GroupEnableFontColor = true; forumGroupObj.GroupEnableFontItalics = true; forumGroupObj.GroupEnableFontStrike = true; forumGroupObj.GroupEnableFontUnderline = true; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupEnableURL = true; forumGroupObj.GroupEnableImage = true; ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj); #endregion #region "Create forum" string codeName = "Default_department_" + departmentNode.NodeGUID; // Check if forum with given name already exists if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSite.SiteID) != null) { return; } ForumInfo forumObj = new ForumInfo(); forumObj.ForumSiteID = SiteContext.CurrentSiteID; forumObj.ForumIsLocked = false; forumObj.ForumOpen = true; forumObj.ForumDisplayEmails = false; forumObj.ForumDescription = "Forum for " + departmentName + " department."; forumObj.ForumRequireEmail = false; suffix = " forum"; forumObj.ForumDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix; forumObj.ForumName = codeName; forumObj.ForumGroupID = forumGroupObj.GroupID; forumObj.ForumModerated = false; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = false; forumObj.SetValue("ForumHTMLEditor", null); // Set security forumObj.AllowAccess = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowAttachFiles = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowMarkAsAnswer = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowPost = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowReply = SecurityAccessEnum.AuthorizedRoles; forumObj.AllowSubscribe = SecurityAccessEnum.AuthorizedRoles; if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); } #endregion }
/// <summary> /// PreRender action on which security settings are set. /// </summary> private void Page_PreRender(object sender, EventArgs e) { if ((Form == null) || !mDocumentSaved) { return; } TreeNode editedNode = Form.EditedObject as TreeNode; // Create or rebuild department content index CreateDepartmentContentSearchIndex(editedNode); if ((editedNode == null) || !editedNode.NodeIsACLOwner) { return; } ForumInfo fi = ForumInfoProvider.GetForumInfo("Default_department_" + editedNode.NodeGUID, SiteContext.CurrentSiteID); MediaLibraryInfo mi = MediaLibraryInfoProvider.GetMediaLibraryInfo("Department_" + editedNode.NodeGUID, SiteContext.CurrentSiteName); // Check if forum of media library exists if ((fi == null) && (mi == null)) { return; } // Get allowed roles ID int aclID = ValidationHelper.GetInteger(editedNode.GetValue("NodeACLID"), 0); DataSet listRoles = AclItemInfoProvider.GetAllowedRoles(aclID, NodePermissionsEnum.Read, "RoleID"); IList <int> roleIds = null; if (!DataHelper.DataSourceIsEmpty(listRoles)) { roleIds = DataHelper.GetIntegerValues(listRoles.Tables[0], "RoleID") as List <int>; } // Set permissions for forum if (fi != null) { // Get resource object ResourceInfo resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); // Get permissions IDs var forumPermissions = PermissionNameInfoProvider.GetPermissionNames() .Column("PermissionID") .WhereEquals("ResourceID", resForums.ResourceID) .WhereNotEquals("PermissionName", CMSAdminControl.PERMISSION_READ) .WhereNotEquals("PermissionName", CMSAdminControl.PERMISSION_MODIFY); // Delete old permissions apart attach file permission ForumRoleInfoProvider.DeleteAllRoles(new WhereCondition().WhereEquals("ForumID", fi.ForumID).WhereIn("PermissionID", forumPermissions)); // Set forum permissions ForumRoleInfoProvider.SetPermissions(fi.ForumID, roleIds, forumPermissions.Select(p => p.PermissionId).ToArray()); // Log staging task SynchronizationHelper.LogObjectChange(fi, TaskTypeEnum.UpdateObject); } // Set permissions for media library if (mi == null) { return; } // Get resource object ResourceInfo resMediaLibs = ResourceInfoProvider.GetResourceInfo("CMS.MediaLibrary"); // Get permissions IDs var where = new WhereCondition() .WhereEquals("ResourceID", resMediaLibs.ResourceID) .And() .Where(new WhereCondition() .WhereEquals("PermissionName", "LibraryAccess") .Or() .WhereEquals("PermissionName", "FileCreate")); DataSet dsMediaLibPerm = PermissionNameInfoProvider.GetPermissionNames().Where(where).Column("PermissionID"); IList <int> mediaLibPermissionsIds = null; if (!DataHelper.DataSourceIsEmpty(dsMediaLibPerm)) { mediaLibPermissionsIds = DataHelper.GetIntegerValues(dsMediaLibPerm.Tables[0], "PermissionID"); } var deleteWhere = new WhereCondition() .WhereEquals("LibraryID", mi.LibraryID) .WhereIn("PermissionID", mediaLibPermissionsIds); // Delete old permissions only for Create file and See library content permissions MediaLibraryRolePermissionInfoProvider.DeleteAllRoles(deleteWhere.ToString(true)); MediaLibraryRolePermissionInfoProvider.SetPermissions(mi.LibraryID, roleIds, mediaLibPermissionsIds); // Log staging task; SynchronizationHelper.LogObjectChange(mi, TaskTypeEnum.UpdateObject); }
/// <summary> /// Reloads the data of the editing forum. /// </summary> /// <param name="forumObj">Forum object</param> private void ReloadData(ForumInfo forumObj) { // Set main properties this.chkForumOpen.Checked = forumObj.ForumOpen; this.chkForumLocked.Checked = forumObj.ForumIsLocked; this.txtForumDescription.Text = forumObj.ForumDescription; this.txtForumDisplayName.Text = forumObj.ForumDisplayName; this.txtForumName.Text = forumObj.ForumName; // Set other settings this.txtImageMaxSideSize.Text = forumObj.ForumImageMaxSideSize.ToString(); this.txtIsAnswerLimit.Text = forumObj.ForumIsAnswerLimit.ToString(); this.txtMaxAttachmentSize.Text = forumObj.ForumAttachmentMaxFileSize.ToString(); this.txtBaseUrl.Text = forumObj.ForumBaseUrl; this.txtUnsubscriptionUrl.Text = forumObj.ForumUnsubscriptionUrl; // Check if is inherited value bool inheritAuthorDelete = (forumObj.GetValue("ForumAuthorDelete") == null); bool inheritAuthorEdit = (forumObj.GetValue("ForumAuthorEdit") == null); bool inheritImageMaxSideSize = (forumObj.GetValue("ForumImageMaxSideSize") == null); bool inheritMaxAttachmentSize = (forumObj.GetValue("ForumAttachmentMaxFileSize") == null); bool inheritIsAnswerLimit = (forumObj.GetValue("ForumIsAnswerLimit") == null); bool inheritType = (forumObj.GetValue("ForumType") == null); bool inheritUseHTML = (forumObj.GetValue("ForumHTMLEditor") == null); bool inheritDislayEmails = (forumObj.GetValue("ForumDisplayEmails") == null); bool inheritRequireEmail = (forumObj.GetValue("ForumRequireEmail") == null); bool inheritCaptcha = (forumObj.GetValue("ForumUseCAPTCHA") == null); bool inheritBaseUrl = (forumObj.GetValue("ForumBaseUrl") == null); bool inheritUnsubscriptionUrl = (forumObj.GetValue("ForumUnsubscriptionUrl") == null); bool inheritLogActivity = (forumObj.GetValue("ForumLogActivity") == null); // Discussion bool inheritDiscussion = (forumObj.GetValue("ForumDiscussionActions") == null); // Set properties this.chkInheritUseHTML.Checked = inheritUseHTML; this.chkInheritDisplayEmails.Checked = inheritDislayEmails; this.chkInheritRequireEmail.Checked = inheritRequireEmail; this.chkInheritCaptcha.Checked = inheritCaptcha; this.chkInheritAuthorDelete.Checked = inheritAuthorDelete; this.chkInheritAuthorEdit.Checked = inheritAuthorEdit; this.txtImageMaxSideSize.Enabled = !inheritImageMaxSideSize; this.chkInheritMaxSideSize.Checked = inheritImageMaxSideSize; this.txtIsAnswerLimit.Enabled = !inheritIsAnswerLimit; this.chkInheritIsAnswerLimit.Checked = inheritIsAnswerLimit; this.chkInheritType.Checked = inheritType; this.txtMaxAttachmentSize.Enabled = !inheritMaxAttachmentSize; this.chkInheritMaxAttachmentSize.Checked = inheritMaxAttachmentSize; this.txtBaseUrl.Enabled = !inheritBaseUrl; this.chkInheritBaseUrl.Checked = inheritBaseUrl; this.txtUnsubscriptionUrl.Enabled = !inheritUnsubscriptionUrl; this.chkInheritUnsubscribeUrl.Checked = inheritUnsubscriptionUrl; this.plcOnline.Visible = ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(CMSContext.CurrentSiteName); this.chkInheritLogActivity.Checked = inheritLogActivity; // Discussion this.chkInheritDiscussion.Checked = inheritDiscussion; // Create script for update inherit values this.ltrScript.Text += ScriptHelper.GetScript( "LoadSetting('" + chkForumRequireEmail.ClientID + "', " + (forumObj.ForumRequireEmail ? "true" : "false") + ", " + (inheritRequireEmail ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkCaptcha.ClientID + "', " + (forumObj.ForumUseCAPTCHA ? "true" : "false") + ", " + (inheritCaptcha ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkForumDisplayEmails.ClientID + "', " + (forumObj.ForumDisplayEmails ? "true" : "false") + ", " + (inheritDislayEmails ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkUseHTML.ClientID + "', " + (forumObj.ForumHTMLEditor ? "true" : "false") + ", " + (inheritUseHTML ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkAuthorDelete.ClientID + "', " + (forumObj.ForumAuthorDelete ? "true" : "false") + ", " + (inheritAuthorDelete ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkAuthorEdit.ClientID + "', " + (forumObj.ForumAuthorEdit ? "true" : "false") + ", " + (inheritAuthorEdit ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkLogActivity.ClientID + "', " + (forumObj.ForumLogActivity ? "true" : "false") + ", " + (inheritLogActivity ? "true" : "false") + ", 'chk');" + // Discussion "LoadSetting('" + radImageSimple.ClientID + "', " + (forumObj.ForumEnableImage ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radImageAdvanced.ClientID + "', " + (forumObj.ForumEnableAdvancedImage ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radImageNo.ClientID + "', " + (!(forumObj.ForumEnableAdvancedImage || forumObj.ForumEnableImage) ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radUrlSimple.ClientID + "', " + (forumObj.ForumEnableURL ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radUrlAdvanced.ClientID + "', " + (forumObj.ForumEnableAdvancedURL ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radUrlNo.ClientID + "', " + (!(forumObj.ForumEnableAdvancedURL || forumObj.ForumEnableURL) ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + chkEnableQuote.ClientID + "', " + (forumObj.ForumEnableQuote ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableBold.ClientID + "', " + (forumObj.ForumEnableFontBold ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableItalic.ClientID + "', " + (forumObj.ForumEnableFontItalics ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableStrike.ClientID + "', " + (forumObj.ForumEnableFontStrike ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableUnderline.ClientID + "', " + (forumObj.ForumEnableFontUnderline ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableCode.ClientID + "', " + (forumObj.ForumEnableCodeSnippet ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableColor.ClientID + "', " + (forumObj.ForumEnableFontColor ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + radTypeAnswer.ClientID + "', " + (forumObj.ForumType == 2 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radTypeDiscussion.ClientID + "', " + (forumObj.ForumType == 1 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radTypeChoose.ClientID + "', " + (forumObj.ForumType == 0 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');"); ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forumObj.ForumGroupID); this.chkInheritUnsubscribeUrl.Attributes.Add("onclick", "SetInheritance('" + txtUnsubscriptionUrl.ClientID + "', '" + fgi.GroupUnsubscriptionUrl.Replace("'","\\\'") + "', 'txt');"); this.chkInheritBaseUrl.Attributes.Add("onclick", "SetInheritance('" + txtBaseUrl.ClientID + "', '" + fgi.GroupBaseUrl.Replace("'", "\\\'") + "', 'txt');"); // Settings inheritance this.chkInheritUseHTML.Attributes.Add("onclick", "SetInheritance('" + chkUseHTML.ClientID + "', '" + fgi.GroupHTMLEditor.ToString().ToLower() + "', 'chk');"); this.chkInheritCaptcha.Attributes.Add("onclick", "SetInheritance('" + chkCaptcha.ClientID + "', '" + fgi.GroupUseCAPTCHA.ToString().ToLower() + "', 'chk');"); this.chkInheritRequireEmail.Attributes.Add("onclick", "SetInheritance('" + chkForumRequireEmail.ClientID + "', '" + fgi.GroupRequireEmail.ToString().ToLower() + "', 'chk');"); this.chkInheritDisplayEmails.Attributes.Add("onclick", "SetInheritance('" + chkForumDisplayEmails.ClientID + "', '" + fgi.GroupDisplayEmails.ToString().ToLower() + "', 'chk');"); this.chkInheritAuthorDelete.Attributes.Add("onclick", "SetInheritance('" + chkAuthorDelete.ClientID + "', '" + fgi.GroupAuthorDelete.ToString().ToLower() + "', 'chk');"); this.chkInheritAuthorEdit.Attributes.Add("onclick", "SetInheritance('" + chkAuthorEdit.ClientID + "', '" + fgi.GroupAuthorEdit.ToString().ToLower() + "', 'chk');"); this.chkInheritIsAnswerLimit.Attributes.Add("onclick", "SetInheritance('" + txtIsAnswerLimit.ClientID + "', '" + fgi.GroupIsAnswerLimit.ToString().Replace("'", "\\\'") + "', 'txt');"); this.chkInheritMaxSideSize.Attributes.Add("onclick", "SetInheritance('" + txtImageMaxSideSize.ClientID + "', '" + fgi.GroupImageMaxSideSize.ToString().Replace("'", "\\\'") + "', 'txt');"); this.chkInheritType.Attributes.Add("onclick", "SetInheritance('" + radTypeAnswer.ClientID + "', '" + (fgi.GroupType == 2 ? "true" : "false") + "', 'rad');" + "SetInheritance('" + radTypeDiscussion.ClientID + "', '" + (fgi.GroupType == 1 ? "true" : "false") + "', 'rad');" + "SetInheritance('" + radTypeChoose.ClientID + "', '" + (fgi.GroupType == 0 ? "true" : "false") + "', 'rad');"); this.chkInheritMaxAttachmentSize.Attributes.Add("onclick", "SetInheritance('" + txtMaxAttachmentSize.ClientID + "','" + fgi.GroupAttachmentMaxFileSize.ToString().Replace("'", "\\\'") + "', 'txt');"); this.chkInheritLogActivity.Attributes.Add("onclick", "SetInheritance('" + chkLogActivity.ClientID + "','" + fgi.GroupLogActivity.ToString().ToLower() + "', 'chk');"); // Discussion string chkList = "'" + radImageSimple.ClientID + ";" + chkEnableBold.ClientID + ";" + chkEnableCode.ClientID + ";" + chkEnableColor.ClientID + ";" + radUrlSimple.ClientID + ";" + chkEnableItalic.ClientID + ";" + radImageAdvanced.ClientID + ";" + radUrlAdvanced.ClientID + ";" + chkEnableQuote.ClientID + ";" + chkEnableStrike.ClientID + ";" + chkEnableUnderline.ClientID + ";" + radImageNo.ClientID + ";" + radUrlNo.ClientID + "'"; string chkListValues = "'" + fgi.GroupEnableImage.ToString() + ";" + fgi.GroupEnableFontBold.ToString() + ";" + fgi.GroupEnableCodeSnippet.ToString() + ";" + fgi.GroupEnableFontColor.ToString() + ";" + fgi.GroupEnableURL.ToString() + ";" + fgi.GroupEnableFontItalics.ToString() + ";" + fgi.GroupEnableAdvancedImage.ToString() + ";" + fgi.GroupEnableAdvancedURL.ToString() + ";" + fgi.GroupEnableQuote.ToString() + ";" + fgi.GroupEnableFontStrike.ToString() + ";" + fgi.GroupEnableFontUnderline.ToString() + ";" + !(fgi.GroupEnableAdvancedImage || fgi.GroupEnableImage) + ";" + !(fgi.GroupEnableAdvancedURL || fgi.GroupEnableURL) + "'"; this.chkInheritDiscussion.Attributes.Add("onclick", "SetInheritance(" + chkList + ", " + chkListValues.ToLower() + ", 'chk');"); }
/// <summary> /// Creates group forum. /// </summary> /// <param name="group">Particular group info object</param> private void CreateGroupForum(GroupInfo group) { #region "Create forum group" // Get forum group code name string forumGroupCodeName = "Forums_group_" + group.GroupGUID; // Check if forum group with given name already exists if (ForumGroupInfoProvider.GetForumGroupInfo(forumGroupCodeName, SiteContext.CurrentSiteID) != null) { return; } // Create forum base URL string baseUrl = null; TreeNode groupDocument = TreeProvider.SelectSingleNode(group.GroupNodeGUID, DocumentContext.CurrentDocumentCulture.CultureCode, SiteContext.CurrentSiteName); if (groupDocument != null) { baseUrl = DocumentURLProvider.GetUrl(groupDocument.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS); } ForumGroupInfo forumGroupObj = new ForumGroupInfo(); const string suffix = " forums"; forumGroupObj.GroupDisplayName = TextHelper.LimitLength(group.GroupDisplayName, 200 - suffix.Length, string.Empty) + suffix; forumGroupObj.GroupName = forumGroupCodeName; forumGroupObj.GroupOrder = 0; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupGroupID = group.GroupID; forumGroupObj.GroupSiteID = SiteContext.CurrentSiteID; forumGroupObj.GroupBaseUrl = baseUrl; // Additional settings forumGroupObj.GroupEnableCodeSnippet = true; forumGroupObj.GroupEnableFontBold = true; forumGroupObj.GroupEnableFontColor = true; forumGroupObj.GroupEnableFontItalics = true; forumGroupObj.GroupEnableFontStrike = true; forumGroupObj.GroupEnableFontUnderline = true; forumGroupObj.GroupEnableQuote = true; forumGroupObj.GroupEnableURL = true; forumGroupObj.GroupEnableImage = true; // Set forum group info ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj); #endregion #region "Create forum" string codeName = "General_discussion_group_" + group.GroupGUID; // Check if forum with given name already exists if (ForumInfoProvider.GetForumInfo(codeName, SiteContext.CurrentSiteID, group.GroupID) != null) { return; } // Create new forum object ForumInfo forumObj = new ForumInfo(); forumObj.ForumSiteID = SiteContext.CurrentSiteID; forumObj.ForumIsLocked = false; forumObj.ForumOpen = true; forumObj.ForumDisplayEmails = false; forumObj.ForumRequireEmail = false; forumObj.ForumDisplayName = "General discussion"; forumObj.ForumName = codeName; forumObj.ForumGroupID = forumGroupObj.GroupID; forumObj.ForumModerated = false; forumObj.ForumAccess = 40000; forumObj.ForumPosts = 0; forumObj.ForumThreads = 0; forumObj.ForumPostsAbsolute = 0; forumObj.ForumThreadsAbsolute = 0; forumObj.ForumOrder = 0; forumObj.ForumUseCAPTCHA = false; forumObj.SetValue("ForumHTMLEditor", null); // Set security forumObj.AllowAccess = SecurityAccessEnum.GroupMembers; forumObj.AllowAttachFiles = SecurityAccessEnum.GroupMembers; forumObj.AllowMarkAsAnswer = SecurityAccessEnum.GroupMembers; forumObj.AllowPost = SecurityAccessEnum.GroupMembers; forumObj.AllowReply = SecurityAccessEnum.GroupMembers; forumObj.AllowSubscribe = SecurityAccessEnum.GroupMembers; if (ForumInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Forums, ObjectActionEnum.Insert)) { ForumInfoProvider.SetForumInfo(forumObj); } #endregion }
/// <summary> /// Generates the permission matrix for the current forum. /// </summary> private void CreateMatrix() { // Get forum resource info if (resForums == null) { resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); } // Get forum object if ((forum == null) && (ForumID > 0)) { forum = ForumInfoProvider.GetForumInfo(ForumID); } if ((resForums != null) && (forum != null)) { // Get permission matrix for roles of the current site/group int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Get permissions for the current forum resource DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resForums.ResourceId); if (DataHelper.DataSourceIsEmpty(permissions)) { ShowInformation(GetString("general.emptymatrix")); } else { TableRow headerRow = new TableRow(); headerRow.CssClass = "UniGridHead"; TableCell newCell = new TableCell(); TableHeaderCell newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = " "; newHeaderCell.Attributes["style"] = "width:200px;"; headerRow.Cells.Add(newHeaderCell); foreach (string permission in allowedPermissions) { DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'"); if ((drArray != null) && (drArray.Length > 0)) { DataRow dr = drArray[0]; newHeaderCell = new TableHeaderCell(); newHeaderCell.Attributes["style"] = "text-align:center;white-space:nowrap;"; newHeaderCell.Text = dr["PermissionDisplayName"].ToString(); newHeaderCell.ToolTip = dr["PermissionDescription"].ToString(); newHeaderCell.HorizontalAlign = HorizontalAlign.Center; headerRow.Cells.Add(newHeaderCell); } else { throw new Exception("[Security matrix] Column '" + permission + "' cannot be found."); } } newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = " "; headerRow.Cells.Add(newHeaderCell); tblMatrix.Rows.Add(headerRow); // Render forum access permissions object[,] accessNames = new object[5, 2]; accessNames[0, 0] = GetString("security.nobody"); accessNames[0, 1] = SecurityAccessEnum.Nobody; accessNames[1, 0] = GetString("security.allusers"); accessNames[1, 1] = SecurityAccessEnum.AllUsers; accessNames[2, 0] = GetString("security.authenticated"); accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers; accessNames[3, 0] = GetString("security.groupmembers"); accessNames[3, 1] = SecurityAccessEnum.GroupMembers; accessNames[4, 0] = GetString("security.authorizedroles"); accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles; TableRow newRow = null; int rowIndex = 0; for (int access = 0; access <= accessNames.GetUpperBound(0); access++) { SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]); // If the security isn't displayed as part of group section if ((currentAccess == SecurityAccessEnum.GroupMembers) && (!IsGroupForum)) { // Do not render this access item } else { // Generate cell holding access item name newRow = new TableRow(); newRow.CssClass = ((rowIndex % 2 == 0) ? "EvenRow" : "OddRow"); newCell = new TableCell(); newCell.Text = accessNames[access, 0].ToString(); newCell.Wrap = false; newCell.CssClass = "MatrixHeader"; newCell.Width = new Unit(28, UnitType.Percentage); newRow.Cells.Add(newCell); rowIndex++; // Render the permissions access items bool isAllowed = false; bool isDisabled = true; int permissionIndex = 0; for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 2); permission++) { newCell = new TableCell(); // Check if the currently processed access is applied for permission isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text); isDisabled = ((currentAccess == SecurityAccessEnum.AllUsers) && (permission == 1)) || (!Enable); // Disable column in roles grid if needed if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed) { gridMatrix.DisableColumn(permissionIndex); } // Insert the radio button for the current permission string permissionText = tblMatrix.Rows[0].Cells[permission + 1].Text; string elemId = ClientID + "_" + permission + "_" + access; newCell.Text = "<label style=\"display:none;\" for=\"" + elemId + "\">" + permissionText + "</label><input type=\"radio\" id=\"" + elemId + "\" name=\"" + permissionText + "\" onclick=\"" + ControlsHelper.GetPostBackEventReference(this, permission.ToString() + ";" + Convert.ToInt32(currentAccess).ToString()) + "\" " + ((isAllowed) ? "checked = \"checked\"" : "") + ((isDisabled) ? " disabled=\"disabled\"" : "") + "/>"; newCell.Wrap = false; newCell.Width = new Unit(12, UnitType.Percentage); newCell.HorizontalAlign = HorizontalAlign.Center; newRow.Cells.Add(newCell); permissionIndex++; } newCell = new TableCell(); newCell.Text = " "; newRow.Cells.Add(newCell); // Add the access row to the table tblMatrix.Rows.Add(newRow); } } // Check if forum has some roles assigned mNoRolesAvailable = !gridMatrix.HasData; // Get permission matrix for current forum resource if (!mNoRolesAvailable) { // Security - Role separator newRow = new TableRow(); newCell = new TableCell(); newCell.Text = " "; newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count)); newRow.Controls.Add(newCell); tblMatrix.Rows.Add(newRow); // Security - Role separator text newRow = new TableRow(); newCell = new TableCell(); newCell.CssClass = "MatrixLabel"; newCell.Text = GetString("SecurityMatrix.RolesAvailability"); newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count)); newRow.Controls.Add(newCell); tblMatrix.Rows.Add(newRow); } } } }
/// <summary> /// Logs "post" activity. /// </summary> /// <param name="bci">Forum subscription</param> /// <param name="fi">Forum info</param> private void LogPostActivity(ForumPostInfo fp, ForumInfo fi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (fp == null) || (fi == null) || !fi.ForumLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ForumPostsEnabled(siteName)) { return; } int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary<string, object> contactData = new Dictionary<string, object>(); contactData.Add("ContactEmail", fp.PostUserMail); contactData.Add("ContactLastName", fp.PostUserName); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.FORUM_POST, TitleData = fi.ForumName, ItemID = fi.ForumID, ItemDetailID = fp.PostId, URL = URLHelper.CurrentRelativePath, NodeID = CMSContext.CurrentDocument.NodeID, Culture = CMSContext.CurrentDocument.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
public void LoadCurrentForumInfo(int fid) { #region 加载相关信息 if (fid > 0) { forumInfo = Forums.GetForumInfo(fid); } else { return; } if (forumInfo.Layer > 0) { tabPage2.Visible = true; tabPage6.Visible = true; } else { //删除掉"高级设置"属性页 TabControl1.Items.Remove(tabPage2); tabPage2.Visible = false; //删除掉"特殊用户"属性页 TabControl1.Items.Remove(tabPage4); tabPage4.Visible = false; //删除掉"主题分类"属性页 TabControl1.Items.Remove(tabPage5); tabPage5.Visible = false; //删除掉"统计信息"属性页 TabControl1.Items.Remove(tabPage6); tabPage6.Visible = false; templatestyle.Visible = false; } forumname.Text = forumInfo.Name.Trim(); name.Text = forumInfo.Name.Trim(); displayorder.Text = forumInfo.Displayorder.ToString(); status.SelectedValue = forumInfo.Status.ToString(); if (forumInfo.Colcount == 1) { showcolnum.Attributes.Add("style", "display:none"); colcount.SelectedIndex = 0; } else { showcolnum.Attributes.Add("style", "display:block"); colcount.SelectedIndex = 1; } colcount.Attributes.Add("onclick", "javascript:document.getElementById('" + showcolnum.ClientID + "').style.display= (document.getElementById('TabControl1_tabPage1_colcount_0').checked ? 'none' : 'block');"); colcountnumber.Text = forumInfo.Colcount.ToString(); templateid.SelectedValue = forumInfo.Templateid.ToString(); forumsstatic.Text = string.Format("主题总数:{0}<br />帖子总数:{1}<br />今日回帖数总数:{2}<br />最后提交日期:{3}", forumInfo.Topics.ToString(), forumInfo.Posts.ToString(), forumInfo.Todayposts.ToString(), forumInfo.Lastpost.ToString()); ViewState["forumsstatic"] = forumsstatic.Text; if (forumInfo.Allowsmilies == 1) { setting.Items[0].Selected = true; } if (forumInfo.Allowrss == 1) { setting.Items[1].Selected = true; } if (forumInfo.Allowbbcode == 1) { setting.Items[2].Selected = true; } if (forumInfo.Allowimgcode == 1) { setting.Items[3].Selected = true; } if (forumInfo.Recyclebin == 1) { setting.Items[4].Selected = true; } if (forumInfo.Modnewposts == 1) { setting.Items[5].Selected = true; } if (forumInfo.Disablewatermark == 1) { setting.Items[6].Selected = true; } if (forumInfo.Inheritedmod == 1) { setting.Items[7].Selected = true; } if (forumInfo.Allowthumbnail == 1) { setting.Items[8].Selected = true; } if (forumInfo.Allowtag == 1) { setting.Items[9].Selected = true; } allowspecialonly.SelectedValue = forumInfo.Allowspecialonly.ToString(); if (forumInfo.Autoclose == 0) { showclose.Attributes.Add("style", "display:none"); autocloseoption.SelectedIndex = 0; } else { autocloseoption.SelectedIndex = 1; } autocloseoption.Attributes.Add("onclick", "javascript:document.getElementById('" + showclose.ClientID + "').style.display= (document.getElementById('TabControl1_tabPage2_autocloseoption_0').checked ? 'none' : 'block');"); autocloseday.Text = forumInfo.Autoclose.ToString(); //提取高级信息 description.Text = forumInfo.Description.Trim(); password.Text = forumInfo.Password.Trim(); icon.Text = forumInfo.Icon.Trim(); redirect.Text = forumInfo.Redirect.Trim(); moderators.Text = forumInfo.Moderators.Trim(); inheritmoderators.Text = Users.GetModerators(fid); rules.Text = forumInfo.Rules.Trim(); topictypes.Text = forumInfo.Topictypes.Trim(); DataTable dt = UserGroups.GetUserGroupForDataTable(); int i = 1; foreach (DataRow dr in dt.Rows) { HtmlTableRow tr = new HtmlTableRow(); HtmlTableCell td = new HtmlTableCell("td"); if (i % 2 == 1) { td.Attributes.Add("class", "td_alternating_item1"); } else { td.Attributes.Add("class", "td_alternating_item2"); } td.Controls.Add(new LiteralControl("<input type='checkbox' id='r" + i + "' onclick='selectRow(" + i + ",this.checked)'>")); tr.Cells.Add(td); td = new HtmlTableCell("td"); if (i % 2 == 1) { td.Attributes.Add("class", "td_alternating_item1"); } else { td.Attributes.Add("class", "td_alternating_item2"); } td.Controls.Add(new LiteralControl("<label for='r" + i + "'>" + dr["grouptitle"].ToString() + "</lable>")); tr.Cells.Add(td); tr.Cells.Add(GetTD("viewperm", forumInfo.Viewperm.Trim(), dr["groupid"].ToString(), i)); tr.Cells.Add(GetTD("postperm", forumInfo.Postperm.Trim(), dr["groupid"].ToString(), i)); tr.Cells.Add(GetTD("replyperm", forumInfo.Replyperm.Trim(), dr["groupid"].ToString(), i)); tr.Cells.Add(GetTD("getattachperm", forumInfo.Getattachperm.Trim(), dr["groupid"].ToString(), i)); tr.Cells.Add(GetTD("postattachperm", forumInfo.Postattachperm.Trim(), dr["groupid"].ToString(), i)); powerset.Rows.Add(tr); i++; } dt = Attachments.GetAttachmentType(); attachextensions.SetSelectByID(forumInfo.Attachextensions.Trim()); if (fid > 0) { forumInfo = Forums.GetForumInfo(fid); } else { return; } applytopictype.SelectedValue = forumInfo.Applytopictype.ToString(); postbytopictype.SelectedValue = forumInfo.Postbytopictype.ToString(); viewbytopictype.SelectedValue = forumInfo.Viewbytopictype.ToString(); topictypeprefix.SelectedValue = forumInfo.Topictypeprefix.ToString(); #endregion }
protected void Page_Load(object sender, EventArgs e) { EnsureEditedObject(); // Show back link if is opened from listing if (!String.IsNullOrEmpty(ListingPost) && (PostInfo != null)) { mListingParameter = "&listingpost=" + HTMLHelper.HTMLEncode(ListingPost); } mThreadMove = Page.LoadUserControl("~/CMSModules/Forums/Controls/ThreadMove.ascx") as ForumViewer; mThreadMove.ID = "ctrlThreadMove"; mThreadMove.IsLiveSite = IsLiveSite; plcThreadMove.Controls.Add(mThreadMove); if (!Visible) { EnableViewState = false; } PostEdit1.OnCancelClick += ForumNewPost1_OnCancelClick; PostEdit1.OnCheckPermissions += PostEdit1_OnCheckPermissions; PostEdit1.IsLiveSite = false; if (Reply != 0) { NewThreadTitle.TitleText = GetString("ForumPost_View.PostTitleText"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ReplyToPostID = PostID; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { //New thread if (NewForumPostIsBeingCreated) { NewThreadTitle.TitleText = GetString("ForumPost_View.NewThreadHeaderCaption"); pnlBody.Visible = false; PanelNewThread.Visible = true; PostEdit1.ForumID = ForumID; PostEdit1.OnInsertPost += ForumNewPost1_OnInsertPost; } else { // ReSharper disable once PossibleNullReferenceException - edited object is ensured => no null reference is possible ForumInfo fi = ForumInfoProvider.GetForumInfo(PostInfo.PostForumID); if (fi != null) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumScripts", ScriptHelper.GetScript(" function ReplyToPost(postId)\n" + "{ if (postId != 0){\n" + "location.href='ForumPost_View.aspx?postid=' + postId + '&reply=1&forumId=" + fi.ForumID + mListingParameter + "' }}\n")); } InitializeMenu(); ltlScript.Text += ScriptHelper.GetScript( "function DeletePost(postId) { if (confirm(" + ScriptHelper.GetString(GetString("ForumPost_View.DeleteConfirmation")) + ")) { " + Page.ClientScript.GetPostBackEventReference(btnDelete, null) + "; } } \n" + "function ApprovePost(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" + "function ApproveSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnApproveSubTree, null) + "; } \n" + "function RejectSubTree(postId) { " + Page.ClientScript.GetPostBackEventReference(btnRejectSubTree, null) + "; } \n" + "function StickThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnStickThread, null) + "; } \n" + "function SplitThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnSplitThread, null) + "; } \n" + "function LockThread(postId) { " + Page.ClientScript.GetPostBackEventReference(btnLockThread, null) + "; } \n" ); ForumPost1.ForumID = ForumID; ForumPost1.PostID = PostID; ForumPost1.DisplayOnly = true; if (PostInfo.PostAttachmentCount > 0) { ReloadAttachmentData(PostID); } } } }
/// <summary> /// Initialize resources, holders, controls etc. /// </summary> protected void Initialize() { #region "Captcha" // Hide captcha when not needed if (!ForumContext.CurrentForum.ForumUseCAPTCHA || (ForumContext.CurrentState == ForumStateEnum.EditPost)) { plcCaptcha.Visible = false; } #endregion #region "Settings of HTML editor" // Set HTML editor properties htmlTemplateBody.AutoDetectLanguage = false; htmlTemplateBody.DefaultLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; htmlTemplateBody.EditorAreaCSS = ""; htmlTemplateBody.ToolbarSet = "Forum"; htmlTemplateBody.DisableObjectResizing = true; // Disable image resizing htmlTemplateBody.RemovePlugins.Add("contextmenu"); // Disable context menu htmlTemplateBody.IsLiveSite = IsLiveSite; htmlTemplateBody.MediaDialogConfig.UseFullURL = true; htmlTemplateBody.LinkDialogConfig.UseFullURL = true; #endregion #region "Resource strings" // Resources rfvSubject.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.subjectErrorMsg"); lblText.Text = GetString("Forums_WebInterface_ForumNewPost.text"); rfvText.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.textErrorMsg"); rfvUserName.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.usernameErrorMsg"); btnOk.Text = GetString("general.ok"); btnCancel.Text = GetString("general.cancel"); btnPreview.Text = GetString("Forums_WebInterface_ForumNewPost.Preview"); lblSubscribe.Text = GetString("Forums_WebInterface_ForumNewPost.Subscription"); lblSignature.Text = GetString("Forums_WebInterface_ForumNewPost.Signature"); lblCaptcha.Text = GetString("Forums_WebInterface_ForumNewPost.captcha"); lblAttachFile.Text = GetString("For.NewPost.Attach"); lblNickName.Text = GetString("Forums_WebInterface_ForumNewPost.NickName"); // WAI validation lblCaptcha.AssociatedControlClientID = SecurityCode1.InputClientID; #endregion #region "Controls visibility" ForumInfo fi = ForumContext.CurrentForum; // Hide or display html editor/ text area if (fi.ForumHTMLEditor) { ucBBEditor.Visible = false; rfvText.Enabled = false; // Define customizable shortcuts Hashtable keystrokes = new Hashtable() { { "link", "CKEDITOR.CTRL + 76 /*L*/" }, { "bold", "CKEDITOR.CTRL + 66 /*B*/" }, { "italic", "CKEDITOR.CTRL + 73 /*I*/" }, { "underline", "CKEDITOR.CTRL + 85 /*U*/" } }; if (!fi.ForumEnableURL) { htmlTemplateBody.RemoveButtons.Add("InsertUrl"); if (!fi.ForumEnableAdvancedURL) { // Remove the keyborad shortcut for the link insertion keystrokes.Remove("link"); } } if (!fi.ForumEnableAdvancedURL) { htmlTemplateBody.RemoveButtons.Add("InsertLink"); } if (!fi.ForumEnableImage) { htmlTemplateBody.RemoveButtons.Add("InsertImage"); } if (!fi.ForumEnableAdvancedImage) { htmlTemplateBody.RemoveButtons.Add("InsertImageOrMedia"); } if (!fi.ForumEnableQuote) { htmlTemplateBody.RemoveButtons.Add("InsertQuote"); } if (!fi.ForumEnableFontBold) { htmlTemplateBody.RemoveButtons.Add("Bold"); keystrokes.Remove("bold"); } if (!fi.ForumEnableFontItalics) { htmlTemplateBody.RemoveButtons.Add("Italic"); keystrokes.Remove("italic"); } if (!fi.ForumEnableFontUnderline) { htmlTemplateBody.RemoveButtons.Add("Underline"); keystrokes.Remove("underline"); } if (!fi.ForumEnableFontStrike) { htmlTemplateBody.RemoveButtons.Add("Strike"); } if (!fi.ForumEnableFontColor) { htmlTemplateBody.RemoveButtons.Add("TextColor"); htmlTemplateBody.RemoveButtons.Add("BGColor"); } // Generate keystrokes string for the CK Editor StringBuilder sb = new StringBuilder("[ [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ], [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], [ CKEDITOR.ALT + ( CKEDITOR.env.ie || CKEDITOR.env.webkit ? 189 : 109 ) /*-*/, 'toolbarCollapse' ], [ CKEDITOR.ALT + 48 /*0*/, 'a11yHelp' ]"); string format = ", [ {0}, '{1}' ]"; foreach (DictionaryEntry entry in keystrokes) { sb.Append(String.Format(format, entry.Value, entry.Key)); } sb.Append("]"); htmlTemplateBody.Keystrokes = sb.ToString(); } else { ucBBEditor.IsLiveSite = IsLiveSite; ucBBEditor.ShowImage = fi.ForumEnableImage; ucBBEditor.ShowQuote = fi.ForumEnableQuote; ucBBEditor.ShowURL = fi.ForumEnableURL; ucBBEditor.ShowBold = fi.ForumEnableFontBold; ucBBEditor.ShowItalic = fi.ForumEnableFontItalics; ucBBEditor.ShowUnderline = fi.ForumEnableFontUnderline; ucBBEditor.ShowStrike = fi.ForumEnableFontStrike; ucBBEditor.ShowColor = fi.ForumEnableFontColor; ucBBEditor.ShowCode = fi.ForumEnableCodeSnippet; ucBBEditor.ShowAdvancedImage = fi.ForumEnableAdvancedImage; ucBBEditor.ShowAdvancedURL = fi.ForumEnableAdvancedURL; htmlTemplateBody.Visible = false; } if ((fi.ForumModerated) && (!ForumContext.UserIsModerator(fi.ForumID, CommunityGroupID))) { ShowInformation(GetString("forums.requiremoderation")); } bool userCanModerate = fi.ForumModerated && ForumContext.UserIsModerator(fi.ForumID, CommunityGroupID); if ((MembershipContext.AuthenticatedUser.IsPublic()) || (!ForumInfoProvider.IsAuthorizedPerForum(fi.ForumID, fi.ForumGroupID, "AttachFiles", fi.AllowAttachFiles, MembershipContext.AuthenticatedUser) && !userCanModerate)) { plcAttachFile.Visible = false; } // If user can choose thread type and this is not reply, show the options if ((fi.ForumType == 0) && (ForumContext.CurrentReplyThread == null)) { // Only thread can be set if ((ForumContext.CurrentState != ForumStateEnum.EditPost) || (ForumContext.CurrentPost.PostLevel == 0)) { plcThreadType.Visible = true; } } // Hide or display subscription checkbox with dependence // on allow subscription property value and security if ((!AllowSubscription) || (!ForumInfoProvider.IsAuthorizedPerForum(fi.ForumID, fi.ForumGroupID, "Subscribe", fi.AllowSubscribe, MembershipContext.AuthenticatedUser))) { SubscribeHolder.Visible = false; } // Display signature if is allowed if (!AllowSignature) { plcSignature.Visible = false; } // Display username textbox if is change name allowed or label with user name if (fi.ForumAllowChangeName || MembershipContext.AuthenticatedUser.IsPublic() || ((ForumContext.CurrentForum != null) && (ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, ForumContext.CommunityGroupID)))) { if (!RequestHelper.IsPostBack()) { // Do not show 'public' for unauthenticated user if (!MembershipContext.AuthenticatedUser.IsPublic()) { txtUserName.Text = UserName; } } plcNickName.Visible = false; } else { if (ForumContext.CurrentMode != ForumMode.Edit) { lblNickNameValue.Text = HTMLHelper.HTMLEncode(UserName); } else { lblNickNameValue.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentPost.PostUserName); } plcUserName.Visible = false; } // Prefill user email and reset the security code if (!RequestHelper.IsPostBack()) { txtEmail.Text = MembershipContext.AuthenticatedUser.Email; } if (ForumContext.CurrentReplyThread != null) { string replyPrefix = GetString("forums.replyprefix"); if (!ForumContext.CurrentReplyThread.PostSubject.StartsWithCSafe(replyPrefix)) { txtSubject.Text = replyPrefix + ForumContext.CurrentReplyThread.PostSubject; txtSubject.Text = TextHelper.LimitLength(txtSubject.Text, POST_SUBJECT_LENGTH, ""); } else { txtSubject.Text = ForumContext.CurrentReplyThread.PostSubject; } txtSubject.Text = txtSubject.Text; // New post - check max level for subscribcribtion if (ForumContext.CurrentReplyThread.PostLevel >= ForumPostInfoProvider.MaxPostLevel - 1) { SubscribeHolder.Visible = false; } } // Edit post - check max level for subscribcribtion else if ((ForumContext.CurrentPost != null) && (ForumContext.CurrentPost.PostLevel >= ForumPostInfoProvider.MaxPostLevel)) { SubscribeHolder.Visible = false; } // Hide subscription if not enabled if (!EnableSubscription) { SubscribeHolder.Visible = false; } #endregion #region "Post Data" if (!RequestHelper.IsPostBack()) { // Check whether current state is edit if (ForumContext.CurrentState == ForumStateEnum.EditPost) { txtEmail.Text = ForumContext.CurrentPost.PostUserMail; txtSignature.Text = ForumContext.CurrentPost.PostUserSignature; txtSubject.Text = ForumContext.CurrentPost.PostSubject; txtUserName.Text = ForumContext.CurrentPost.PostUserName; SetPostText(ForumContext.CurrentPost.PostText); radTypeDiscussion.Checked = true; if (ForumContext.CurrentPost.PostType == 1) { radTypeQuestion.Checked = true; } } else if ((ForumContext.CurrentMode == ForumMode.Quote) && (ForumContext.CurrentReplyThread != null)) { // Indicates whether wysiwyg editor is used bool isHtml = ForumContext.CurrentForum.ForumHTMLEditor; // Keeps post user name string userName = ForumContext.CurrentReplyThread.PostUserName; // Encode username for wysiwyg editor if (isHtml) { userName = HTMLHelper.HTMLEncode(userName); } SetPostText(DiscussionMacroResolver.GetQuote(userName, ForumContext.CurrentReplyThread.PostText)); // Set new line after if (isHtml) { htmlTemplateBody.ResolvedValue += "<br /><br />"; } else { ucBBEditor.Text += "\n"; } } } #endregion }
/// <summary> /// Generates the permission matrix for the current forum. /// </summary> private void CreateMatrix() { // Get forum resource info if (resForums == null) { resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); } // Get forum object if ((forum == null) && (ForumID > 0)) { forum = ForumInfoProvider.GetForumInfo(ForumID); } if ((resForums != null) && (forum != null)) { // Get permission matrix for roles of the current site/group int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Get permissions for the current forum resource DataSet permissions = PermissionNameInfoProvider.GetResourcePermissions(resForums.ResourceId); if (DataHelper.DataSourceIsEmpty(permissions)) { ShowInformation(GetString("general.emptymatrix")); } else { TableRow headerRow = new TableRow(); headerRow.CssClass = "UniGridHead"; TableCell newCell = new TableCell(); TableHeaderCell newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = " "; newHeaderCell.Attributes["style"] = "width:200px;"; headerRow.Cells.Add(newHeaderCell); foreach (string permission in allowedPermissions) { DataRow[] drArray = permissions.Tables[0].DefaultView.Table.Select("PermissionName = '" + permission + "'"); if ((drArray != null) && (drArray.Length > 0)) { DataRow dr = drArray[0]; newHeaderCell = new TableHeaderCell(); newHeaderCell.Attributes["style"] = "text-align:center;white-space:nowrap;"; newHeaderCell.Text = dr["PermissionDisplayName"].ToString(); newHeaderCell.ToolTip = dr["PermissionDescription"].ToString(); newHeaderCell.HorizontalAlign = HorizontalAlign.Center; headerRow.Cells.Add(newHeaderCell); } else { throw new Exception("[Security matrix] Column '" + permission + "' cannot be found."); } } newHeaderCell = new TableHeaderCell(); newHeaderCell.Text = " "; headerRow.Cells.Add(newHeaderCell); tblMatrix.Rows.Add(headerRow); // Render forum access permissions object[,] accessNames = new object[5,2]; accessNames[0, 0] = GetString("security.nobody"); accessNames[0, 1] = SecurityAccessEnum.Nobody; accessNames[1, 0] = GetString("security.allusers"); accessNames[1, 1] = SecurityAccessEnum.AllUsers; accessNames[2, 0] = GetString("security.authenticated"); accessNames[2, 1] = SecurityAccessEnum.AuthenticatedUsers; accessNames[3, 0] = GetString("security.groupmembers"); accessNames[3, 1] = SecurityAccessEnum.GroupMembers; accessNames[4, 0] = GetString("security.authorizedroles"); accessNames[4, 1] = SecurityAccessEnum.AuthorizedRoles; TableRow newRow = null; int rowIndex = 0; for (int access = 0; access <= accessNames.GetUpperBound(0); access++) { SecurityAccessEnum currentAccess = ((SecurityAccessEnum)accessNames[access, 1]); // If the security isn't displayed as part of group section if ((currentAccess == SecurityAccessEnum.GroupMembers) && (!IsGroupForum)) { // Do not render this access item } else { // Generate cell holding access item name newRow = new TableRow(); newRow.CssClass = ((rowIndex % 2 == 0) ? "EvenRow" : "OddRow"); newCell = new TableCell(); newCell.Text = accessNames[access, 0].ToString(); newCell.Wrap = false; newCell.CssClass = "MatrixHeader"; newCell.Width = new Unit(28, UnitType.Percentage); newRow.Cells.Add(newCell); rowIndex++; // Render the permissions access items bool isAllowed = false; bool isDisabled = true; int permissionIndex = 0; for (int permission = 0; permission < (tblMatrix.Rows[0].Cells.Count - 2); permission++) { newCell = new TableCell(); // Check if the currently processed access is applied for permission isAllowed = CheckPermissionAccess(currentAccess, permission, tblMatrix.Rows[0].Cells[permission + 1].Text); isDisabled = ((currentAccess == SecurityAccessEnum.AllUsers) && (permission == 1)) || (!Enable); // Disable column in roles grid if needed if ((currentAccess == SecurityAccessEnum.AuthorizedRoles) && !isAllowed) { gridMatrix.DisableColumn(permissionIndex); } // Insert the radio button for the current permission string permissionText = tblMatrix.Rows[0].Cells[permission + 1].Text; string elemId = ClientID + "_" + permission + "_" + access; newCell.Text = "<label style=\"display:none;\" for=\"" + elemId + "\">" + permissionText + "</label><input type=\"radio\" id=\"" + elemId + "\" name=\"" + permissionText + "\" onclick=\"" + ControlsHelper.GetPostBackEventReference(this, permission.ToString() + ";" + Convert.ToInt32(currentAccess).ToString()) + "\" " + ((isAllowed) ? "checked = \"checked\"" : "") + ((isDisabled) ? " disabled=\"disabled\"" : "") + "/>"; newCell.Wrap = false; newCell.Width = new Unit(12, UnitType.Percentage); newCell.HorizontalAlign = HorizontalAlign.Center; newRow.Cells.Add(newCell); permissionIndex++; } newCell = new TableCell(); newCell.Text = " "; newRow.Cells.Add(newCell); // Add the access row to the table tblMatrix.Rows.Add(newRow); } } // Check if forum has some roles assigned mNoRolesAvailable = !gridMatrix.HasData; // Get permission matrix for current forum resource if (!mNoRolesAvailable) { // Security - Role separator newRow = new TableRow(); newCell = new TableCell(); newCell.Text = " "; newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count)); newRow.Controls.Add(newCell); tblMatrix.Rows.Add(newRow); // Security - Role separator text newRow = new TableRow(); newCell = new TableCell(); newCell.CssClass = "MatrixLabel"; newCell.Text = GetString("SecurityMatrix.RolesAvailability"); newCell.Attributes.Add("colspan", Convert.ToString(tblMatrix.Rows[0].Cells.Count)); newRow.Controls.Add(newCell); tblMatrix.Rows.Add(newRow); } } } }
/// <summary> /// 加载主题所在版块名称 /// </summary> /// <param name="topicInfo"></param> private static void LoadTopicForumName(TopicInfo topicInfo) { ForumInfo forumInfo = Forums.GetForumInfo(topicInfo.Fid); topicInfo.Forumname = forumInfo == null ? "" : forumInfo.Name; }
/// <summary> /// Loads the forums DropDownList for topic move. /// </summary> private void LoadMoveTopicDropdown() { if (drpMoveToForum.Items.Count > 0) { return; } ForumPostInfo fpi = ForumContext.CurrentThread; if ((fpi == null) && (CurrentThread > 0)) { fpi = ForumPostInfoProvider.GetForumPostInfo(CurrentThread); } if (fpi != null) { bool isOk = AdminMode || ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID == fpi.PostForumID)); if (isOk) { var currentForumId = fpi.PostForumID; ForumInfo fi = ForumInfoProvider.GetForumInfo(currentForumId); if (fi != null) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { var whereCondition = new WhereCondition().WhereNotStartsWith("GroupName", "AdHoc").WhereEquals("GroupSiteID", SiteID); if (fgi.GroupGroupID > 0) { whereCondition.WhereEquals("GroupGroupID", fgi.GroupGroupID); } else { whereCondition.WhereNull("GroupGroupID"); } DataSet dsGroups = ForumGroupInfoProvider.GetForumGroups().Where(whereCondition).OrderBy("GroupDisplayName").Columns("GroupID, GroupDisplayName"); if (!DataHelper.DataSourceIsEmpty(dsGroups)) { Hashtable forums = new Hashtable(); // Get all forums for selected groups var groupWhereCondition = new WhereCondition().WhereIn("ForumGroupID", new ObjectQuery<ForumGroupInfo>().Where(whereCondition).Column("GroupID")); DataSet dsForums = ForumInfoProvider.GetForums() .WhereEquals("ForumOpen", 1) .WhereNotEquals("ForumID", currentForumId) .Where(groupWhereCondition) .OrderBy("ForumDisplayName") .Columns("ForumID, ForumDisplayName, ForumGroupID") .TypedResult; if (!DataHelper.DataSourceIsEmpty(dsForums)) { // Load forums into hash table foreach (DataRow drForum in dsForums.Tables[0].Rows) { int groupId = Convert.ToInt32(drForum["ForumGroupID"]); List<string[]> forumNames = forums[groupId] as List<string[]> ?? new List<string[]>(); forumNames.Add(new[] { Convert.ToString(drForum["ForumDisplayName"]), Convert.ToString(drForum["ForumID"]) }); forums[groupId] = forumNames; } } foreach (DataRow dr in dsGroups.Tables[0].Rows) { int groupId = Convert.ToInt32(dr["GroupId"]); List<string[]> forumNames = forums[groupId] as List<string[]>; if (forumNames != null) { // Add forum group item if some forum ListItem li = new ListItem(Convert.ToString(dr["GroupDisplayName"]), "0"); li.Attributes.Add("disabled", "disabled"); drpMoveToForum.Items.Add(li); // Add forum items foreach (string[] forum in forumNames) { // Add forum to DDL drpMoveToForum.Items.Add(new ListItem(" \xA0\xA0\xA0\xA0 " + forum[0], forum[1])); } } } // Display message if no forum exists if (drpMoveToForum.Items.Count == 0) { plcMoveInner.Visible = false; ShowInformation(GetString("Forums.NoForumToMoveIn")); } } } } } } }
/// <summary> /// 获取指定用户组和版信息下主题的DisplayOrder /// </summary> /// <param name="usergroupinfo">用户组信息</param> /// <param name="useradminid">管理组ID</param> /// <param name="forum">当前版块</param> /// <param name="topicInfo">当前主题信息</param> /// <param name="message">帖子内容</param> /// <param name="disablepost">是否受灌水限制 1,不受限制;0,受限制</param> /// <returns>0:正常显示;-2:待审核</returns> public static int GetTitleDisplayOrder(UserGroupInfo usergroupinfo, int useradminid, ForumInfo forum, TopicInfo topicInfo, string message, int disablepost) { if (useradminid == 1 || Moderators.IsModer(useradminid, topicInfo.Posterid, forum.Fid)) { return(topicInfo.Displayorder); } if (forum.Modnewtopics == 1 || usergroupinfo.ModNewTopics == 1 || Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postmodperiods) && disablepost != 1 || ForumUtils.HasAuditWord(topicInfo.Title) || ForumUtils.HasAuditWord(message)) { return(-2); } return(topicInfo.Displayorder); }
private void SubmitInfo_Click(object sender, EventArgs e) { #region 提交同级版块 if (this.CheckCookie()) { if (DNTRequest.GetString("fid") != "") { forumInfo = Forums.GetForumInfo(DNTRequest.GetInt("fid", 0)); forumInfo.Name = name.Text.Trim(); forumInfo.Displayorder = Convert.ToInt32(displayorder.Text); forumInfo.Status = Convert.ToInt16(status.SelectedValue); if (colcount.SelectedValue == "1") //传统模式[默认] { forumInfo.Colcount = 1; } else { if (Convert.ToInt16(colcountnumber.Text) < 1 || Convert.ToInt16(colcountnumber.Text) > 9) { base.RegisterStartupScript("", "<script>alert('列值必须在2~9范围内');</script>"); return; } forumInfo.Colcount = Convert.ToInt16(colcountnumber.Text); } forumInfo.Templateid = (Convert.ToInt32(templateid.SelectedValue) == config.Templateid ? 0 : Convert.ToInt32(templateid.SelectedValue)); forumInfo.Allowhtml = 0; forumInfo.Allowblog = 0; //__foruminfo.Istrade = 0; //__foruminfo.Allowpostspecial = 0; //需要作与运算如下 //__foruminfo.Allowspecialonly = 0; //需要作与运算如下 ////$allow辩论 = allowpostspecial & 16; ////$allow悬赏 = allowpostspecial & 4; ////$allow投票 = allowpostspecial & 1; forumInfo.Alloweditrules = 0; forumInfo.Allowsmilies = BoolToInt(setting.Items[0].Selected); forumInfo.Allowrss = BoolToInt(setting.Items[1].Selected); forumInfo.Allowbbcode = BoolToInt(setting.Items[2].Selected); forumInfo.Allowimgcode = BoolToInt(setting.Items[3].Selected); forumInfo.Recyclebin = BoolToInt(setting.Items[4].Selected); forumInfo.Modnewposts = BoolToInt(setting.Items[5].Selected); //__foruminfo.Jammer = BoolToInt(setting.Items[6].Selected); forumInfo.Disablewatermark = BoolToInt(setting.Items[6].Selected); forumInfo.Inheritedmod = BoolToInt(setting.Items[7].Selected); forumInfo.Allowthumbnail = BoolToInt(setting.Items[8].Selected); forumInfo.Allowtag = BoolToInt(setting.Items[9].Selected); //__foruminfo.Istrade = BoolToInt(setting.Items[11].Selected); int temppostspecial = 0; //temppostspecial = setting.Items[11].Selected ? temppostspecial | 1 : temppostspecial & ~1; //temppostspecial = setting.Items[12].Selected ? temppostspecial | 16 : temppostspecial & ~16; //temppostspecial = setting.Items[13].Selected ? temppostspecial | 4 : temppostspecial & ~4; forumInfo.Allowpostspecial = temppostspecial; forumInfo.Allowspecialonly = Convert.ToInt16(allowspecialonly.SelectedValue); if (autocloseoption.SelectedValue == "0") { forumInfo.Autoclose = 0; } else { forumInfo.Autoclose = Convert.ToInt32(autocloseday.Text); } forumInfo.Description = description.Text; forumInfo.Password = password.Text; forumInfo.Icon = icon.Text; forumInfo.Redirect = redirect.Text; forumInfo.Attachextensions = attachextensions.GetSelectString(","); AdminForums.CompareOldAndNewModerator(forumInfo.Moderators, moderators.Text.Replace("\r\n", ","), DNTRequest.GetInt("fid", 0)); forumInfo.Moderators = moderators.Text.Replace("\r\n", ","); forumInfo.Rules = rules.Text; forumInfo.Topictypes = topictypes.Text; forumInfo.Viewperm = Request.Form["viewperm"]; forumInfo.Postperm = Request.Form["postperm"]; forumInfo.Replyperm = Request.Form["replyperm"]; forumInfo.Getattachperm = Request.Form["getattachperm"]; forumInfo.Postattachperm = Request.Form["postattachperm"]; forumInfo.Applytopictype = Convert.ToInt32(applytopictype.SelectedValue); forumInfo.Postbytopictype = Convert.ToInt32(postbytopictype.SelectedValue); forumInfo.Viewbytopictype = Convert.ToInt32(viewbytopictype.SelectedValue); forumInfo.Topictypeprefix = Convert.ToInt32(topictypeprefix.SelectedValue); forumInfo.Topictypes = GetTopicType(); forumInfo.Permuserlist = GetPermuserlist(); Discuz.Aggregation.AggregationFacade.ForumAggregation.ClearDataBind(); string result = AdminForums.UpdateForumInfo(forumInfo).Replace("'", "’"); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "编辑论坛版块", "编辑论坛版块,名称为:" + name.Text.Trim()); GeneralConfigInfo configInfo = GeneralConfigs.GetConfig(); configInfo.Specifytemplate = Forums.GetSpecifyForumTemplateCount() > 0 ? 1 : 0; GeneralConfigs.Serialiaze(configInfo, Server.MapPath("../../config/general.config")); if (result == "") { Response.Redirect("forum_ForumsTree.aspx"); } else { Response.Write("<script>alert('用户:" + result + "不存在或因为它们所属组为\"游客\",\"等待验证会员\",因为无法设为版主');window.location.href='forum_ForumsTree.aspx';</script>"); Response.End(); } } } #endregion }
/// <summary> /// 获得板块信息 /// </summary> /// <returns></returns> public string Get() { if (Signature != GetParam("sig").ToString()) { ErrorCode = (int)ErrorType.API_EC_SIGNATURE; return(""); } //如果是桌面程序则需要验证用户身份 if (this.App.ApplicationType == (int)ApplicationType.DESKTOP) { if (Uid < 1) { ErrorCode = (int)ErrorType.API_EC_SESSIONKEY; return(""); } } if (CallId <= LastCallId) { ErrorCode = (int)ErrorType.API_EC_CALLID; return(""); } if (!CheckRequiredParams("fid")) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(""); } int fid = Utils.StrToInt(GetParam("fid"), 0); if (fid < 1) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(""); } ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid); if (forumInfo == null) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(""); } //string forumurl = "http://" + DNTRequest.GetCurrentFullHost() + BaseConfigs.GetForumPath.ToLower(); ForumGetResponse fgr = new ForumGetResponse(); fgr.Fid = fid; fgr.Url = ForumUrl + Urls.ShowForumAspxRewrite(fid, 1, forumInfo.Rewritename); fgr.CurTopics = forumInfo.CurrentTopics; fgr.Description = forumInfo.Description; fgr.Icon = forumInfo.Icon; fgr.LastPost = forumInfo.Lastpost; fgr.LastPoster = forumInfo.Lastposter.Trim(); fgr.LastPosterId = forumInfo.Lastposterid; fgr.LastTid = forumInfo.Lasttid; fgr.LastTitle = forumInfo.Lasttitle.Trim(); fgr.Moderators = forumInfo.Moderators; fgr.Name = forumInfo.Name; fgr.ParentId = forumInfo.Parentid; fgr.ParentIdList = forumInfo.Parentidlist.Trim(); fgr.PathList = forumInfo.Pathlist.Trim(); fgr.Posts = forumInfo.Posts; fgr.Rules = forumInfo.Rules; fgr.Status = forumInfo.Status; fgr.SubForumCount = forumInfo.Subforumcount; fgr.TodayPosts = forumInfo.Todayposts; fgr.Topics = forumInfo.Topics; if (Format == FormatType.JSON) { return(JavaScriptConvert.SerializeObject(fgr)); } return(SerializationHelper.Serialize(fgr)); }
/// <summary> /// 得到指定论坛版块(分类)的相关信息 /// </summary> /// <param name="fid">指定版块或分类的fid值</param> /// <returns></returns> public static ForumInfo GetForumInfomation(int fid) { ForumInfo foruminfo = new ForumInfo(); DataTable dt = DatabaseProvider.GetInstance().GetForumInformation(fid); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; foruminfo.Fid = Int32.Parse(dr["fid"].ToString()); foruminfo.Parentid = Int16.Parse(dr["parentid"].ToString()); foruminfo.Layer = Int16.Parse(dr["layer"].ToString()); foruminfo.Name = dr["name"].ToString(); foruminfo.Pathlist = dr["pathlist"].ToString(); foruminfo.Parentidlist = dr["parentidlist"].ToString(); foruminfo.Subforumcount = Int32.Parse(dr["subforumcount"].ToString()); foruminfo.Status = Int32.Parse(dr["status"].ToString()); foruminfo.Colcount = Int32.Parse(dr["colcount"].ToString()); foruminfo.Displayorder = Int32.Parse(dr["displayorder"].ToString()); foruminfo.Templateid = Int16.Parse(dr["templateid"].ToString()); foruminfo.Topics = Int32.Parse(dr["topics"].ToString()); foruminfo.Posts = Int32.Parse(dr["posts"].ToString()); foruminfo.Todayposts = Int32.Parse(dr["todayposts"].ToString()); foruminfo.Lastpost = dr["lastpost"].ToString(); foruminfo.Lastposter = dr["lastposter"].ToString(); foruminfo.Lastposterid = Int32.Parse(dr["lastposterid"].ToString()); foruminfo.Lasttitle = dr["lasttitle"].ToString(); foruminfo.Allowsmilies = Int32.Parse(dr["allowsmilies"].ToString()); foruminfo.Allowrss = Int32.Parse(dr["allowrss"].ToString()); foruminfo.Allowhtml = Int32.Parse(dr["allowhtml"].ToString()); foruminfo.Allowbbcode = Int32.Parse(dr["allowbbcode"].ToString()); foruminfo.Allowimgcode = Int32.Parse(dr["allowimgcode"].ToString()); foruminfo.Allowblog = Int32.Parse(dr["allowblog"].ToString()); foruminfo.Istrade = Int32.Parse(dr["istrade"].ToString()); foruminfo.Allowpostspecial = Int32.Parse(dr["allowpostspecial"].ToString()); foruminfo.Allowspecialonly = Int32.Parse(dr["allowspecialonly"].ToString()); foruminfo.Alloweditrules = Int32.Parse(dr["alloweditrules"].ToString()); foruminfo.Recyclebin = Int32.Parse(dr["recyclebin"].ToString()); foruminfo.Modnewposts = Int32.Parse(dr["modnewposts"].ToString()); foruminfo.Jammer = Int32.Parse(dr["jammer"].ToString()); foruminfo.Disablewatermark = Int32.Parse(dr["disablewatermark"].ToString()); foruminfo.Inheritedmod = Int32.Parse(dr["inheritedmod"].ToString()); foruminfo.Autoclose = Int16.Parse(dr["autoclose"].ToString()); foruminfo.Description = dr["description"].ToString().Trim() != "" ? dr["description"].ToString() : ""; foruminfo.Password = dr["password"].ToString(); foruminfo.Icon = dr["icon"].ToString(); foruminfo.Postcredits = dr["postcredits"].ToString(); foruminfo.Replycredits = dr["replycredits"].ToString(); foruminfo.Redirect = dr["redirect"].ToString(); foruminfo.Attachextensions = dr["attachextensions"].ToString(); foruminfo.Moderators = dr["moderators"].ToString(); foruminfo.Rules = dr["rules"].ToString(); foruminfo.Topictypes = dr["topictypes"].ToString(); foruminfo.Viewperm = dr["viewperm"].ToString(); foruminfo.Postperm = dr["postperm"].ToString(); foruminfo.Replyperm = dr["replyperm"].ToString(); foruminfo.Getattachperm = dr["getattachperm"].ToString(); foruminfo.Postattachperm = dr["postattachperm"].ToString(); foruminfo.Allowthumbnail = Int32.Parse(dr["allowthumbnail"].ToString()); foruminfo.Allowtag = Int32.Parse(dr["allowtag"].ToString()); foruminfo.Applytopictype = Int32.Parse(dr["applytopictype"].ToString()); foruminfo.Postbytopictype = Int32.Parse(dr["postbytopictype"].ToString()); foruminfo.Viewbytopictype = Int32.Parse(dr["viewbytopictype"].ToString()); foruminfo.Topictypeprefix = Int32.Parse(dr["topictypeprefix"].ToString()); foruminfo.Topictypes = dr["topictypes"].ToString(); foruminfo.Permuserlist = dr["permuserlist"].ToString(); dt.Dispose(); } return(foruminfo); }
/// <summary> /// 创建板块 /// </summary> /// <returns></returns> public string Create() { if (Signature != GetParam("sig").ToString()) { ErrorCode = (int)ErrorType.API_EC_SIGNATURE; return(""); } //如果是桌面程序则需要验证用户身份 if (this.App.ApplicationType == (int)ApplicationType.DESKTOP) { if (Uid < 1) { ErrorCode = (int)ErrorType.API_EC_SESSIONKEY; return(""); } } if (CallId <= LastCallId) { ErrorCode = (int)ErrorType.API_EC_CALLID; return(""); } if (!CheckRequiredParams("forum_info")) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(""); } Forum forum; try { forum = JavaScriptConvert.DeserializeObject <Forum>(GetParam("forum_info").ToString()); } catch { ErrorCode = (int)ErrorType.API_EC_PARAM; return(""); } if (forum == null || AreParamsNullOrZeroOrEmptyString(forum.Name)) { ErrorCode = (int)ErrorType.API_EC_PARAM; return(""); } if (!Utils.StrIsNullOrEmpty(forum.RewriteName) && Discuz.Forum.Forums.CheckRewriteNameInvalid(forum.RewriteName)) { ErrorCode = (int)ErrorType.API_EC_REWRITENAME; return(""); } int fid; if (forum.ParentId > 0) { #region 添加与当前论坛同级的论坛 //添加与当前论坛同级的论坛 //DataRow dr = AdminForums.GetForum(forum.ParentId); ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(forum.ParentId); //找出当前要插入的记录所用的FID string parentidlist = null; if (forumInfo.Parentidlist == "0") { parentidlist = forumInfo.Fid.ToString(); } else { parentidlist = forumInfo.Parentidlist + "," + forumInfo.Fid; } int maxdisplayorder = 0; DataTable dt = AdminForums.GetMaxDisplayOrder(forum.ParentId); if ((dt.Rows.Count > 0) && (dt.Rows[0][0].ToString() != "")) { maxdisplayorder = Convert.ToInt32(dt.Rows[0][0]); } else { maxdisplayorder = forumInfo.Displayorder; } AdminForums.UpdateForumsDisplayOrder(maxdisplayorder); fid = InsertForum(forum, forumInfo.Layer + 1, parentidlist, 0, maxdisplayorder + 1); AdminForums.SetSubForumCount(forumInfo.Fid); #endregion } else { #region 根论坛插入 int maxdisplayorder = AdminForums.GetMaxDisplayOrder(); fid = InsertForum(forum, 0, "0", 0, maxdisplayorder); #endregion } //string forumurl = "http://" + DNTRequest.GetCurrentFullHost() + BaseConfigs.GetForumPath.ToLower(); ForumCreateResponse fcr = new ForumCreateResponse(); fcr.Fid = fid; fcr.Url = ForumUrl + Urls.ShowForumAspxRewrite(fid, 1, forum.RewriteName); if (Format == FormatType.JSON) { return(JavaScriptConvert.SerializeObject(fcr)); } return(SerializationHelper.Serialize(fcr)); }
public int SaveForum(ForumInfo objForum) { int UserId = -1; if (objForum.ForumId > 0) { UserId = objForum.LastModifiedByUserId; } else { UserId = objForum.CreatedByUserId; } return dataProvider.SaveForum(objForum.ForumId, objForum.PortalId, objForum.ModuleId, objForum.ParentId, objForum.AllowTopics, objForum.Name, objForum.Description, objForum.SortOrder, objForum.Active, objForum.Hidden, objForum.TopicCount, objForum.ReplyCount, objForum.LastPostId, objForum.Slug, objForum.PermissionId, objForum.SettingId, objForum.EmailAddress, objForum.SiteMapPriority, UserId); }
private int InsertForum(Forum forum, int layer, string parentidlist, int subforumcount, int systemdisplayorder) { #region 添加新论坛 ForumInfo foruminfo = new ForumInfo(); foruminfo.Parentid = forum.ParentId; foruminfo.Layer = layer; foruminfo.Parentidlist = parentidlist; foruminfo.Subforumcount = subforumcount; foruminfo.Name = forum.Name.Trim(); foruminfo.Status = forum.Status == null ? 1 : Convert.ToInt32(forum.Status); foruminfo.Displayorder = systemdisplayorder; foruminfo.Templateid = forum.TemplateId; foruminfo.Allowsmilies = forum.AllowSmilies; foruminfo.Allowrss = forum.AllowRss; foruminfo.Allowhtml = 1; foruminfo.Allowbbcode = forum.AllowBbcode; foruminfo.Allowimgcode = forum.AllowImgcode; foruminfo.Allowblog = 0; foruminfo.Istrade = 0; //__foruminfo.Allowpostspecial = 0; //需要作与运算如下 //__foruminfo.Allowspecialonly = 0; //需要作与运算如下 //$allow辩论 = allowpostspecial & 16; //$allow悬赏 = allowpostspecial & 4; //$allow投票 = allowpostspecial & 1; foruminfo.Alloweditrules = forum.AllowEditRules; foruminfo.Recyclebin = forum.RecycleBin; foruminfo.Modnewposts = forum.ModNewPosts; foruminfo.Modnewtopics = forum.ModNewTopics; foruminfo.Jammer = forum.Jammer; foruminfo.Disablewatermark = forum.DisableWatermark; foruminfo.Inheritedmod = forum.InheritedMod; foruminfo.Allowthumbnail = forum.AllowThumbnail; foruminfo.Allowtag = forum.AllowTag; foruminfo.Allowpostspecial = 0; foruminfo.Allowspecialonly = 0; foruminfo.Autoclose = forum.AutoClose; foruminfo.Description = forum.Description == null ? string.Empty : forum.Description; foruminfo.Password = string.Empty; foruminfo.Icon = forum.Icon == null ? string.Empty : forum.Icon; foruminfo.Postcredits = ""; foruminfo.Replycredits = ""; foruminfo.Redirect = string.Empty; foruminfo.Attachextensions = string.Empty; foruminfo.Moderators = forum.Moderators == null ? string.Empty : forum.Moderators; foruminfo.Rules = forum.Rules == null ? string.Empty : forum.Rules; foruminfo.Seokeywords = forum.SeoKeywords == null ? string.Empty : forum.SeoKeywords; foruminfo.Seodescription = forum.SeoDescription == null ? string.Empty : forum.SeoDescription; foruminfo.Rewritename = forum.RewriteName == null ? string.Empty : forum.RewriteName; foruminfo.Topictypes = string.Empty; foruminfo.Colcount = 1; foruminfo.Viewperm = string.Empty; foruminfo.Postperm = string.Empty; foruminfo.Replyperm = string.Empty; foruminfo.Getattachperm = string.Empty; foruminfo.Postattachperm = string.Empty; return(Discuz.Forum.AdminForums.CreateForums(foruminfo)); #endregion }
/// <summary> /// Loads the forums DropDownList for topic move. /// </summary> private void LoadMoveTopicDropdown() { if (drpMoveToForum.Items.Count > 0) { return; } int currentForumId = 0; ForumPostInfo fpi = ForumContext.CurrentThread; if ((fpi == null) && (CurrentThread > 0)) { fpi = ForumPostInfoProvider.GetForumPostInfo(CurrentThread); } if (fpi != null) { bool isOk = AdminMode ? true : ((ForumContext.CurrentForum != null) && (ForumContext.CurrentForum.ForumID == fpi.PostForumID)); if (isOk) { currentForumId = fpi.PostForumID; ForumInfo fi = ForumInfoProvider.GetForumInfo(currentForumId); if (fi != null) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(fi.ForumGroupID); if (fgi != null) { string where = null; DataSet dsGroups = null; if (fgi.GroupGroupID > 0) { where = "GroupName NOT LIKE 'AdHoc%' AND GroupSiteID = " + SiteID + " AND GroupGroupID = " + fgi.GroupGroupID; } else { where = "GroupName NOT LIKE 'AdHoc%' AND GroupSiteID = " + SiteID + " AND GroupGroupID IS NULL"; } dsGroups = ForumGroupInfoProvider.GetGroups(where, "GroupDisplayName", 0, "GroupID, GroupDisplayName"); if (!DataHelper.DataSourceIsEmpty(dsGroups)) { Hashtable forums = new Hashtable(); // Get all forums for selected groups string groupWhere = "AND ForumGroupID IN (SELECT GroupID FROM Forums_ForumGroup WHERE " + where + ") "; DataSet dsForums = ForumInfoProvider.GetForums(" ForumOpen = 1 " + " AND NOT ForumID = " + currentForumId + groupWhere, "ForumDisplayName", 0, "ForumID, ForumDisplayName, ForumGroupID"); if (!DataHelper.DataSourceIsEmpty(dsForums)) { // Load forums into hash table foreach (DataRow drForum in dsForums.Tables[0].Rows) { int groupId = Convert.ToInt32(drForum["ForumGroupID"]); List <string[]> forumNames = forums[groupId] as List <string[]>; if (forumNames == null) { forumNames = new List <string[]>(); } forumNames.Add(new string[] { Convert.ToString(drForum["ForumDisplayName"]), Convert.ToString(drForum["ForumID"]) }); forums[groupId] = forumNames; } } foreach (DataRow dr in dsGroups.Tables[0].Rows) { int groupId = Convert.ToInt32(dr["GroupId"]); List <string[]> forumNames = forums[groupId] as List <string[]>; if (forumNames != null) { // Add forum group item if some forum ListItem li = new ListItem(Convert.ToString(dr["GroupDisplayName"]), "0"); li.Attributes.Add("disabled", "disabled"); drpMoveToForum.Items.Add(li); // Add forum items foreach (string[] forum in forumNames) { // Add forum to DDL drpMoveToForum.Items.Add(new ListItem(" \xA0\xA0\xA0\xA0 " + forum[0], forum[1])); } } } // Display message if no forum exists if (drpMoveToForum.Items.Count == 0) { plcMoveInner.Visible = false; ShowInformation(GetString("Forums.NoForumToMoveIn")); } } } } } } }
/// <summary> /// Logs "post" activity. /// </summary> /// <param name="fp">Forum post object</param> /// <param name="fi">Forum info</param> private void LogPostActivity(ForumPostInfo fp, ForumInfo fi) { Activity forumPost = new ActivityForumPost(fp, fi, DocumentContext.CurrentDocument, fi.ForumLogActivity, AnalyticsContext.ActivityEnvironmentVariables); forumPost.Log(); }
public override void CancelForum(UserInfo u, ForumInfo f) { return; }
protected void Page_Load(object sender, EventArgs e) { bool process = true; if (!Visible || StopProcessing) { EnableViewState = true; process = false; } chkForumModerated.Text = GetString("Forum_Edit.ForumModerated"); // Get community group id int communityGroupID = 0; forum = ForumInfoProvider.GetForumInfo(mForumId); if (forum == null) { return; } if (forum.ForumGroupID > 0) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); if (fgi != null) { communityGroupID = fgi.GroupGroupID; } } userSelector.ForumID = ForumID; userSelector.GroupID = communityGroupID; userSelector.CurrentSelector.SelectionMode = SelectionModeEnum.Multiple; userSelector.ShowSiteFilter = false; userSelector.SiteID = SiteContext.CurrentSiteID; userSelector.IsLiveSite = IsLiveSite; userSelector.Changed += userSelector_Changed; if (!IsLiveSite && process) { ReloadData(false); } }
private static bool testForum(ForumInfo f, int i) { string str = "test" + i; return(f.id.Equals(Int2Guid(i)) && f.name == str); }
/// <summary> /// Gets and bulk updates forums. Called when the "Get and bulk update forums" button is pressed. /// Expects the CreateForum method to be run first. /// </summary> private bool GetAndBulkUpdateForums() { // Prepare the parameters string where = "ForumName LIKE N'MyNewForum%'"; string orderBy = ""; string columns = ""; int topN = 10; // Get the data DataSet forums = ForumInfoProvider.GetForums(where, orderBy, topN, columns); if (!DataHelper.DataSourceIsEmpty(forums)) { // Loop through the individual items foreach (DataRow forumDr in forums.Tables[0].Rows) { // Create object from DataRow ForumInfo modifyForum = new ForumInfo(forumDr); // Update the properties modifyForum.ForumDisplayName = modifyForum.ForumDisplayName.ToUpper(); // Save the changes ForumInfoProvider.SetForumInfo(modifyForum); } return true; } return false; }
public override List <MemberInfo> WatchAllMembers(UserInfo _usr, ForumInfo forumInfo) { return(null); }
protected void Page_Load(object sender, EventArgs e) { bool process = (Visible && !StopProcessing); fi = ForumInfoProvider.GetForumInfo(ForumID); replyPi = ForumPostInfoProvider.GetForumPostInfo(ReplyToPostID); editPi = ForumPostInfoProvider.GetForumPostInfo(EditPostID); if ((fi == null) && (editPi != null)) { fi = ForumInfoProvider.GetForumInfo(editPi.PostForumID); ForumID = fi.ForumID; } // Check whether the post still exists if (EditPostID > 0) { EditedObject = editPi; } // Check whether the post still exists if ((ForumID > 0) && (fi == null)) { RedirectToInformation("editedobject.notexists"); } #region "HTML Editor properties" // Set HTML editor properties htmlTemplateBody.AutoDetectLanguage = false; htmlTemplateBody.DefaultLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; htmlTemplateBody.EditorAreaCSS = ""; htmlTemplateBody.ToolbarSet = "Forum"; htmlTemplateBody.DisableObjectResizing = true; // Disable image resizing htmlTemplateBody.RemovePlugins.Add("contextmenu"); // Disable context menu htmlTemplateBody.IsLiveSite = IsLiveSite; htmlTemplateBody.MediaDialogConfig.UseFullURL = true; htmlTemplateBody.LinkDialogConfig.UseFullURL = true; #endregion // Regular expression to validate email (e-mail is not required) rfvEmail.ValidationExpression = @"^([\w0-9_\-\+]+(\.[\w0-9_\-\+]+)*@[\w0-9_-]+(\.[\w0-9_-]+)+)*$"; if (fi != null) { if ((fi.ForumType == 0) && (replyPi == null)) { plcThreadType.Visible = true; } if (fi.ForumRequireEmail) { rfvEmailRequired.Enabled = true; rfvEmailRequired.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.emailRequireErrorMsg"); } #region "Forum text" rfvText.Enabled = !fi.ForumHTMLEditor; htmlTemplateBody.Visible = fi.ForumHTMLEditor; ucBBEditor.Visible = !fi.ForumHTMLEditor; if (fi.ForumHTMLEditor) { // Define customizable shortcuts Hashtable keystrokes = new Hashtable() { { "link", "CKEDITOR.CTRL + 76 /*L*/" }, { "bold", "CKEDITOR.CTRL + 66 /*B*/" }, { "italic", "CKEDITOR.CTRL + 73 /*I*/" }, { "underline", "CKEDITOR.CTRL + 85 /*U*/" } }; // Register script for HTML Editor forum buttons control if (!fi.ForumEnableURL) { htmlTemplateBody.RemoveButtons.Add("InsertUrl"); if (!fi.ForumEnableAdvancedURL) { // Remove the keyboard shortcut for the link insertion keystrokes.Remove("link"); } } if (!fi.ForumEnableImage) { htmlTemplateBody.RemoveButtons.Add("InsertImage"); } if (!fi.ForumEnableQuote) { htmlTemplateBody.RemoveButtons.Add("InsertQuote"); } if (!fi.ForumEnableAdvancedURL) { htmlTemplateBody.RemoveButtons.Add("InsertLink"); } if (!fi.ForumEnableAdvancedImage) { htmlTemplateBody.RemoveButtons.Add("InsertImageOrMedia"); } if (!fi.ForumEnableFontBold) { htmlTemplateBody.RemoveButtons.Add("Bold"); keystrokes.Remove("bold"); } if (!fi.ForumEnableFontItalics) { htmlTemplateBody.RemoveButtons.Add("Italic"); keystrokes.Remove("italic"); } if (!fi.ForumEnableFontUnderline) { htmlTemplateBody.RemoveButtons.Add("Underline"); keystrokes.Remove("underline"); } if (!fi.ForumEnableFontStrike) { htmlTemplateBody.RemoveButtons.Add("Strike"); } if (!fi.ForumEnableFontColor) { htmlTemplateBody.RemoveButtons.Add("TextColor"); htmlTemplateBody.RemoveButtons.Add("BGColor"); } // Generate keystrokes string for the CK Editor StringBuilder sb = new StringBuilder("[ [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ], [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ], [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ], [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], [ CKEDITOR.ALT + ( CKEDITOR.env.ie || CKEDITOR.env.webkit ? 189 : 109 ) /*-*/, 'toolbarCollapse' ], [ CKEDITOR.ALT + 48 /*0*/, 'a11yHelp' ]"); string format = ", [ {0}, '{1}' ]"; foreach (DictionaryEntry entry in keystrokes) { sb.Append(String.Format(format, entry.Value, entry.Key)); } sb.Append("]"); htmlTemplateBody.Keystrokes = sb.ToString(); } else { ucBBEditor.IsLiveSite = IsLiveSite; ucBBEditor.ShowImage = fi.ForumEnableImage; ucBBEditor.ShowQuote = fi.ForumEnableQuote; ucBBEditor.ShowBold = fi.ForumEnableFontBold; ucBBEditor.ShowItalic = fi.ForumEnableFontItalics; ucBBEditor.ShowUnderline = fi.ForumEnableFontUnderline; ucBBEditor.ShowStrike = fi.ForumEnableFontStrike; ucBBEditor.ShowCode = fi.ForumEnableCodeSnippet; ucBBEditor.ShowColor = fi.ForumEnableFontColor; ucBBEditor.ShowURL = fi.ForumEnableURL; ucBBEditor.ShowAdvancedImage = fi.ForumEnableAdvancedImage; ucBBEditor.ShowAdvancedURL = fi.ForumEnableAdvancedURL; // WAI validation lblText.AssociatedControlClientID = ucBBEditor.TextArea.ClientID; } #endregion } // Do not show subscribe checkbox if no post can't be added under the post if ((replyPi != null) && (replyPi.PostLevel >= ForumPostInfoProvider.MaxPostLevel - 1)) { plcSubscribe.Visible = false; } #region "Resources" rfvEmail.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.emailErrorMsg"); rfvSubject.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.subjectErrorMsg"); lblText.Text = GetString("Forums_WebInterface_ForumNewPost.text"); rfvText.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.textErrorMsg"); rfvUserName.ErrorMessage = GetString("Forums_WebInterface_ForumNewPost.usernameErrorMsg"); btnOk.Text = GetString("general.ok"); btnCancel.Text = GetString("general.cancel"); btnPreview.Text = GetString("Forums_WebInterface_ForumNewPost.Preview"); lblSubscribe.Text = GetString("Forums_WebInterface_ForumNewPost.Subscription"); lblSignature.Text = GetString("Forums_WebInterface_ForumNewPost.Signature"); lblPostIsAnswerLabel.Text = GetString("ForumPost_Edit.PostIsAnswer"); lblPostIsNotAnswerLabel.Text = GetString("ForumPost_Edit.PostIsNotAnswer"); #endregion if (!IsLiveSite && !RequestHelper.IsPostBack() && process) { ReloadData(); } }
public override bool UpdatePolicyParams(UserInfo u, ForumInfo f, int minword, int maxmont, List <String> legg) { return(true); }
/// <summary> /// Logs "subscription" activity. /// </summary> /// <param name="bci">Forum subscription</param> private void LogSubscriptionActivity(ForumSubscriptionInfo fsi, ForumInfo fi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (fsi == null) || (fi == null) || !fi.ForumLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ForumPostSubscriptionEnabled(siteName)) { return; } var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_FORUM_POST, TitleData = fi.ForumName, ItemID = fi.ForumID, ItemDetailID = fsi.SubscriptionID, URL = URLHelper.CurrentRelativePath, NodeID = CMSContext.CurrentDocument.NodeID, Culture = CMSContext.CurrentDocument.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
public override PolicyInfo GetPolicyParam(UserInfo u, ForumInfo f) { return(null); }
//protected void EditDescriptionDialog_OkButtonClicked(object sender, EventArgs e) //{ // SelectedForum.Description = DescriptionTextBox.Text; // Forums.UpdateForum(SelectedForum); // DescriptionLiteral.Text = SelectedForum.Description; // DescriptionUpdatePanel.Update(); //} public void GetForumDetailsById() { string forumId = Request.QueryString["forum"]; _forum = Forums.GetForumByID(int.Parse(forumId)); }
/// <summary> /// Creates tree node. /// </summary> /// <param name="sourceNode">Node with source data</param> protected TreeNode CreateNode(ForumPostTreeNode sourceNode, int index) { if (sourceNode == null) { return(null); } // Create tree node TreeNode newNode = new TreeNode(); DataRow dr = (DataRow)sourceNode.ItemData; // Check whether item data are defined, if not it is root node if (dr != null) { int sourceNodeId = (int)dr["PostID"]; int nodeLevel = (int)dr["PostLevel"]; // Check on maximum post in tree if (!this.UseMaxPostNodes || (index < MaxPostNodes)) { #region "Set node values and appearance" newNode.Value = sourceNodeId.ToString(); newNode.SelectAction = TreeNodeSelectAction.None; bool isApproved = ValidationHelper.GetBoolean(dr["PostApproved"], false); string postSubject = (string)dr["PostSubject"]; string cssClass = this.ItemCssClass; // Add CSS class for unapproved posts if (HighlightUnApprove && !isApproved) { cssClass += " PostUnApproved"; } string imageTag = ""; if (OnGetPostIconUrl != null) { string imageUrl = OnGetPostIconUrl(sourceNode); imageTag = "<img src=\"" + imageUrl + "\" alt=\"post\" style=\"border:0px;vertical-align:middle;\" /> "; } // Set by display mode switch (this.ShowMode) { // Dynamic detail mode case ShowModeEnum.DynamicDetailMode: newNode.Text = CreateDynamicDetailModeNode(dr, cssClass, imageTag, postSubject); break; // Detail mode case ShowModeEnum.DetailMode: newNode.Text = CreateDetailModeNode(dr); break; // Tree mode default: if (this.Selected == sourceNodeId) { cssClass = this.SelectedItemCssClass; string spanId = String.Empty; if (this.AdministrationMode) { spanId = "id=\"treeSelectedNode\""; } newNode.Text = String.Format("<span {0} class=\"{1}\" onclick=\"ShowPost({2}); SelectForumNode(this);\">{3}<span class=\"Name\">{4}</span></span>", spanId, cssClass, newNode.Value, imageTag, HTMLHelper.HTMLEncode(postSubject)); } else { newNode.Text = String.Format("<span class=\"{0}\" onclick=\"ShowPost({1}); SelectForumNode(this);\">{2}<span class=\"Name\">{3}</span></span>", cssClass, newNode.Value, imageTag, HTMLHelper.HTMLEncode(postSubject)); } break; } #endregion if (!this.ExpandTree) { #region "Populate deeper levels on demand" // Check if can expand string childCountColumn = "PostThreadPosts"; // Check if unapproved posts can be included if (this.AdministrationMode || this.UserIsModerator) { childCountColumn = "PostThreadPostsAbsolute"; } int childNodesCount = ValidationHelper.GetInteger(dr[childCountColumn], 0); // If the post is thread(level = 0) then childnodes count 1 means no real child-post if ((childNodesCount == 0) || ((childNodesCount == 1) && (nodeLevel == 0))) { newNode.PopulateOnDemand = false; // No childs -> expand newNode.Expanded = true; } else { if (!sourceNode.ChildNodesLoaded) { newNode.PopulateOnDemand = true; newNode.Expanded = false; } } #endregion #region "Expand nodes on the current path" // If preselect is set = first load if (this.RegularLoad) { string currentNodePath = (string)dr["PostIDPath"]; string currentSelectedPath = String.Empty; if (this.SelectedPost != null) { currentSelectedPath = this.SelectedPost.PostIDPath; } // Expand if node is on the path if (currentSelectedPath.StartsWith(currentNodePath)) { // Raise OnTreeNodePopulate newNode.PopulateOnDemand = true; newNode.Expanded = true; } else { newNode.Expanded = false; } } #endregion } else { // Populate will be called on each node newNode.PopulateOnDemand = true; newNode.Expanded = true; } } else { string parentNodeId = ValidationHelper.GetString(dr["PostParentID"], ""); newNode.Value = sourceNodeId.ToString(); newNode.Text = MaxTreeNodeText.Replace("##PARENTNODEID##", parentNodeId); newNode.SelectAction = TreeNodeSelectAction.None; } } // Root node populate by default else { // Root node as forum display name ForumInfo fi = ForumInfoProvider.GetForumInfo(this.ForumID); if (fi != null) { newNode.Text = "<span class=\"" + this.ItemCssClass + "\" onclick=\"ShowPost('-1'); SelectForumNode(this); \"><span class=\"Name\">" + HTMLHelper.HTMLEncode(fi.ForumDisplayName) + "</span></span>"; newNode.Value = "0"; newNode.SelectAction = TreeNodeSelectAction.None; } newNode.PopulateOnDemand = true; newNode.Expanded = true; } return(newNode); }
/// <summary> /// Logs activity. /// </summary> /// <param name="bci">Forum subscription</param> private void LogSubscriptionActivity(ForumSubscriptionInfo fsi, ForumInfo fi) { if ((fi == null) || !fi.ForumLogActivity) { return; } Activity activity = new ActivitySubscriptionForumPost(fi, fsi, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables); activity.Log(); }
protected void Page_Load(object sender, EventArgs e) { process = true; if (!Visible || StopProcessing) { EnableViewState = false; process = false; } chkChangeName.CheckedChanged += new EventHandler(chkChangeName_CheckedChanged); if (ForumID > 0) { // Get information on current forum forum = ForumInfoProvider.GetForumInfo(ForumID); // Check whether the forum still exists EditedObject = forum; } // Get forum resource resForums = ResourceInfoProvider.GetResourceInfo("CMS.Forums"); if ((resForums != null) && (forum != null)) { QueryDataParameters parameters = new QueryDataParameters(); parameters.Add("@ID", resForums.ResourceId); parameters.Add("@ForumID", forum.ForumID); parameters.Add("@SiteID", CMSContext.CurrentSiteID); string where = ""; int groupId = 0; if (IsGroupForum) { ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forum.ForumGroupID); groupId = fgi.GroupGroupID; } // Build where condition if (groupId > 0) { where = "RoleGroupID=" + groupId.ToString() + " AND PermissionDisplayInMatrix = 0"; } else { where = "RoleGroupID IS NULL AND PermissionDisplayInMatrix = 0"; } // Setup matrix control gridMatrix.IsLiveSite = IsLiveSite; gridMatrix.QueryParameters = parameters; gridMatrix.WhereCondition = where; gridMatrix.ContentBefore = "<table class=\"PermissionMatrix\" cellspacing=\"0\" cellpadding=\"0\" rules=\"rows\" border=\"1\" style=\"border-collapse:collapse;\">"; gridMatrix.ContentAfter = "</table>"; gridMatrix.OnItemChanged += new UniMatrix.ItemChangedEventHandler(gridMatrix_OnItemChanged); // Disable permission matrix if user has no MANAGE rights if (!CheckPermissions("cms.forums", PERMISSION_MODIFY)) { Enable = false; gridMatrix.Enabled = false; ShowError(String.Format(GetString("CMSSiteManager.AccessDeniedOnPermissionName"), "Manage")); } } }
/// <summary> /// Reloads the data of the editing forum. /// </summary> /// <param name="forumObj">Forum object</param> private void ReloadData(ForumInfo forumObj) { // Set main properties chkForumOpen.Checked = forumObj.ForumOpen; chkForumLocked.Checked = forumObj.ForumIsLocked; txtForumDescription.Text = forumObj.ForumDescription; txtForumDisplayName.Text = forumObj.ForumDisplayName; txtForumName.Text = forumObj.ForumName; // Set other settings txtImageMaxSideSize.Text = forumObj.ForumImageMaxSideSize.ToString(); txtIsAnswerLimit.Text = forumObj.ForumIsAnswerLimit.ToString(); txtMaxAttachmentSize.Text = forumObj.ForumAttachmentMaxFileSize.ToString(); txtBaseUrl.Text = forumObj.ForumBaseUrl; txtUnsubscriptionUrl.Text = forumObj.ForumUnsubscriptionUrl; txtOptInURL.Text = forumObj.ForumOptInApprovalURL; // Three state checkboxes chkForumRequireEmail.InitFromThreeStateValue(forumObj, "ForumRequireEmail"); chkCaptcha.InitFromThreeStateValue(forumObj, "ForumUseCAPTCHA"); chkForumDisplayEmails.InitFromThreeStateValue(forumObj, "ForumDisplayEmails"); chkUseHTML.InitFromThreeStateValue(forumObj, "ForumHTMLEditor"); chkAuthorDelete.InitFromThreeStateValue(forumObj, "ForumAuthorDelete"); chkAuthorEdit.InitFromThreeStateValue(forumObj, "ForumAuthorEdit"); chkEnableOptIn.InitFromThreeStateValue(forumObj, "ForumEnableOptIn"); chkSendOptInConfirmation.InitFromThreeStateValue(forumObj, "ForumSendOptInConfirmation"); // Check if is inherited value bool inheritImageMaxSideSize = (forumObj.GetValue("ForumImageMaxSideSize") == null); bool inheritMaxAttachmentSize = (forumObj.GetValue("ForumAttachmentMaxFileSize") == null); bool inheritIsAnswerLimit = (forumObj.GetValue("ForumIsAnswerLimit") == null); bool inheritType = (forumObj.GetValue("ForumType") == null); bool inheritBaseUrl = (forumObj.GetValue("ForumBaseUrl") == null); bool inheritUnsubscriptionUrl = (forumObj.GetValue("ForumUnsubscriptionUrl") == null); bool inheritLogActivity = (forumObj.GetValue("ForumLogActivity") == null); bool inheritOptInApprovalUrl = (forumObj.GetValue("ForumOptInApprovalURL") == null); // Discussion bool inheritDiscussion = (forumObj.GetValue("ForumDiscussionActions") == null); // Set properties txtImageMaxSideSize.Enabled = !inheritImageMaxSideSize; chkInheritMaxSideSize.Checked = inheritImageMaxSideSize; txtIsAnswerLimit.Enabled = !inheritIsAnswerLimit; chkInheritIsAnswerLimit.Checked = inheritIsAnswerLimit; chkInheritType.Checked = inheritType; txtMaxAttachmentSize.Enabled = !inheritMaxAttachmentSize; chkInheritMaxAttachmentSize.Checked = inheritMaxAttachmentSize; txtBaseUrl.Enabled = !inheritBaseUrl; chkInheritBaseUrl.Checked = inheritBaseUrl; txtUnsubscriptionUrl.Enabled = !inheritUnsubscriptionUrl; chkInheritUnsubscribeUrl.Checked = inheritUnsubscriptionUrl; txtOptInURL.Enabled = !inheritOptInApprovalUrl; chkInheritOptInURL.Checked = inheritOptInApprovalUrl; plcOnline.Visible = ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(CMSContext.CurrentSiteName); chkInheritLogActivity.Checked = inheritLogActivity; // Discussion chkInheritDiscussion.Checked = inheritDiscussion; // Create script for update inherit values ltrScript.Text += ScriptHelper.GetScript( "LoadSetting('" + chkLogActivity.ClientID + "', " + (forumObj.ForumLogActivity ? "true" : "false") + ", " + (inheritLogActivity ? "true" : "false") + ", 'chk');" + // Discussion "LoadSetting('" + radImageSimple.ClientID + "', " + (forumObj.ForumEnableImage ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radImageAdvanced.ClientID + "', " + (forumObj.ForumEnableAdvancedImage ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radImageNo.ClientID + "', " + (!(forumObj.ForumEnableAdvancedImage || forumObj.ForumEnableImage) ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radUrlSimple.ClientID + "', " + (forumObj.ForumEnableURL ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radUrlAdvanced.ClientID + "', " + (forumObj.ForumEnableAdvancedURL ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radUrlNo.ClientID + "', " + (!(forumObj.ForumEnableAdvancedURL || forumObj.ForumEnableURL) ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'rad');" + "LoadSetting('" + chkEnableQuote.ClientID + "', " + (forumObj.ForumEnableQuote ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableBold.ClientID + "', " + (forumObj.ForumEnableFontBold ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableItalic.ClientID + "', " + (forumObj.ForumEnableFontItalics ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableStrike.ClientID + "', " + (forumObj.ForumEnableFontStrike ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableUnderline.ClientID + "', " + (forumObj.ForumEnableFontUnderline ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableCode.ClientID + "', " + (forumObj.ForumEnableCodeSnippet ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + chkEnableColor.ClientID + "', " + (forumObj.ForumEnableFontColor ? "true" : "false") + ", " + (inheritDiscussion ? "true" : "false") + ", 'chk');" + "LoadSetting('" + radTypeAnswer.ClientID + "', " + (forumObj.ForumType == 2 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radTypeDiscussion.ClientID + "', " + (forumObj.ForumType == 1 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');" + "LoadSetting('" + radTypeChoose.ClientID + "', " + (forumObj.ForumType == 0 ? "true" : "false") + ", " + (inheritType ? "true" : "false") + ", 'rad');"); ForumGroupInfo fgi = ForumGroupInfoProvider.GetForumGroupInfo(forumObj.ForumGroupID); chkInheritUnsubscribeUrl.Attributes.Add("onclick", "SetInheritance('" + txtUnsubscriptionUrl.ClientID + "', '" + fgi.GroupUnsubscriptionUrl.Replace("'", "\\\'") + "', 'txt');"); chkInheritBaseUrl.Attributes.Add("onclick", "SetInheritance('" + txtBaseUrl.ClientID + "', '" + fgi.GroupBaseUrl.Replace("'", "\\\'") + "', 'txt');"); string btnId = txtOptInURL.SelectButton.ClientID; chkInheritOptInURL.Attributes.Add("onclick", "SetInheritance('" + txtOptInURL.PathTextBox.ClientID + "', '" + fgi.GroupOptInApprovalURL.Replace("'", "\\\'") + "', 'txt');ChangeState_" + txtOptInURL.ClientID + "(!this.checked);"); // Set default values chkForumRequireEmail.SetDefaultValue(fgi.GroupRequireEmail); chkForumDisplayEmails.SetDefaultValue(fgi.GroupDisplayEmails); chkUseHTML.SetDefaultValue(fgi.GroupHTMLEditor); chkCaptcha.SetDefaultValue(fgi.GroupUseCAPTCHA); chkAuthorDelete.SetDefaultValue(fgi.GroupAuthorDelete); chkAuthorEdit.SetDefaultValue(fgi.GroupAuthorEdit); chkEnableOptIn.SetDefaultValue(fgi.GroupEnableOptIn); chkSendOptInConfirmation.SetDefaultValue(fgi.GroupSendOptInConfirmation); // Settings inheritance chkInheritIsAnswerLimit.Attributes.Add("onclick", "SetInheritance('" + txtIsAnswerLimit.ClientID + "', '" + fgi.GroupIsAnswerLimit.ToString().Replace("'", "\\\'") + "', 'txt');"); chkInheritMaxSideSize.Attributes.Add("onclick", "SetInheritance('" + txtImageMaxSideSize.ClientID + "', '" + fgi.GroupImageMaxSideSize.ToString().Replace("'", "\\\'") + "', 'txt');"); chkInheritType.Attributes.Add("onclick", "SetInheritance('" + radTypeAnswer.ClientID + "', '" + (fgi.GroupType == 2 ? "true" : "false") + "', 'rad');" + "SetInheritance('" + radTypeDiscussion.ClientID + "', '" + (fgi.GroupType == 1 ? "true" : "false") + "', 'rad');" + "SetInheritance('" + radTypeChoose.ClientID + "', '" + (fgi.GroupType == 0 ? "true" : "false") + "', 'rad');"); chkInheritMaxAttachmentSize.Attributes.Add("onclick", "SetInheritance('" + txtMaxAttachmentSize.ClientID + "','" + fgi.GroupAttachmentMaxFileSize.ToString().Replace("'", "\\\'") + "', 'txt');"); chkInheritLogActivity.Attributes.Add("onclick", "SetInheritance('" + chkLogActivity.ClientID + "','" + fgi.GroupLogActivity.ToString().ToLowerCSafe() + "', 'chk');"); // Discussion string chkList = "'" + radImageSimple.ClientID + ";" + chkEnableBold.ClientID + ";" + chkEnableCode.ClientID + ";" + chkEnableColor.ClientID + ";" + radUrlSimple.ClientID + ";" + chkEnableItalic.ClientID + ";" + radImageAdvanced.ClientID + ";" + radUrlAdvanced.ClientID + ";" + chkEnableQuote.ClientID + ";" + chkEnableStrike.ClientID + ";" + chkEnableUnderline.ClientID + ";" + radImageNo.ClientID + ";" + radUrlNo.ClientID + "'"; string chkListValues = "'" + fgi.GroupEnableImage.ToString() + ";" + fgi.GroupEnableFontBold.ToString() + ";" + fgi.GroupEnableCodeSnippet.ToString() + ";" + fgi.GroupEnableFontColor.ToString() + ";" + fgi.GroupEnableURL.ToString() + ";" + fgi.GroupEnableFontItalics.ToString() + ";" + fgi.GroupEnableAdvancedImage.ToString() + ";" + fgi.GroupEnableAdvancedURL.ToString() + ";" + fgi.GroupEnableQuote.ToString() + ";" + fgi.GroupEnableFontStrike.ToString() + ";" + fgi.GroupEnableFontUnderline.ToString() + ";" + !(fgi.GroupEnableAdvancedImage || fgi.GroupEnableImage) + ";" + !(fgi.GroupEnableAdvancedURL || fgi.GroupEnableURL) + "'"; chkInheritDiscussion.Attributes.Add("onclick", "SetInheritance(" + chkList + ", " + chkListValues.ToLowerCSafe() + ", 'chk');"); }