Esempio n. 1
0
        /// <summary>
        /// Save the Settings
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void UpdateClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            var moduleController = new ModuleController();

            moduleController.UpdateModuleSetting(this.ModuleId, "forumboardid", this.BoardID.SelectedValue);

            moduleController.UpdateModuleSetting(this.ModuleId, "RemoveTabName", this.RemoveTabName.SelectedValue);
            moduleController.UpdateModuleSetting(
                this.ModuleId,
                "InheritDnnLanguage",
                this.InheritDnnLanguage.Checked.ToString());

            var boardSettings =
                new LoadBoardSettings(this.BoardID.SelectedValue.ToType <int>())
            {
                DNNPageTab  = this.TabId,
                DNNPortalId = this.PortalId,
                BaseUrlMask = $"http://{HttpContext.Current.Request.ServerVariables["SERVER_NAME"]}/"
            };

            // save the settings to the database
            boardSettings.SaveRegistry();

            // Import Users & Roles
            UserImporter.ImportUsers(
                this.BoardID.SelectedValue.ToType <int>(),
                this.PortalSettings.PortalId,
                out _);

            Config.Touch();

            this.Response.Redirect(this.navigationManager.NavigateURL(this.TabId), true);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the OnClick event of the Create control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Create_OnClick([NotNull] object sender, [NotNull] EventArgs e)
        {
            var newBoardId = this.CreateBoard(true, this.NewBoardName.Text.Trim());

            var moduleController = new ModuleController();

            moduleController.UpdateModuleSetting(this.ModuleId, "forumboardid", newBoardId.ToString());

            moduleController.UpdateModuleSetting(this.ModuleId, "RemoveTabName", this.RemoveTabName.SelectedValue);
            moduleController.UpdateModuleSetting(
                this.ModuleId,
                "InheritDnnLanguage",
                this.InheritDnnLanguage.Checked.ToString());

            var boardSettings =
                new LoadBoardSettings(newBoardId)
            {
                DNNPageTab  = this.TabId,
                DNNPortalId = this.PortalId,
                BaseUrlMask = $"http://{HttpContext.Current.Request.ServerVariables["SERVER_NAME"]}/"
            };

            // save the settings to the database
            boardSettings.SaveRegistry();

            Config.Touch();

            this.Response.Redirect(this.navigationManager.NavigateURL(this.TabId), true);
        }
        /// <summary>
        /// Handles the OnClick event of the ImportForums control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ImportForums_OnClick(object sender, EventArgs e)
        {
            // First Create new empty forum
            var newBoardId = this.CreateBoard(false, "Import Board");

            Data.ImportActiveForums(this.ActiveForums.SelectedValue.ToType <int>(), newBoardId);

            this.MigrateAttachments();

            var moduleController = new ModuleController();

            moduleController.UpdateModuleSetting(this.ModuleId, "forumboardid", (newBoardId + 1).ToString());

            moduleController.UpdateModuleSetting(this.ModuleId, "RemoveTabName", this.RemoveTabName.SelectedValue);
            moduleController.UpdateModuleSetting(
                this.ModuleId,
                "InheritDnnLanguage",
                this.InheritDnnLanguage.Checked.ToString());

            var boardSettings =
                new LoadBoardSettings(newBoardId + 1)
            {
                DNNPageTab  = this.TabId,
                DNNPortalId = this.PortalId,
                BaseUrlMask = $"http://{HttpContext.Current.Request.ServerVariables["SERVER_NAME"]}/"
            };

            // save the settings to the database
            boardSettings.SaveRegistry();

            // Reload forum settings
            BoardContext.Current.BoardSettings = null;

            this.Response.Redirect(Globals.NavigateURL(), true);
        }
        /// <summary>
        /// Save the Settings
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void UpdateClick(object sender, EventArgs e)
        {
            var moduleController = new ModuleController();

            moduleController.UpdateModuleSetting(this.ModuleId, "forumboardid", this.BoardID.SelectedValue);

            moduleController.UpdateModuleSetting(this.ModuleId, "RemoveTabName", this.RemoveTabName.SelectedValue);
            moduleController.UpdateModuleSetting(
                this.ModuleId,
                "InheritDnnLanguage",
                this.InheritDnnLanguage.Checked.ToString());

            var boardSettings =
                new LoadBoardSettings(this.BoardID.SelectedValue.ToType <int>())
            {
                DNNPageTab  = this.TabId,
                DNNPortalId = this.PortalId,
                BaseUrlMask = $"http://{HttpContext.Current.Request.ServerVariables["SERVER_NAME"]}/"
            };

            // save the settings to the database
            boardSettings.SaveRegistry();

            // Import Users & Roles
            UserImporter.ImportUsers(
                this.BoardID.SelectedValue.ToType <int>(),
                this.PortalSettings.PortalId,
                out _);

            // Reload forum settings
            BoardContext.Current.BoardSettings = null;

            BuildLink.Redirect(ForumPages.Board);
        }
Esempio n. 5
0
        /// <summary>
        /// Determines whether is time to send digest for board.
        /// </summary>
        /// <param name="boardSettings">The board settings.</param>
        /// <returns>
        /// The is time to send digest for board.
        /// </returns>
        private static bool IsTimeToSendDigestForBoard([NotNull] LoadBoardSettings boardSettings)
        {
            CodeContracts.VerifyNotNull(boardSettings, "boardSettings");

            if (!boardSettings.AllowDigestEmail)
            {
                return(false);
            }

            var lastSend        = DateTime.MinValue;
            var sendEveryXHours = boardSettings.DigestSendEveryXHours;

            if (boardSettings.LastDigestSend.IsSet())
            {
                try
                {
                    lastSend = Convert.ToDateTime(boardSettings.LastDigestSend, CultureInfo.InvariantCulture);
                }
                catch (Exception)
                {
                    lastSend = DateTime.MinValue;
                }
            }

#if (DEBUG)
            // haven't sent in X hours or more and it's 12 to 5 am.
            var sendDigest = lastSend < DateTime.Now.AddHours(-sendEveryXHours);
#else
            // haven't sent in X hours or more and it's 12 to 5 am.
            var sendDigest = lastSend < DateTime.Now.AddHours(-sendEveryXHours) &&
                             DateTime.Now < DateTime.Today.AddHours(6);
#endif
            if (!sendDigest && !boardSettings.ForceDigestSend)
            {
                return(false);
            }

            // && DateTime.Now < DateTime.Today.AddHours(5))
            // we're good to send -- update latest send so no duplication...
            boardSettings.LastDigestSend  = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            boardSettings.ForceDigestSend = false;
            boardSettings.SaveGuestUserIdBackup();

            boardSettings.SaveRegistry();

            // reload all settings from the DB
            BoardContext.Current.BoardSettings = null;

            return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// The send digest.
        /// </summary>
        private void SendDigest()
        {
            try
            {
                var boardIds = this.GetRepository <Board>().ListTyped().Select(b => b.ID);

                boardIds.ForEach(
                    boardId =>
                {
                    var boardSettings = new LoadBoardSettings(boardId);

                    if (!IsTimeToSendDigestForBoard(boardSettings))
                    {
                        return;
                    }

                    // get users with digest enabled...
                    var usersWithDigest = this.GetRepository <User>()
                                          .FindUserTyped(false, boardId, dailyDigest: true).Where(
                        x => x.IsGuest != null && !x.IsGuest.Value && (x.IsApproved ?? false));

                    var typedUserFinds = usersWithDigest as IList <User> ?? usersWithDigest.ToList();

                    if (typedUserFinds.Any())
                    {
                        // start sending...
                        this.SendDigestToUsers(typedUserFinds, boardSettings);
                    }
                    else
                    {
                        this.Get <ILogger>().Info("no user found");
                    }
                });
            }
            catch (Exception ex)
            {
                this.Get <ILogger>().Error(ex, $"Error In {TaskName} Task");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// The send digest.
        /// </summary>
        private void SendDigest()
        {
            try
            {
                var boardIds = this.GetRepository <Board>().GetAll().Select(b => b.ID);

                boardIds.ForEach(
                    id =>
                {
                    var boardSettings = new LoadBoardSettings(id);

                    if (!IsTimeToSendDigestForBoard(boardSettings))
                    {
                        return;
                    }

                    // get users with digest enabled...
                    var usersWithDigest = this.GetRepository <User>().Get(
                        u => u.BoardID == id && u.IsApproved == true && u.IsGuest == false &&
                        u.DailyDigest);

                    if (usersWithDigest.Any())
                    {
                        // start sending...
                        this.SendDigestToUsers(usersWithDigest, boardSettings);
                    }
                    else
                    {
                        this.Get <ILogger>().Info("no user found");
                    }
                });
            }
            catch (Exception ex)
            {
                this.Get <ILogger>().Error(ex, $"Error In {TaskName} Task");
            }
        }
Esempio n. 8
0
        /// <summary>
        /// The initialize component.
        /// </summary>
        private void InitializeComponent()
        {
            if (AJAX.IsInstalled())
            {
                AJAX.RegisterScriptManager();
            }

            this.forum1 = new Forum();

            this.pnlModuleContent.Controls.Add(this.forum1);

            this.Load += this.DotNetNukeModuleLoad;
            this.forum1.PageTitleSet += this.Forum1_PageTitleSet;

            // This will create an error if there is no setting for forumboardid
            if (this.Settings["forumboardid"] != null)
            {
                this.forum1.BoardID = this.Settings["forumboardid"].ToType <int>();

                var boardSettingsTabId = BoardContext.Current.BoardSettings != null &&
                                         BoardContext.Current.BoardSettings.BoardID.Equals(this.forum1.BoardID)
                                             ? BoardContext.Current.BoardSettings.DNNPageTab
                                             : new LoadBoardSettings(this.forum1.BoardID).DNNPageTab;

                if (boardSettingsTabId.Equals(-1) ||
                    !boardSettingsTabId.Equals(this.TabId) && !this.CurrentPortalSettings.ContentLocalizationEnabled)
                {
                    if (HttpContext.Current.User.Identity.IsAuthenticated &&
                        UserController.Instance.GetCurrentUserInfo().IsSuperUser)
                    {
                        this.Response.Redirect(
                            this.ResolveUrl(
                                $"~/tabid/{this.PortalSettings.ActiveTab.TabID}/ctl/Edit/mid/{this.ModuleId}/Default.aspx"));
                    }

                    /*else
                     *                  {
                     *                      boardSettings.DNNPageTab = this.TabId;
                     *
                     *                      // save the settings to the database
                     *                      boardSettings.SaveRegistry();
                     *
                     *                      // Reload forum settings
                     *                      BoardContext.Current.BoardSettings = null;
                     *                  }*/
                }

                if (BoardContext.Current.BoardSettings.DNNPortalId.Equals(-1))
                {
                    var boardSettings = new LoadBoardSettings(this.forum1.BoardID)
                    {
                        DNNPageTab  = this.TabId,
                        DNNPortalId = this.PortalId
                    };

                    // save the settings to the database
                    boardSettings.SaveRegistry();
                }

                // Inherit Language from Dnn?
                var inheritDnnLanguage = true;

                if (this.Settings["InheritDnnLanguage"] != null)
                {
                    inheritDnnLanguage = this.Settings["InheritDnnLanguage"].ToType <bool>();
                }

                if (inheritDnnLanguage)
                {
                    SetDnnLangToYaf();
                }
            }
            else
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated &&
                    UserController.Instance.GetCurrentUserInfo().IsSuperUser)
                {
                    this.Response.Redirect(
                        this.ResolveUrl(
                            $"~/tabid/{this.PortalSettings.ActiveTab.TabID}/ctl/Edit/mid/{this.ModuleId}/Default.aspx"));
                }
                else
                {
                    this.pnlModuleContent.Controls.Clear();

                    this.pnlModuleContent.Controls.Add(
                        new Literal
                    {
                        Text =
                            "<div class=\"dnnFormMessage dnnFormInfo\">Please login as Superuser (host) and Setup the forum first.</div>"
                    });
                }
            }
        }