private void LoadSettings()
        {
            moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            module = GetModule(moduleId, Forum.FeatureGuid);
            settings = ModuleSettings.GetModuleSettings(moduleId);
            config = new ForumConfiguration(settings);

            forumList.Config = config;
            forumList.ModuleId = moduleId;
            forumList.PageId = pageId;
            forumList.SiteRoot = SiteRoot;
            forumList.ImageSiteRoot = ImageSiteRoot;
            //forumList.IsEditable = IsEditable;

            forumListAlt.Config = config;
            forumListAlt.ModuleId = moduleId;
            forumListAlt.PageId = pageId;
            forumListAlt.SiteRoot = SiteRoot;
            forumListAlt.ImageSiteRoot = ImageSiteRoot;
            //forumListAlt.IsEditable = IsEditable;

            if (displaySettings.UseAltForumList)
            {
                forumList.Visible = false;
                forumListAlt.Visible = true;
            }

            AddClassToBody("editforumsubscriptions");
        }
Esempio n. 2
0
        private void LoadSettings()
        {
            userCanEdit = UserCanEditModule(ModuleId);

            moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new ForumConfiguration(moduleSettings);
            searchBoxTop.Visible = config.ShowForumSearchBox && !displaySettings.HideSearchOnForumView;

            if ((searchBoxTop.Visible) && (displaySettings.UseBottomSearchOnForumView))
            {
                searchBoxTop.Visible = false;
                searchBoxBottom.Visible = true;
            }

            threadList.Forum = forum;
            threadList.Config = config;
            threadList.PageId = PageId;
            threadList.ModuleId = ModuleId;
            threadList.ItemId = ItemId;
            threadList.PageNumber = pageNumber;
            threadList.SiteRoot = SiteRoot;
            threadList.NonSslSiteRoot = SiteUtils.GetInSecureNavigationSiteRoot();
            threadList.ImageSiteRoot = ImageSiteRoot;
            threadList.IsEditable = userCanEdit;

            threadListAlt.Forum = forum;
            threadListAlt.Config = config;
            threadListAlt.PageId = PageId;
            threadListAlt.ModuleId = ModuleId;
            threadListAlt.ItemId = ItemId;
            threadListAlt.PageNumber = pageNumber;
            threadListAlt.SiteRoot = SiteRoot;
            threadListAlt.NonSslSiteRoot = threadList.NonSslSiteRoot;
            threadListAlt.ImageSiteRoot = ImageSiteRoot;
            threadListAlt.IsEditable = userCanEdit;

            if (displaySettings.UseAltThreadList)
            {
                threadList.Visible = false;
                threadListAlt.Visible = true;
            }

            if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); }

            AddClassToBody("forumview");

            if ((CurrentPage != null)&&(CurrentPage.BodyCssClass.Length > 0))
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }

            if (ForumConfiguration.TrackFakeTopicUrlInAnalytics) { SetupAnalytics(); }
        }
Esempio n. 3
0
        private void LoadSettings()
        {
            config = new ForumConfiguration(Settings);

            forumList.Config = config;
            forumList.ModuleId = ModuleId;
            forumList.PageId = PageId;
            forumList.SiteRoot = SiteRoot;
            forumList.NonSslSiteRoot = SiteUtils.GetInSecureNavigationSiteRoot();
            forumList.ImageSiteRoot = ImageSiteRoot;
            forumList.IsEditable = IsEditable;

            forumListAlt.Config = config;
            forumListAlt.ModuleId = ModuleId;
            forumListAlt.PageId = PageId;
            forumListAlt.SiteRoot = SiteRoot;
            forumListAlt.NonSslSiteRoot = forumList.NonSslSiteRoot;
            forumListAlt.ImageSiteRoot = ImageSiteRoot;
            forumListAlt.IsEditable = IsEditable;

            if (displaySettings.UseAltForumList)
            {
                forumList.Visible = false;
                forumListAlt.Visible = true;
            }

            if (!config.ShowForumSearchBox) { searchBoxTop.Visible = false; }
            if (displaySettings.HideSearchOnForumList) { searchBoxTop.Visible = false; }

            if (searchBoxTop.Visible && displaySettings.UseBottomSearchOnForumList)
            {
                searchBoxTop.Visible = false;
                searchBoxBottom.Visible = true;
            }

            if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); }

            if (Page is mojoBasePage)
            {
                mojoBasePage basePage = Page as mojoBasePage;
                if (basePage != null)
                {
                    basePage.ScriptConfig.IncludeColorBox = true;
                    if (basePage.AnalyticsSection.Length == 0)
                    {
                        basePage.AnalyticsSection = ConfigHelper.GetStringProperty("AnalyticsForumSection", "forums");
                    }
                }
            }
        }
Esempio n. 4
0
        private void LoadParams()
        {
            PageId = WebUtils.ParseInt32FromQueryString("pageid", PageId);
            //moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            //ItemId = WebUtils.ParseInt32FromQueryString("ItemID", ItemId);
            //threadId = WebUtils.ParseInt32FromQueryString("thread", threadId);
            //PageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", PageNumber);

            threadParams = new ThreadParameterParser(this);
            threadParams.Parse();

            moduleId   = threadParams.ModuleId;
            ItemId     = threadParams.ItemId;
            threadId   = threadParams.ThreadId;
            PageNumber = threadParams.PageNumber;


            IsAdmin        = WebUser.IsAdmin;
            IsEditable     = UserCanEditModule(moduleId, Forum.FeatureGuid);
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config         = new ForumConfiguration(moduleSettings);

            postList.Config                 = config;
            postList.PageId                 = PageId;
            postList.ModuleId               = moduleId;
            postList.ItemId                 = ItemId;
            postList.ThreadId               = threadId;
            postList.PageNumber             = PageNumber;
            postList.IsAdmin                = IsAdmin;
            postList.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postList.SiteRoot               = SiteRoot;
            postList.ImageSiteRoot          = ImageSiteRoot;
            postList.SiteSettings           = siteSettings;
            postList.IsEditable             = IsEditable;

            postListAlt.Config                 = config;
            postListAlt.PageId                 = PageId;
            postListAlt.ModuleId               = moduleId;
            postListAlt.ItemId                 = ItemId;
            postListAlt.ThreadId               = threadId;
            postListAlt.PageNumber             = PageNumber;
            postListAlt.IsAdmin                = IsAdmin;
            postListAlt.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postListAlt.SiteRoot               = SiteRoot;
            postListAlt.ImageSiteRoot          = ImageSiteRoot;
            postListAlt.SiteSettings           = siteSettings;
            postListAlt.IsEditable             = IsEditable;

            if (Request.IsAuthenticated)
            {
                if (currentUser == null)
                {
                    currentUser = SiteUtils.GetCurrentSiteUser();
                }

                if ((currentUser != null) && (ItemId > -1))
                {
                    postList.UserId = currentUser.UserId;
                    postList.IsSubscribedToForum = Forum.IsSubscribed(ItemId, currentUser.UserId);

                    postListAlt.UserId = currentUser.UserId;
                    postListAlt.IsSubscribedToForum = postList.IsSubscribedToForum;
                }
            }

            if (displaySettings.UseAltPostList)
            {
                postList.Visible    = false;
                postListAlt.Visible = true;
            }

            if (displaySettings.OverrideThreadHeadingElement.Length > 0)
            {
                heading.HeadingTag = displaySettings.OverrideThreadHeadingElement;
            }

            AddClassToBody("forumthread");

            if (config.InstanceCssClass.Length > 0)
            {
                pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass);
            }

            if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0))
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }
        }
Esempio n. 5
0
        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
            {
                ThreadId        = thread.ThreadId,
                PostId          = thread.PostId,
                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("&amp;", "&"); // 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);
            }
        }
Esempio n. 6
0
        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");
        }
Esempio n. 7
0
        private void LoadSettings()
        {
            userCanEdit = UserCanEditModule(ModuleId);



            moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);

            config = new ForumConfiguration(moduleSettings);
            searchBoxTop.Visible = config.ShowForumSearchBox && !displaySettings.HideSearchOnForumView;

            if ((searchBoxTop.Visible) && (displaySettings.UseBottomSearchOnForumView))
            {
                searchBoxTop.Visible    = false;
                searchBoxBottom.Visible = true;
            }

            threadList.Forum          = forum;
            threadList.Config         = config;
            threadList.PageId         = PageId;
            threadList.ModuleId       = ModuleId;
            threadList.ItemId         = ItemId;
            threadList.PageNumber     = pageNumber;
            threadList.SiteRoot       = SiteRoot;
            threadList.NonSslSiteRoot = SiteUtils.GetInSecureNavigationSiteRoot();
            threadList.ImageSiteRoot  = ImageSiteRoot;
            threadList.IsEditable     = userCanEdit;

            threadListAlt.Forum          = forum;
            threadListAlt.Config         = config;
            threadListAlt.PageId         = PageId;
            threadListAlt.ModuleId       = ModuleId;
            threadListAlt.ItemId         = ItemId;
            threadListAlt.PageNumber     = pageNumber;
            threadListAlt.SiteRoot       = SiteRoot;
            threadListAlt.NonSslSiteRoot = threadList.NonSslSiteRoot;
            threadListAlt.ImageSiteRoot  = ImageSiteRoot;
            threadListAlt.IsEditable     = userCanEdit;

            if (displaySettings.UseAltThreadList)
            {
                threadList.Visible    = false;
                threadListAlt.Visible = true;
            }

            if (config.InstanceCssClass.Length > 0)
            {
                pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass);
            }

            AddClassToBody("forumview");

            if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0))
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }

            if (ForumConfiguration.TrackFakeTopicUrlInAnalytics)
            {
                SetupAnalytics();
            }
        }
Esempio n. 8
0
        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("&amp;", "&"); // 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);
            }
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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");
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
0
        private void LoadParams()
        {
            PageId = WebUtils.ParseInt32FromQueryString("pageid", PageId);
            //moduleId = WebUtils.ParseInt32FromQueryString("mid", moduleId);
            //ItemId = WebUtils.ParseInt32FromQueryString("ItemID", ItemId);
            //threadId = WebUtils.ParseInt32FromQueryString("thread", threadId);
            //PageNumber = WebUtils.ParseInt32FromQueryString("pagenumber", PageNumber);

            threadParams = new ThreadParameterParser(this);
            threadParams.Parse();

            moduleId = threadParams.ModuleId;
            ItemId = threadParams.ItemId;
            threadId = threadParams.ThreadId;
            PageNumber = threadParams.PageNumber;

            IsAdmin = WebUser.IsAdmin;
            IsEditable = UserCanEditModule(moduleId, Forum.FeatureGuid);
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            config = new ForumConfiguration(moduleSettings);

            postList.Config = config;
            postList.PageId = PageId;
            postList.ModuleId = moduleId;
            postList.ItemId = ItemId;
            postList.ThreadId = threadId;
            postList.PageNumber = PageNumber;
            postList.IsAdmin = IsAdmin;
            postList.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postList.SiteRoot = SiteRoot;
            postList.ImageSiteRoot = ImageSiteRoot;
            postList.SiteSettings = siteSettings;
            postList.IsEditable = IsEditable;

            postListAlt.Config = config;
            postListAlt.PageId = PageId;
            postListAlt.ModuleId = moduleId;
            postListAlt.ItemId = ItemId;
            postListAlt.ThreadId = threadId;
            postListAlt.PageNumber = PageNumber;
            postListAlt.IsAdmin = IsAdmin;
            postListAlt.IsCommerceReportViewer = WebUser.IsInRoles(siteSettings.CommerceReportViewRoles);
            postListAlt.SiteRoot = SiteRoot;
            postListAlt.ImageSiteRoot = ImageSiteRoot;
            postListAlt.SiteSettings = siteSettings;
            postListAlt.IsEditable = IsEditable;

            if (Request.IsAuthenticated)
            {
                if (currentUser == null) { currentUser = SiteUtils.GetCurrentSiteUser(); }

                if ((currentUser != null) && (ItemId > -1))
                {
                    postList.UserId = currentUser.UserId;
                    postList.IsSubscribedToForum = Forum.IsSubscribed(ItemId, currentUser.UserId);

                    postListAlt.UserId = currentUser.UserId;
                    postListAlt.IsSubscribedToForum = postList.IsSubscribedToForum;

                }

            }

            if (displaySettings.UseAltPostList)
            {
                postList.Visible = false;
                postListAlt.Visible = true;
            }

            if (displaySettings.OverrideThreadHeadingElement.Length > 0)
            {
                heading.HeadingTag = displaySettings.OverrideThreadHeadingElement;
            }

            AddClassToBody("forumthread");

            if (config.InstanceCssClass.Length > 0) { pnlOuterWrap.SetOrAppendCss(config.InstanceCssClass); }

            if ((CurrentPage != null) && (CurrentPage.BodyCssClass.Length > 0))
            {
                AddClassToBody(CurrentPage.BodyCssClass);
            }
        }