private void btnUpdate_Click(object sender, EventArgs e) { Forum forum = new Forum(itemId); if ((forum.ItemId > -1)&&(forum.ModuleId != moduleId)) { SiteUtils.RedirectToAccessDeniedPage(this); return; } //SiteUser siteUser = new SiteUser(siteSettings, Context.User.Identity.Name); SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); if(siteUser != null) forum.CreatedByUserId = siteUser.UserId; forum.ModuleId = moduleId; forum.Description = edContent.Text; forum.Title = this.txtTitle.Text; forum.IsActive = this.chkIsActive.Checked; //forum.AllowAnonymousPosts = this.chkAllowAnonymousPosts.Checked; forum.IsModerated = this.chkIsModerated.Checked; forum.SortOrder = int.Parse(this.txtSortOrder.Text); forum.PostsPerPage = int.Parse(this.txtPostsPerPage.Text); forum.ThreadsPerPage = int.Parse(this.txtThreadsPerPage.Text); allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting; forum.RolesThatCanPost = allowedPostRolesSetting.GetValue(); moderatorRolesSetting = moderatorRoles as AllowedRolesSetting; forum.RolesThatCanModerate = moderatorRolesSetting.GetValue(); forum.RequireModForNotify = chkRequireModForNotify.Checked; forum.AllowTrustedDirectNotify = chkAllowTrustedDirectNotify.Checked; forum.ModeratorNotifyEmail = txtModeratorNotifyEmail.Text; forum.IncludeInGoogleMap = chkIncludeInGoogleMap.Checked; forum.AddNoIndexMeta = chkAddNoIndexMeta.Checked; forum.Closed = chkClosed.Checked; forum.Visible = chkVisible.Checked; if(forum.Save()) { CurrentPage.UpdateLastModifiedTime(); //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey); CacheHelper.ClearModuleCache(forum.ModuleId); if (hdnReturnUrl.Value.Length > 0) { WebUtils.SetupRedirect(this, hdnReturnUrl.Value); return; } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); } }
private string FormatTitle(Forum forum) { if (forum.TotalPages > 1) { return string.Format(CultureInfo.InvariantCulture, ForumResources.ThreadPageTitleFormat, forum.Title, pageNumber.ToInvariantString()); } return forum.Title; }
private void LoadParams() { forumParams = new ForumParameterParser(this); forumParams.Parse(); PageId = forumParams.PageId; ModuleId = forumParams.ModuleId; ItemId = forumParams.ItemId; pageNumber = forumParams.PageNumber; forum = forumParams.Forum; }
private void UnsubscribeUser(int forumId) { SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); if (siteUser == null) return; Forum forum = new Forum(forumId); if (!forum.Unsubscribe(siteUser.UserId)) { log.ErrorFormat("Forum.UnSubscribe({0}, {1}, ) failed", forumId, siteUser.UserId); lblUnsubscribe.Text = ForumResources.ForumUnsubscribeFailed; return; } lblUnsubscribe.Text = ForumResources.ForumUnsubscribeCompleted; }
private void btnDelete_Click(object sender, EventArgs e) { Forum forum = new Forum(itemId); if (forum.ModuleId != moduleId) { SiteUtils.RedirectToAccessDeniedPage(this); return; } Forum.Delete(itemId); Forum.UpdateUserStats(-1); // updates all users CurrentPage.UpdateLastModifiedTime(); if (hdnReturnUrl.Value.Length > 0) { WebUtils.SetupRedirect(this, hdnReturnUrl.Value); return; } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); }
public void InstallContent(Module module, string configInfo) { if (string.IsNullOrEmpty(configInfo)) { return; } int userId = SiteUser.GetNewestUserId(module.SiteId); XmlDocument xml = new XmlDocument(); using (StreamReader stream = File.OpenText(HostingEnvironment.MapPath(configInfo))) { xml.LoadXml(stream.ReadToEnd()); } foreach (XmlNode node in xml.DocumentElement.ChildNodes) { if (node.Name == "forum") { Forum forum = new Forum(); forum.ModuleId = module.ModuleId; XmlAttributeCollection attributeCollection = node.Attributes; if (attributeCollection["title"] != null) { forum.Title = attributeCollection["title"].Value; } if (attributeCollection["sortOrder"] != null) { int sort = 1; if (int.TryParse(attributeCollection["sortOrder"].Value, out sort)) { forum.SortOrder = sort; } } foreach (XmlNode descriptionNode in node.ChildNodes) { if (descriptionNode.Name == "description") { forum.Description = descriptionNode.InnerText; break; } } forum.CreatedByUserId = userId; forum.Save(); foreach (XmlNode threadsNode in node.ChildNodes) { if (threadsNode.Name == "threads") { foreach (XmlNode threadNode in threadsNode.ChildNodes) { if (threadNode.Name == "thread") { XmlAttributeCollection threadAttributes = threadNode.Attributes; ForumThread thread = new ForumThread(); thread.ForumId = forum.ItemId; thread.PostUserId = userId; if (threadAttributes["subject"] != null) { thread.PostSubject = threadAttributes["subject"].Value; } foreach (XmlNode postNode in threadNode.ChildNodes) { if (postNode.Name == "post") { thread.PostMessage = postNode.InnerText; break; //TODO: this is limited to one post when creating a thread. could support more but just making it for the demo site } } thread.Post(); } } break; //there should only be one threads node } } } } }
private static void IndexItem(ForumThread forumThread) { if (WebConfigSettings.DisableSearchIndex) { return; } if (forumThread == null) { if (log.IsErrorEnabled) { log.Error("forumThread object passed in ForumThreadIndexBuilderProvider.IndexItem was null"); } return; } Forum forum = new Forum(forumThread.ForumId); Module module = new Module(forum.ModuleId); Guid forumFeatureGuid = new Guid("38aa5a84-9f5c-42eb-8f4c-105983d419fb"); ModuleDefinition forumFeature = new ModuleDefinition(forumFeatureGuid); // get list of pages where this module is published List<PageModule> pageModules = PageModule.GetPageModulesByModule(forum.ModuleId); // must update index for all pages containing // this module foreach (PageModule pageModule in pageModules) { PageSettings pageSettings = new PageSettings( forumThread.SiteId, pageModule.PageId); //don't index pending/unpublished pages if (pageSettings.IsPending) { continue; } mojoPortal.SearchIndex.IndexItem indexItem = new mojoPortal.SearchIndex.IndexItem(); if (forumThread.SearchIndexPath.Length > 0) { indexItem.IndexPath = forumThread.SearchIndexPath; } indexItem.SiteId = forumThread.SiteId; indexItem.PageId = pageModule.PageId; indexItem.PageName = pageSettings.PageName; // permissions are kept in sync in search index // so that results are filtered by role correctly indexItem.ViewRoles = pageSettings.AuthorizedRoles; indexItem.ModuleViewRoles = module.ViewRoles; indexItem.ItemId = forumThread.ForumId; indexItem.ModuleId = forum.ModuleId; indexItem.ModuleTitle = module.ModuleTitle; indexItem.FeatureId = forumFeatureGuid.ToString(); indexItem.FeatureName = forumFeature.FeatureName; indexItem.FeatureResourceFile = forumFeature.ResourceFile; indexItem.Title = forumThread.Subject; indexItem.PublishBeginDate = pageModule.PublishBeginDate; indexItem.PublishEndDate = pageModule.PublishEndDate; indexItem.ViewPage = "Forums/Thread.aspx"; indexItem.CreatedUtc = forumThread.ThreadDate; indexItem.LastModUtc = forumThread.MostRecentPostDate; if (ForumConfiguration.AggregateSearchIndexPerThread) { indexItem.PublishBeginDate = forumThread.MostRecentPostDate; StringBuilder threadContent = new StringBuilder(); DataTable threadPosts = ForumThread.GetPostsByThread(forumThread.ThreadId); foreach (DataRow r in threadPosts.Rows) { threadContent.Append(r["Post"].ToString()); } //aggregate contents of posts into one indexable content item indexItem.Content = threadContent.ToString(); if (ForumConfiguration.CombineUrlParams) { indexItem.ViewPage = "Forums/Thread.aspx?pageid=" + pageModule.PageId.ToInvariantString() + "&t=" + forumThread.ThreadId.ToInvariantString() + "~1"; indexItem.UseQueryStringParams = false; } indexItem.QueryStringAddendum = "&thread=" + forumThread.ThreadId.ToInvariantString(); } else { //older implementation indexItem.Content = forumThread.PostMessage; indexItem.QueryStringAddendum = "&thread=" + forumThread.ThreadId.ToString() + "&postid=" + forumThread.PostId.ToString(); } mojoPortal.SearchIndex.IndexHelper.RebuildIndex(indexItem); if (debugLog) { log.Debug("Indexed " + forumThread.Subject); } } }
public void ThreadMovedHandler(object sender, ForumThreadMovedArgs e) { if (WebConfigSettings.DisableSearchIndex) { return; } ForumThread forumThread = (ForumThread)sender; DataTable postIDList = forumThread.GetPostIdList(); Forum origForum = new Forum(e.OriginalForumId); foreach (DataRow row in postIDList.Rows) { int postID = Convert.ToInt32(row["PostID"]); ForumThread post = new ForumThread(forumThread.ThreadId, postID); RemoveForumIndexItem( origForum.ModuleId, e.OriginalForumId, forumThread.ThreadId, postID); IndexItem(post); } }
private bool UserCanModerate(PageSettings currentPage, Module module, Forum forum) { if (currentPage == null) { return false; } if (module == null) { return false; } if (forum == null) { return false; } if (WebUser.IsAdminOrContentAdmin) { return true; } if (WebUser.IsInRoles(currentPage.EditRoles)) { return true; } if (WebUser.IsInRoles(module.AuthorizedEditRoles)) { return true; } if (WebUser.IsInRoles(forum.RolesThatCanModerate)) { return true; } if (SiteUtils.UserIsSiteEditor()) { return true; } log.Info("user can't moderate"); return false; }
private bool IsAllowed(ModerationRequest modReq) { siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings == null) { //log.Info("SiteSettings was null"); return false; } currentPage = CacheHelper.GetPage(modReq.PageId); if ( (currentPage.PageId != modReq.PageId) || (currentPage.SiteId != siteSettings.SiteId) ) { log.Info("request rejected - pageid did not match"); return false; } thread = new ForumThread(modReq.ThreadId, modReq.PostId); if (thread.ModuleId != modReq.ModuleId) { log.Info("thread module id did not match"); return false; } forum = new Forum(thread.ForumId); module = GetModule(currentPage, thread.ModuleId); if (module == null) { log.Info("module not found in page modules"); return false; } config = new ForumConfiguration(ModuleSettings.GetModuleSettings(module.ModuleId)); if (thread.PostUserId > -1) { postUser = new SiteUser(siteSettings, thread.PostUserId); } return UserCanModerate(currentPage, module, forum); }
private void LoadSettings() { virtualRoot = WebUtils.GetApplicationRoot(); pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); forumId = WebUtils.ParseInt32FromQueryString("forumid", -1); threadId = WebUtils.ParseInt32FromQueryString("thread", -1); postId = WebUtils.ParseInt32FromQueryString("postid", -1); pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1); lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl(); timeOffset = SiteUtils.GetUserTimeOffset(); timeZone = SiteUtils.GetUserTimeZone(); isModerator = UserCanEditModule(moduleId, Forum.FeatureGuid); moduleSettings = ModuleSettings.GetModuleSettings(moduleId); config = new ForumConfiguration(moduleSettings); postList.Config = config; postList.PageId = pageId; postList.ModuleId = moduleId; postList.ItemId = forumId; postList.ThreadId = threadId; postList.PageNumber = pageNumber; postList.IsAdmin = WebUser.IsAdmin ; postList.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles); postList.SiteRoot = SiteRoot; postList.ImageSiteRoot = ImageSiteRoot; postList.SiteSettings = siteSettings; postList.IsEditable = false; postList.IsSubscribedToForum = true; postListAlt.Config = config; postListAlt.PageId = pageId; postListAlt.ModuleId = moduleId; postListAlt.ItemId = forumId; postListAlt.ThreadId = threadId; postListAlt.PageNumber = pageNumber; postListAlt.IsAdmin = postList.IsAdmin; postListAlt.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles); postListAlt.SiteRoot = SiteRoot; postListAlt.ImageSiteRoot = ImageSiteRoot; postListAlt.SiteSettings = siteSettings; postListAlt.IsEditable = false; postListAlt.IsSubscribedToForum = true; if (Request.IsAuthenticated) { theUser = SiteUtils.GetCurrentSiteUser(); if (theUser != null) { if (forumId > -1) { isSubscribedToForum = Forum.IsSubscribed(forumId, theUser.UserId); } if (threadId > -1) { isSubscribedToThread = ForumThread.IsSubscribed(threadId, theUser.UserId); } } } if (isModerator) { edMessage.WebEditor.ToolBar = ToolBar.FullWithTemplates; } else if ((Request.IsAuthenticated)&&(WebUser.IsInRoles(siteSettings.UserFilesBrowseAndUploadRoles))) { edMessage.WebEditor.ToolBar = ToolBar.ForumWithImages; } else { edMessage.WebEditor.ToolBar = ToolBar.Forum; } edMessage.WebEditor.SetFocusOnStart = true; edMessage.WebEditor.Height = Unit.Parse("350px"); if (config.UseSpamBlockingForAnonymous) { captcha.ProviderName = siteSettings.CaptchaProvider; captcha.Captcha.ControlID = "captcha" + moduleId.ToString(CultureInfo.InvariantCulture); captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey; captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey; } forum = new Forum(forumId); if (displaySettings.UseAltPostList) { postList.Visible = false; postListAlt.Visible = true; } AddClassToBody("editforumpost"); }
private void PopulateControls() { Forum forum = new Forum(forumThread.ForumId); txtSubject.Text = SecurityHelper.RemoveMarkup(forumThread.Subject); txtSortOrder.Text = forumThread.SortOrder.ToInvariantString(); txtPageTitleOverride.Text = forumThread.PageTitleOverride; chkIsLocked.Checked = forumThread.IsLocked; chkIncludeInSiteMap.Checked = forumThread.IncludeInSiteMap; chkSetNoIndexMeta.Checked = forumThread.SetNoIndexMeta; using (IDataReader reader = Forum.GetForums(forum.ModuleId, siteUser.UserId)) { ddForumList.DataSource = reader; ddForumList.DataBind(); } this.ddForumList.SelectedValue = forumThread.ForumId.ToInvariantString(); }
private void ShowNewForumControls() { this.btnDelete.Visible = false; this.btnUpdate.Text = ForumResources.ForumEditCreateButton; this.chkIsActive.Checked = true; this.txtSortOrder.Text = "100"; this.txtPostsPerPage.Text = "10"; this.txtThreadsPerPage.Text = "40"; Forum forum = new Forum(); allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting; allowedPostRolesSetting.SetValue(forum.RolesThatCanPost); chkIncludeInGoogleMap.Checked = forum.IncludeInGoogleMap; chkAddNoIndexMeta.Checked = forum.AddNoIndexMeta; chkRequireModForNotify.Checked = forum.RequireModForNotify; chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify; chkVisible.Checked = forum.Visible; }
private void PopulateControls() { Forum forum = new Forum(itemId); if (forum.ModuleId != moduleId) { SiteUtils.RedirectToAccessDeniedPage(this); return; } this.lblCreatedDate.Text = forum.CreatedDate.AddHours(timeOffset).ToString(); edContent.Text = forum.Description; this.txtTitle.Text = forum.Title; this.chkIsActive.Checked = forum.IsActive; //this.chkAllowAnonymousPosts.Checked = forum.AllowAnonymousPosts; this.chkIsModerated.Checked = forum.IsModerated; this.txtSortOrder.Text = forum.SortOrder.ToString(); this.txtPostsPerPage.Text = forum.PostsPerPage.ToString(); this.txtThreadsPerPage.Text = forum.ThreadsPerPage.ToString(); allowedPostRolesSetting = allowedPostRoles as AllowedRolesSetting; allowedPostRolesSetting.SetValue(forum.RolesThatCanPost); moderatorRolesSetting = moderatorRoles as AllowedRolesSetting; moderatorRolesSetting.SetValue(forum.RolesThatCanModerate); chkRequireModForNotify.Checked = forum.RequireModForNotify; chkAllowTrustedDirectNotify.Checked = forum.AllowTrustedDirectNotify; txtModeratorNotifyEmail.Text = forum.ModeratorNotifyEmail; chkIncludeInGoogleMap.Checked = forum.IncludeInGoogleMap; chkAddNoIndexMeta.Checked = forum.AddNoIndexMeta; chkClosed.Checked = forum.Closed; chkVisible.Checked = forum.Visible; }
public static void NotifySubscribers( Forum forum, ForumThread thread, Module module, SiteUser siteUser, SiteSettings siteSettings, ForumConfiguration config, string siteRoot, int pageId, int pageNumber, CultureInfo defaultCulture, SmtpSettings smtpSettings, bool notifyModeratorOnly) { string threadViewUrl; if (ForumConfiguration.CombineUrlParams) { threadViewUrl = siteRoot + "/Forums/Thread.aspx?pageid=" + pageId.ToInvariantString() + "&t=" + thread.ThreadId.ToInvariantString() + "~" + pageNumber.ToInvariantString() + "#post" + thread.PostId.ToInvariantString(); } else { threadViewUrl = siteRoot + "/Forums/Thread.aspx?thread=" + thread.ThreadId.ToInvariantString() + "&mid=" + module.ModuleId.ToInvariantString() + "&pageid=" + pageId.ToInvariantString() + "&ItemID=" + forum.ItemId.ToInvariantString() + "&pagenumber=" + pageNumber.ToInvariantString() + "#post" + thread.PostId.ToInvariantString(); } ForumNotificationInfo notificationInfo = new ForumNotificationInfo(); notificationInfo.ThreadId = thread.ThreadId; notificationInfo.PostId = thread.PostId; notificationInfo.SubjectTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ForumNotificationEmailSubject.config"); if (config.IncludePostBodyInNotification) { string postedBy = string.Empty; if (siteUser != null) { string sigFormat = ResourceHelper.GetResourceString("ForumResources", "PostedByFormat", defaultCulture, true); postedBy = string.Format(CultureInfo.InvariantCulture, sigFormat, siteUser.Name) + "\r\n\r\n"; ; } string bodyWithFullLinks = SiteUtils.ChangeRelativeLinksToFullyQualifiedLinks( siteRoot, thread.PostMessage); List<string> urls = SiteUtils.ExtractUrls(bodyWithFullLinks); notificationInfo.MessageBody = System.Web.HttpUtility.HtmlDecode(SecurityHelper.RemoveMarkup(thread.PostMessage)); if (urls.Count > 0) { notificationInfo.MessageBody += "\r\n" + ResourceHelper.GetResourceString("ForumResources", "PostedLinks", defaultCulture, true); foreach (string s in urls) { notificationInfo.MessageBody += "\r\n" + s.Replace("&", "&"); // html decode url params } notificationInfo.MessageBody += "\r\n\r\n"; } notificationInfo.MessageBody += "\r\n\r\n" + postedBy; } notificationInfo.BodyTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ForumNotificationEmail.config"); notificationInfo.ForumOnlyTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ForumNotificationEmail-ForumOnly.config"); notificationInfo.ThreadOnlyTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ForumNotificationEmail-ThreadOnly.config"); notificationInfo.ModeratorTemplate = ResourceHelper.GetMessageTemplate(defaultCulture, "ForumModeratorNotificationEmail.config"); notificationInfo.FromEmail = siteSettings.DefaultEmailFromAddress; notificationInfo.FromAlias = siteSettings.DefaultFromEmailAlias; if (config.OverrideNotificationFromAddress.Length > 0) { notificationInfo.FromEmail = config.OverrideNotificationFromAddress; notificationInfo.FromAlias = config.OverrideNotificationFromAlias; } notificationInfo.SiteName = siteSettings.SiteName; notificationInfo.ModuleName = module.ModuleTitle; notificationInfo.ForumName = forum.Title; notificationInfo.Subject = SecurityHelper.RemoveMarkup(thread.PostSubject); notificationInfo.MessageLink = threadViewUrl; notificationInfo.UnsubscribeForumThreadLink = siteRoot + "/Forums/UnsubscribeThread.aspx"; notificationInfo.UnsubscribeForumLink = siteRoot + "/Forums/UnsubscribeForum.aspx"; notificationInfo.SmtpSettings = smtpSettings; if (notifyModeratorOnly) { // just send notification to moderator List<string> moderatorsEmails = forum.ModeratorNotifyEmail.SplitOnChar(','); if (moderatorsEmails.Count > 0) { notificationInfo.ModeratorEmailAddresses = moderatorsEmails; ThreadPool.QueueUserWorkItem(new WaitCallback(ForumNotification.SendForumModeratorNotificationEmail), notificationInfo); } } else { // Send notification to subscribers DataSet dsThreadSubscribers = thread.GetThreadSubscribers(config.IncludeCurrentUserInNotifications); notificationInfo.Subscribers = dsThreadSubscribers; ThreadPool.QueueUserWorkItem(new WaitCallback(ForumNotification.SendForumNotificationEmail), notificationInfo); } }
public void Parse() { if (BasePage == null) { return; } pageId = WebUtils.ParseInt32FromQueryString("pageid", -1); moduleId = WebUtils.ParseInt32FromQueryString("mid", -1); itemId = WebUtils.ParseInt32FromQueryString("ItemID", -1); pageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", 1); // new option to combine params for better seo // we don't need moduleid in the url we can get it from the forum // but we still need to validate that the page contains the moduleid of the forum // pageid must remain a separate param but we can combine itemid and page number into one param // that can be split to get the individual params // so we can use ?pageid=x&f=y~z where y is itemid and z is pagenumber string f = WebUtils.ParseStringFromQueryString("f", string.Empty); if ((f.Length > 0)&&(f.Contains("~"))) { List<string> parms = f.SplitOnCharAndTrim('~'); if (parms.Count == 2) { int.TryParse(parms[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out itemId); int.TryParse(parms[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out pageNumber); } } forum = new Forum(ItemId); if (forum.ModuleId == -1) { forum = null; return; } Module m = BasePage.GetModule(forum.ModuleId, Forum.FeatureGuid); if (m != null) { //module exists on the page and matches the forum module id moduleId = forum.ModuleId; paramsAreValid = true; } }
private void btnUpdate_Click(object sender, EventArgs e) { if (forum == null) { forum = new Forum(forumId); } if (WebUser.IsInRoles(forum.RolesThatCanPost)) { if (Request.IsAuthenticated) { captcha.Enabled = false; pnlAntiSpam.Visible = false; } } else { SiteUtils.RedirectToAccessDeniedPage(this); return; } Page.Validate("Forum"); if(!Page.IsValid) { PopulateControls(); return; } else { if ((config.UseSpamBlockingForAnonymous) && (pnlAntiSpam.Visible)&&(captcha.Enabled)) { if (!captcha.IsValid) { PopulateControls(); return; } } ForumThread thread; bool userIsAllowedToUpdateThisPost = false; if(threadId == -1) { //new thread thread = new ForumThread(); thread.ForumId = forumId; thread.IncludeInSiteMap = forum.IncludeInGoogleMap; thread.SetNoIndexMeta = forum.AddNoIndexMeta; } else { if(postId > -1) { thread = new ForumThread(threadId,postId); if (isModerator || (this.theUser.UserId == thread.PostUserId)) { userIsAllowedToUpdateThisPost = true; } if ((isModerator) && (divSortOrder.Visible)) { int sort = thread.PostSortOrder; int.TryParse(txtSortOrder.Text, out sort); thread.PostSortOrder = sort; } } else { thread = new ForumThread(threadId); } //existing thread but it does not belong to this forum if (forumId != thread.ForumId) { SiteUtils.RedirectToAccessDeniedPage(this); return; } } thread.ContentChanged += new ContentChangedEventHandler(thread_ContentChanged); thread.PostSubject = this.txtSubject.Text; thread.PostMessage = edMessage.Text; bool isNewPost = (thread.PostId == -1); SiteUser siteUser = null; if(Request.IsAuthenticated) { siteUser = SiteUtils.GetCurrentSiteUser(); if (siteUser != null) thread.PostUserId = siteUser.UserId; if (chkSubscribeToForum.Checked) { forum.Subscribe(siteUser.UserId); } else { thread.SubscribeUserToThread = this.chkNotifyOnReply.Checked; } } else { thread.PostUserId = -1; //guest } string threadViewUrl; if (ForumConfiguration.CombineUrlParams) { threadViewUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + pageId.ToInvariantString() + "&t=" + thread.ThreadId.ToInvariantString() + "~" + this.pageNumber.ToInvariantString(); } else { threadViewUrl = SiteRoot + "/Forums/Thread.aspx?thread=" + thread.ThreadId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&pageid=" + pageId.ToInvariantString() + "&ItemID=" + forumId.ToInvariantString() + "&pagenumber=" + this.pageNumber.ToInvariantString(); } if((thread.PostId == -1)||(userIsAllowedToUpdateThisPost)) { thread.Post(); CurrentPage.UpdateLastModifiedTime(); if (ForumConfiguration.CombineUrlParams) { threadViewUrl = SiteRoot + "/Forums/Thread.aspx?pageid=" + pageId.ToInvariantString() + "&t=" + thread.ThreadId.ToInvariantString() + "~" + pageNumber.ToInvariantString() + "#post" + thread.PostId.ToInvariantString(); } else { threadViewUrl = SiteRoot + "/Forums/Thread.aspx?thread=" + thread.ThreadId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString() + "&pageid=" + pageId.ToInvariantString() + "&ItemID=" + forum.ItemId.ToInvariantString() + "&pagenumber=" + pageNumber.ToInvariantString() + "#post" + thread.PostId.ToInvariantString(); } if ((isNewPost) || (!config.SuppressNotificationOfPostEdits)) { bool notifyModeratorOnly = false; if (forum.RequireModForNotify) { notifyModeratorOnly = true; if(forum.AllowTrustedDirectNotify && (siteUser != null) && siteUser.Trusted) { notifyModeratorOnly = false; } } Module m = GetModule(moduleId, Forum.FeatureGuid); ForumNotification.NotifySubscribers( forum, thread, m, siteUser, siteSettings, config, SiteRoot, pageId, pageNumber, SiteUtils.GetDefaultCulture(), ForumConfiguration.GetSmtpSettings(), notifyModeratorOnly ); if(!notifyModeratorOnly) { thread.NotificationSent = true; thread.UpdatePost(); } } //String cacheDependencyKey = "Module-" + moduleId.ToInvariantString(); //CacheHelper.TouchCacheDependencyFile(cacheDependencyKey); CacheHelper.ClearModuleCache(moduleId); SiteUtils.QueueIndexing(); } Response.Redirect(threadViewUrl); } }
public bool DeletePost(int postId) { bool deleted = DBForums.ForumPostDelete(postId); if (deleted) { Forum.DecrementPostCount(this.forumID); if (this.totalReplies > 0) { DBForums.ForumThreadDecrementReplyStats(this.threadID); } Forum forum = new Forum(this.forumID); this.moduleID = forum.ModuleId; this.postID = postId; ContentChangedEventArgs e = new ContentChangedEventArgs(); e.IsDeleted = true; OnContentChanged(e); int threadPostCount = ForumThread.GetPostCount(this.threadID); if (threadPostCount == 0) { ForumThread.Delete(this.threadID); Forum.DecrementThreadCount(this.forumID); } ResetThreadSequences(); } return deleted; }
private void btnSave_Click(object sender, EventArgs e) { foreach (int forumId in forumIDsToSubscribe) { Forum forum = new Forum(forumId); forum.Subscribe(siteUser.UserId); } foreach (int forumId in forumIDsToUnsubscribe) { Forum forum = new Forum(forumId); forum.Unsubscribe(siteUser.UserId); } WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); }
private void LoadSettings() { thread = threadParams.Thread; if (thread.ThreadId == -1) { //thread does not exist, probably just got deleted //redirect back to thread list string redirectUrl; if (ForumConfiguration.CombineUrlParams) { redirectUrl = SiteRoot + "/Forums/ForumView.aspx?pageid=" + PageId.ToInvariantString() + "&f=" + ItemId.ToInvariantString() + "~1"; } else { redirectUrl = SiteRoot + "/Forums/ForumView.aspx?ItemID=" + ItemId.ToInvariantString() + "&pageid=" + PageId.ToInvariantString() + "&mid=" + moduleId.ToInvariantString(); } WebUtils.SetupRedirect(this, redirectUrl); return; } if (thread.ModuleId != moduleId) { //SiteUtils.RedirectToAccessDeniedPage(this); WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); return; } forum = threadParams.Forum; //if (forum.ModuleId != moduleId) //{ // //SiteUtils.RedirectToAccessDeniedPage(this); // WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl()); // return; //} postList.Forum = forum; postList.Thread = thread; postListAlt.Forum = forum; postListAlt.Thread = thread; if (ForumConfiguration.TrackFakeTopicUrlInAnalytics) { SetupAnalytics(); } if ((IsEditable)||(WebUser.IsInRoles(forum.RolesThatCanModerate))) { SetupNotifyScript(); } }