/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { this.PageContext.PageElements.RegisterJQuery(); this.PageContext.PageElements.RegisterJsResourceInclude("blockUIJs", "js/jquery.blockUI.js"); if (this.IsPostBack) { return; } this.LoadingImage.ImageUrl = YafForumInfo.GetURLToResource("images/loader.gif"); this.PageLinks.AddRoot(); this.PageLinks.AddLink( this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink(this.GetText("TEAM", "FORUMS"), YafBuildLink.GetLink(ForumPages.admin_forums)); this.PageLinks.AddLink(this.GetText("ADMIN_DELETEFORUM", "TITLE"), string.Empty); this.Page.Header.Title = "{0} - {1} - {2}".FormatWith( this.GetText("ADMIN_ADMIN", "Administration"), this.GetText("TEAM", "FORUMS"), this.GetText("ADMIN_DELETEFORUM", "TITLE")); this.Delete.Text = this.GetText("ADMIN_DELETEFORUM", "DELETE_FORUM"); this.Cancel.Text = this.GetText("CANCEL"); this.Delete.Attributes["onclick"] = "return (confirm('{0}') && confirm('{1}'));".FormatWith( this.GetText("ADMIN_FORUMS", "CONFIRM_DELETE"), this.GetText("ADMIN_FORUMS", "CONFIRM_DELETE_POSITIVE")); this.BindData(); var forumId = this.GetQueryStringAsInt("fa"); using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value)) { DataRow row = dt.Rows[0]; this.ForumNameTitle.Text = (string)row["Name"]; // populate parent forums list with forums according to selected category this.BindParentList(); } }
/// <summary> /// Adds page links to the page /// </summary> private void AddPageLinks() { this.PageLinks.AddRoot(); if (this._categoryId > 0) { this.PageLinks.AddLink( this.PageContext.PageCategoryName, YafBuildLink.GetLink(ForumPages.forum, "c={0}", this._categoryId)); } if (this._returnForum > 0) { this.PageLinks.AddLink( LegacyDb.forum_list(this.PageContext.PageBoardID, this._returnForum).Rows[0]["Name"].ToString(), YafBuildLink.GetLink(ForumPages.topics, "f={0}", this._returnForum)); } if (this._forumId > 0) { this.PageLinks.AddLink( LegacyDb.forum_list(this.PageContext.PageBoardID, this._returnForum).Rows[0]["Name"].ToString(), YafBuildLink.GetLink(ForumPages.topics, "f={0}", this._forumId)); } if (this._topicId > 0) { this.PageLinks.AddLink( this._topicInfo["Topic"].ToString(), YafBuildLink.GetLink(ForumPages.posts, "t={0}", this._topicId)); } if (this._editMessageId > 0) { this.PageLinks.AddLink( this._topicInfo["Topic"].ToString(), YafBuildLink.GetLink(ForumPages.postmessage, "m={0}", this._editMessageId)); } this.PageLinks.AddLink(this.GetText("POLLEDIT", "EDITPOLL"), string.Empty); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.IsPostBack) { return; } this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif"); this.BindData(); var forumId = this.GetQueryStringAsInt("fa"); using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value)) { var row = dt.Rows[0]; this.ForumNameTitle.Text = (string)row["Name"]; // populate parent forums list with forums according to selected category this.BindParentList(); } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID)) { this._forum = dt.Rows[0]; } this._topic = LegacyDb.topic_info(this.PageContext.PageTopicID); if (this.IsPostBack) { return; } if (!this.PageContext.ForumModeratorAccess && !this.PageContext.ForumUploadAccess) { YafBuildLink.AccessDenied(); } if (!this.PageContext.ForumReadAccess) { YafBuildLink.AccessDenied(); } // Ederon : 9/9/2007 - moderaotrs can attach in locked posts if (this._topic["Flags"].BinaryAnd(TopicFlags.Flags.IsLocked) && !this.PageContext.ForumModeratorAccess) { YafBuildLink.AccessDenied(/*"The topic is closed."*/); } if (this._forum["Flags"].BinaryAnd(ForumFlags.Flags.IsLocked)) { YafBuildLink.AccessDenied(/*"The forum is closed."*/); } // Check that non-moderators only edit messages they have written if (!this.PageContext.ForumModeratorAccess) { using (DataTable dt = LegacyDb.message_list(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m"))) { if ((int)dt.Rows[0]["UserID"] != this.PageContext.PageUserID) { YafBuildLink.AccessDenied(/*"You didn't post this message."*/); } } } if (this.PageContext.Settings.LockedForum == 0) { this.PageLinks.AddLink(this.Get <YafBoardSettings>().Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.PageCategoryName, YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID)); } this.PageLinks.AddForumLinks(this.PageContext.PageForumID); this.PageLinks.AddLink( this.PageContext.PageTopicName, YafBuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); this.Back.Text = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t").IsNotSet() ? this.GetText("BACK") : this.GetText("COMMON", "CONTINUE"); this.Upload.Text = this.GetText("UPLOAD"); // MJ : 10/14/2007 - list of allowed file extensions DataTable extensionTable = this.GetRepository <FileExtension>().List(); string types = string.Empty; bool bFirst = true; foreach (DataRow row in extensionTable.Rows) { types += "{1}*.{0}".FormatWith(row["Extension"].ToString(), bFirst ? string.Empty : ", "); if (bFirst) { bFirst = false; } } if (types.IsSet()) { this.ExtensionsList.Text = types; } if (this.Get <YafBoardSettings>().MaxFileSize > 0) { this.UploadNodePlaceHold.Visible = true; this.UploadNote.Text = this.GetTextFormatted( "UPLOAD_NOTE", (this.Get <YafBoardSettings>().MaxFileSize / 1024).ToString()); } else { this.UploadNodePlaceHold.Visible = false; } this.BindData(); }
/// <summary> /// Handles the Click event of the Save control. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="EventArgs"/> instance containing the event data. /// </param> private void SaveClick([NotNull] object sender, [NotNull] EventArgs e) { if (this.CategoryList.SelectedValue.Trim().Length == 0) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITFORUM", "MSG_CATEGORY"), MessageTypes.warning); return; } if (this.Name.Text.Trim().Length == 0) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITFORUM", "MSG_NAME_FORUM"), MessageTypes.warning); return; } if (this.SortOrder.Text.Trim().Length == 0) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITFORUM", "MSG_VALUE"), MessageTypes.warning); return; } short sortOrder; if (!ValidationHelper.IsValidPosShort(this.SortOrder.Text.Trim())) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITFORUM", "MSG_POSITIVE_VALUE"), MessageTypes.warning); return; } if (!short.TryParse(this.SortOrder.Text.Trim(), out sortOrder)) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITFORUM", "MSG_NUMBER"), MessageTypes.warning); return; } if (this.remoteurl.Text.IsSet()) { // add http:// by default if (!Regex.IsMatch(this.remoteurl.Text.Trim(), @"^(http|https|ftp|ftps|git|svn|news)\://.*")) { this.remoteurl.Text = "http://" + this.remoteurl.Text.Trim(); } if (!ValidationHelper.IsValidURL(this.remoteurl.Text)) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITFORUM", "MSG_INVALID_URL"), MessageTypes.warning); return; } } // Forum // vzrus: it's stored in the DB as int var forumId = this.GetQueryStringAsInt("fa"); var forumCopyId = this.GetQueryStringAsInt("copy"); object parentId = null; if (this.ParentList.SelectedValue.Length > 0) { parentId = this.ParentList.SelectedValue; } // parent selection check. if (parentId != null && parentId.ToString() == this.Request.QueryString.GetFirstOrDefault("fa")) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITFORUM", "MSG_PARENT_SELF")); return; } // The picked forum cannot be a child forum as it's a parent // If we update a forum ForumID > 0 if (forumId.HasValue && parentId != null) { var dependency = LegacyDb.forum_save_parentschecker(forumId.Value, parentId); if (dependency > 0) { this.PageContext.AddLoadMessage(this.GetText("ADMIN_EDITFORUM", "MSG_CHILD_PARENT")); return; } } // inital access mask if (!forumId.HasValue && !forumCopyId.HasValue) { if (this.AccessMaskID.SelectedValue.Length == 0) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITFORUM", "MSG_INITAL_MASK"), MessageTypes.warning); return; } } // duplicate name checking... if (!forumId.HasValue) { var forumList = LegacyDb.forum_list(this.PageContext.PageBoardID, null).AsEnumerable(); if (forumList.Any() && !this.Get <YafBoardSettings>().AllowForumsWithSameName && forumList.Any(dr => dr.Field <string>("Name") == this.Name.Text.Trim())) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_EDITFORUM", "MSG_FORUMNAME_EXISTS"), MessageTypes.warning); return; } } object themeUrl = null; if (this.ThemeList.SelectedValue.Length > 0) { themeUrl = this.ThemeList.SelectedValue; } var newForumId = LegacyDb.forum_save( forumId, this.CategoryList.SelectedValue, parentId, this.Name.Text.Trim(), this.Description.Text.Trim(), sortOrder, this.Locked.Checked, this.HideNoAccess.Checked, this.IsTest.Checked, this.Moderated.Checked, this.ModerateAllPosts.Checked ? null : this.ModeratedPostCount.Text, this.ModerateNewTopicOnly.Checked, this.AccessMaskID.SelectedValue, IsNull(this.remoteurl.Text), themeUrl, this.ForumImages.SelectedIndex > 0 ? this.ForumImages.SelectedValue.Trim() : null, this.Styles.Text, false); // empty out access table(s) this.GetRepository <Active>().DeleteAll(); this.GetRepository <ActiveAccess>().DeleteAll(); // Access if (forumId.HasValue || forumCopyId.HasValue) { foreach (var item in this.AccessList.Items.OfType <RepeaterItem>()) { var groupId = int.Parse(item.FindControlAs <Label>("GroupID").Text); LegacyDb.forumaccess_save( newForumId, groupId, item.FindControlAs <DropDownList>("AccessmaskID").SelectedValue); } } this.ClearCaches(); if (forumId.HasValue) { YafBuildLink.Redirect(ForumPages.admin_forums); } else { YafBuildLink.Redirect(ForumPages.admin_editforum, "fa={0}", newForumId); } }
/// <summary> /// Handles the Load event of the Page 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 Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.IsPostBack) { return; } this.ModerateAllPosts.Text = this.GetText("MODERATE_ALL_POSTS"); // Populate Forum Images Table this.CreateImagesDataTable(); this.ForumImages.Attributes["onchange"] = "getElementById('{1}').src='{0}{2}/' + this.value".FormatWith( YafForumInfo.ForumClientFileRoot, this.Preview.ClientID, YafBoardFolders.Current.Forums); this.BindData(); var forumId = this.GetQueryStringAsInt("fa") ?? this.GetQueryStringAsInt("copy"); if (!forumId.HasValue) { // Currently creating a New Forum, and auto fill the Forum Sort Order + 1 using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, null)) { var sortOrder = 1; try { var highestRow = dt.Rows[dt.Rows.Count - 1]; sortOrder = (short)highestRow["SortOrder"] + sortOrder; } catch { sortOrder = 1; } this.SortOrder.Text = sortOrder.ToString(); return; } } using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value)) { var row = dt.Rows[0]; var flags = new ForumFlags(row["Flags"]); this.Name.Text = row["Name"].ToString(); this.Description.Text = row["Description"].ToString(); this.SortOrder.Text = row["SortOrder"].ToString(); this.HideNoAccess.Checked = flags.IsHidden; this.Locked.Checked = flags.IsLocked; this.IsTest.Checked = flags.IsTest; this.ForumNameTitle.Text = this.Label1.Text = this.Name.Text; this.Moderated.Checked = flags.IsModerated; this.ModeratedPostCountRow.Visible = this.Moderated.Checked; this.ModerateNewTopicOnlyRow.Visible = this.Moderated.Checked; if (row["ModeratedPostCount"].IsNullOrEmptyDBField()) { this.ModerateAllPosts.Checked = true; } else { this.ModerateAllPosts.Checked = false; this.ModeratedPostCount.Visible = true; this.ModeratedPostCount.Text = row["ModeratedPostCount"].ToString(); } this.ModerateNewTopicOnly.Checked = row["IsModeratedNewTopicOnly"].ToType <bool>(); this.Styles.Text = row["Styles"].ToString(); this.CategoryList.SelectedValue = row["CategoryID"].ToString(); this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry var item = this.ForumImages.Items.FindByText(row["ImageURL"].ToString()); if (item != null) { item.Selected = true; this.Preview.Src = "{0}{2}/{1}".FormatWith( YafForumInfo.ForumClientFileRoot, row["ImageURL"], YafBoardFolders.Current.Forums); // path corrected } // populate parent forums list with forums according to selected category this.BindParentList(); if (!row.IsNull("ParentID")) { this.ParentList.SelectedValue = row["ParentID"].ToString(); } if (!row.IsNull("ThemeURL")) { this.ThemeList.SelectedValue = row["ThemeURL"].ToString(); } this.remoteurl.Text = row["RemoteURL"].ToString(); } this.NewGroupRow.Visible = false; }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { this.Get <IYafSession>().UnreadTopics = 0; this.RssFeed.AdditionalParameters = "f={0}".FormatWith(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f")); this.ForumJumpHolder.Visible = this.Get <YafBoardSettings>().ShowForumJump && this.PageContext.Settings.LockedForum == 0; this.LastPostImageTT = this.GetText("DEFAULT", "GO_LAST_POST"); if (this.ForumSearchHolder.Visible) { this.forumSearch.Attributes["onkeydown"] = "if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{0}').click();return false;}}}} else {{return true}}; " .FormatWith(this.forumSearchOK.ClientID); } if (!this.IsPostBack) { // PageLinks.Clear(); if (this.PageContext.Settings.LockedForum == 0) { this.PageLinks.AddRoot(); this.PageLinks.AddLink( this.PageContext.PageCategoryName, YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID)); } this.PageLinks.AddForum(this.PageContext.PageForumID, true); this.ShowList.DataSource = StaticDataHelper.TopicTimes(); this.ShowList.DataTextField = "TopicText"; this.ShowList.DataValueField = "TopicValue"; this._showTopicListSelected = (this.Get <IYafSession>().ShowList == -1) ? this.Get <YafBoardSettings>().ShowTopicsDefault : this.Get <IYafSession>().ShowList; this.moderate1.NavigateUrl = this.moderate2.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.moderating, "f={0}", this.PageContext.PageForumID); this.NewTopic1.NavigateUrl = this.NewTopic2.NavigateUrl = YafBuildLink.GetLinkNotEscaped(ForumPages.postmessage, "f={0}", this.PageContext.PageForumID); this.HandleWatchForum(); } if (this.Request.QueryString.GetFirstOrDefault("f") == null) { YafBuildLink.AccessDenied(); } if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess) { // attempt to get permission by redirecting to login... this.Get <IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers); } else if (!this.PageContext.ForumReadAccess) { YafBuildLink.AccessDenied(); } using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID)) { this._forum = dt.Rows[0]; } if (this._forum["RemoteURL"] != DBNull.Value) { this.Response.Clear(); this.Response.Redirect((string)this._forum["RemoteURL"]); } this._forumFlags = new ForumFlags(this._forum["Flags"]); this.PageTitle.Text = this._forum["Description"].ToString().IsSet() ? "{0} - <em>{1}</em>".FormatWith( this.HtmlEncode(this._forum["Name"]), this.HtmlEncode(this._forum["Description"])) : this.HtmlEncode(this._forum["Name"]); this.BindData(); // Always because of yaf:TopicLine if (!this.PageContext.ForumPostAccess || (this._forumFlags.IsLocked && !this.PageContext.ForumModeratorAccess)) { this.NewTopic1.Visible = false; this.NewTopic2.Visible = false; } if (this.PageContext.ForumModeratorAccess) { return; } this.moderate1.Visible = false; this.moderate2.Visible = false; }
/// <summary> /// The init poll ui. /// </summary> /// <param name="pollID"> /// The poll ID. /// </param> private void InitPollUI(int?pollID) { // we should get the schema anyway this._choices = LegacyDb.poll_stats(pollID); this._choices.Columns.Add("ChoiceOrderID", typeof(int)); // First existing values alway 1! int existingRowsCount = 1; int allExistingRowsCount = this._choices.Rows.Count; // we edit existing poll if (this._choices.HasRows()) { if ((this._choices.Rows[0]["UserID"].ToType <int>() != this.PageContext.PageUserID) && (!this.PageContext.IsAdmin) && (!this.PageContext.ForumModeratorAccess)) { YafBuildLink.RedirectInfoPage(InfoMessage.Invalid); } this.IsBoundCheckBox.Checked = this._choices.Rows[0]["IsBound"].ToType <bool>(); this.IsClosedBoundCheckBox.Checked = this._choices.Rows[0]["IsClosedBound"].ToType <bool>(); this.AllowMultipleChoicesCheckBox.Checked = this._choices.Rows[0]["AllowMultipleChoices"].ToType <bool>(); this.AllowSkipVoteCheckBox.Checked = this._choices.Rows[0]["AllowSkipVote"].ToType <bool>(); this.ShowVotersCheckBox.Checked = this._choices.Rows[0]["ShowVoters"].ToType <bool>(); this.Question.Text = this._choices.Rows[0]["Question"].ToString(); this.QuestionObjectPath.Text = this._choices.Rows[0]["QuestionObjectPath"].ToString(); if (this._choices.Rows[0]["Closes"] != DBNull.Value) { TimeSpan closing = (DateTime)this._choices.Rows[0]["Closes"] - DateTime.UtcNow; this.PollExpire.Text = (closing.TotalDays + 1).ToType <int>().ToString(); } else { this.PollExpire.Text = null; } foreach (DataRow choiceRow in this._choices.Rows) { choiceRow["ChoiceOrderID"] = existingRowsCount; existingRowsCount++; } } else { // A new topic is created // below check currently if works for topics only, but will do as some things are not enabled if (!this.CanCreatePoll()) { YafBuildLink.RedirectInfoPage(InfoMessage.AccessDenied); } // Get isBound value using page variables. They are initialized here. int pgidt = 0; // If a topic poll is edited or new topic created if (this._topicId > 0 && this._topicInfo != null) { // topicid should not be null here if (!this._topicInfo["PollID"].IsNullOrEmptyDBField()) { pgidt = (int)this._topicInfo["PollID"]; DataTable pollGroupData = LegacyDb.pollgroup_stats(pgidt); this.IsBoundCheckBox.Checked = Convert.ToBoolean(pollGroupData.Rows[0]["IsBound"]); //// this.IsClosedBoundCheckBox.Checked = Convert.ToBoolean(DB.pollgroup_stats(pgidt).Rows[0]["IsClosedBound"]); } } else if (this._forumId > 0 && (!(this._topicId > 0) || (!(this._editTopicId > 0)))) { // forumid should not be null here pgidt = (int)LegacyDb.forum_list(this.PageContext.PageBoardID, this._forumId).Rows[0]["PollGroupID"]; } else if (this._categoryId > 0) { // categoryid should not be null here pgidt = this.GetRepository <Category>() .Listread(this.PageContext.PageUserID, this._categoryId) .GetFirstRowColumnAsValue("PollGroupID", 0); } if (pgidt > 0) { if (LegacyDb.pollgroup_stats(pgidt).Rows[0]["IsBound"].ToType <int>() == 2) { this.IsBoundCheckBox.Checked = true; } if (LegacyDb.pollgroup_stats(pgidt).Rows[0]["IsClosedBound"].ToType <int>() == 4) { this.IsClosedBoundCheckBox.Checked = true; } } // clear the fields... this.PollExpire.Text = string.Empty; this.Question.Text = string.Empty; } // we add dummy rows to data table to fill in repeater empty fields int dummyRowsCount = this.Get <YafBoardSettings>().AllowedPollChoiceNumber - allExistingRowsCount - 1; for (int i = 0; i <= dummyRowsCount; i++) { DataRow drow = this._choices.NewRow(); drow["ChoiceOrderID"] = existingRowsCount + i; this._choices.Rows.Add(drow); } // Bind choices repeater this.ChoiceRepeater.DataSource = this._choices; this.ChoiceRepeater.DataBind(); this.ChoiceRepeater.Visible = true; // Show controls this.SavePoll.Visible = true; this.Cancel.Visible = true; this.PollRow1.Visible = true; this.PollRowExpire.Visible = true; this.IsClosedBound.Visible = this.IsBound.Visible = this.Get <YafBoardSettings>().AllowUsersHidePollResults || PageContext.IsAdmin || PageContext.IsForumModerator; this.tr_AllowMultipleChoices.Visible = this.Get <YafBoardSettings>().AllowMultipleChoices || PageContext.IsAdmin || PageContext.ForumModeratorAccess; this.tr_ShowVoters.Visible = true; this.tr_AllowSkipVote.Visible = false; }
// ---------------------------------------------------------------------------------- /// <summary> /// Gets the forums. /// </summary> /// <param name="boardID">The board ID.</param> /// <returns></returns> // ---------------------------------------------------------------------------------- private DataTable GetForums(int boardID) { DataTable forums = LegacyDb.forum_list(boardID, null); return(forums); }
/// <summary> /// The quick reply_ click. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void QuickReplyClick([NotNull] object sender, [NotNull] EventArgs e) { try { if (this.quickReplyEditor.Text.Length <= 0) { YafContext.Current.PageElements.RegisterJsBlockStartup( "openModalJs", JavaScriptBlocks.OpenModalJs("QuickReplyDialog")); this.PageContext.AddLoadMessage(this.GetText("EMPTY_MESSAGE"), MessageTypes.warning); return; } // No need to check whitespace if they are actually posting something if (this.Get <YafBoardSettings>().MaxPostSize > 0 && this.quickReplyEditor.Text.Length >= this.Get <YafBoardSettings>().MaxPostSize) { YafContext.Current.PageElements.RegisterJsBlockStartup( "openModalJs", JavaScriptBlocks.OpenModalJs("QuickReplyDialog")); this.PageContext.AddLoadMessage(this.GetText("ISEXCEEDED"), MessageTypes.warning); return; } if (this.EnableCaptcha() && !CaptchaHelper.IsValid(this.tbCaptcha.Text.Trim())) { YafContext.Current.PageElements.RegisterJsBlockStartup( "openModalJs", JavaScriptBlocks.OpenModalJs("QuickReplyDialog")); this.PageContext.AddLoadMessage(this.GetText("BAD_CAPTCHA"), MessageTypes.warning); return; } if (!(this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess) && this.Get <YafBoardSettings>().PostFloodDelay > 0) { if (YafContext.Current.Get <IYafSession>().LastPost > DateTime.UtcNow.AddSeconds(-this.Get <YafBoardSettings>().PostFloodDelay)) { YafContext.Current.PageElements.RegisterJsBlockStartup( "openModalJs", JavaScriptBlocks.OpenModalJs("QuickReplyDialog")); this.PageContext.AddLoadMessage( this.GetTextFormatted( "wait", (YafContext.Current.Get <IYafSession>().LastPost - DateTime.UtcNow.AddSeconds(-this.Get <YafBoardSettings>().PostFloodDelay)).Seconds), MessageTypes.warning); return; } } YafContext.Current.Get <IYafSession>().LastPost = DateTime.UtcNow; // post message... long messageId = 0; object replyTo = -1; var message = this.quickReplyEditor.Text; long topicId = this.PageContext.PageTopicID; // SPAM Check // Check if Forum is Moderated DataRow forumInfo; var isForumModerated = false; using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID)) { forumInfo = dt.Rows[0]; } if (forumInfo != null) { isForumModerated = this.CheckForumModerateStatus(forumInfo); } var spamApproved = true; var isPossibleSpamMessage = false; // Check for SPAM if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess && !this.Get <YafBoardSettings>().SpamServiceType.Equals(0)) { var spamChecker = new YafSpamCheck(); string spamResult; // Check content for spam if (spamChecker.CheckPostForSpam( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, YafContext.Current.Get <HttpRequestBase>().GetUserRealIPAddress(), this.quickReplyEditor.Text, this.PageContext.IsGuest ? null : this.PageContext.User.Email, out spamResult)) { switch (this.Get <YafBoardSettings>().SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}".FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 1: spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); YafContext.Current.PageElements.RegisterJsBlockStartup( "openModalJs", JavaScriptBlocks.OpenModalJs("QuickReplyDialog")); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.danger); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and bannded" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } // Check posts for urls if the user has only x posts if (YafContext.Current.CurrentUserData.NumPosts <= YafContext.Current.Get <YafBoardSettings>().IgnoreSpamWordCheckPostCount && !this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess) { var urlCount = UrlHelper.CountUrls(this.quickReplyEditor.Text); if (urlCount > this.PageContext.BoardSettings.AllowedNumberOfUrls) { spamResult = "The user posted {0} urls but allowed only {1}".FormatWith( urlCount, this.PageContext.BoardSettings.AllowedNumberOfUrls); switch (this.Get <YafBoardSettings>().SpamMessageHandling) { case 0: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}".FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 1: spamApproved = false; isPossibleSpamMessage = true; this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, it was flagged as unapproved post" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); break; case 2: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, post was rejected" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); YafContext.Current.PageElements.RegisterJsBlockStartup( "openModalJs", JavaScriptBlocks.OpenModalJs("QuickReplyDialog")); this.PageContext.AddLoadMessage(this.GetText("SPAM_MESSAGE"), MessageTypes.danger); return; case 3: this.Logger.Log( this.PageContext.PageUserID, "Spam Message Detected", "Spam Check detected possible SPAM ({1}) posted by User: {0}, user was deleted and bannded" .FormatWith( this.PageContext.IsGuest ? "Guest" : this.PageContext.PageUserName, spamResult), EventLogTypes.SpamMessageDetected); var userIp = new CombinedUserDataHelper( this.PageContext.CurrentUserData.Membership, this.PageContext.PageUserID).LastIP; UserMembershipHelper.DeleteAndBanUser( this.PageContext.PageUserID, this.PageContext.CurrentUserData.Membership, userIp); return; } } } if (!this.PageContext.IsGuest) { this.UpdateWatchTopic(this.PageContext.PageUserID, this.PageContext.PageTopicID); } } // If Forum is Moderated if (isForumModerated) { spamApproved = false; } // Bypass Approval if Admin or Moderator if (this.PageContext.IsAdmin || this.PageContext.ForumModeratorAccess) { spamApproved = true; } var messageFlags = new MessageFlags { IsHtml = this.quickReplyEditor.UsesHTML, IsBBCode = this.quickReplyEditor.UsesBBCode, IsApproved = spamApproved }; // Bypass Approval if Admin or Moderator. LegacyDb.message_save( topicId, this.PageContext.PageUserID, message, null, this.Get <HttpRequestBase>().GetUserRealIPAddress(), null, replyTo, messageFlags.BitValue, ref messageId); // Check to see if the user has enabled "auto watch topic" option in his/her profile. if (this.PageContext.CurrentUserData.AutoWatchTopics) { var watchTopicId = this.GetRepository <WatchTopic>().Check( this.PageContext.PageUserID, this.PageContext.PageTopicID); if (!watchTopicId.HasValue) { // subscribe to this topic this.GetRepository <WatchTopic>().Add(this.PageContext.PageUserID, this.PageContext.PageTopicID); } } if (messageFlags.IsApproved) { // send new post notification to users watching this topic/forum this.Get <ISendNotification>().ToWatchingUsers(messageId.ToType <int>()); if (Config.IsDotNetNuke && !this.PageContext.IsGuest) { this.Get <IActivityStream>().AddReplyToStream( this.PageContext.PageForumID, this.PageContext.PageTopicID, messageId.ToType <int>(), this.PageContext.PageTopicName, message); } // redirect to newly posted message YafBuildLink.Redirect(ForumPages.posts, "m={0}&#post{0}", messageId); } else { if (this.Get <YafBoardSettings>().EmailModeratorsOnModeratedPost) { // not approved, notifiy moderators this.Get <ISendNotification>().ToModeratorsThatMessageNeedsApproval( this.PageContext.PageForumID, messageId.ToType <int>(), isPossibleSpamMessage); } var url = YafBuildLink.GetLink(ForumPages.topics, "f={0}", this.PageContext.PageForumID); if (Config.IsRainbow) { YafBuildLink.Redirect(ForumPages.info, "i=1"); } else { YafBuildLink.Redirect(ForumPages.info, "i=1&url={0}", this.Server.UrlEncode(url)); } } } catch (Exception exception) { if (exception.GetType() != typeof(ThreadAbortException)) { this.Logger.Log(this.PageContext.PageUserID, this, exception); } } }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.IsPostBack) { return; } this.PageLinks.AddRoot(); this.PageLinks.AddLink( this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink(this.GetText("TEAM", "FORUMS"), YafBuildLink.GetLink(ForumPages.admin_forums)); this.PageLinks.AddLink(this.GetText("ADMIN_EDITFORUM", "TITLE"), string.Empty); this.Page.Header.Title = "{0} - {1} - {2}".FormatWith( this.GetText("ADMIN_ADMIN", "Administration"), this.GetText("TEAM", "FORUMS"), this.GetText("ADMIN_EDITFORUM", "TITLE")); this.Save.Text = this.GetText("SAVE"); this.Cancel.Text = this.GetText("CANCEL"); // Populate Forum Images Table this.CreateImagesDataTable(); this.ForumImages.Attributes["onchange"] = "getElementById('{1}').src='{0}{2}/' + this.value".FormatWith( YafForumInfo.ForumClientFileRoot, this.Preview.ClientID, YafBoardFolders.Current.Forums); this.BindData(); var forumId = this.GetQueryStringAsInt("fa") ?? this.GetQueryStringAsInt("copy"); if (!forumId.HasValue) { // Currently creating a New Forum, and auto fill the Forum Sort Order + 1 using ( DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, null)) { int sortOrder = 1; try { DataRow highestRow = dt.Rows[dt.Rows.Count - 1]; sortOrder = (short)highestRow["SortOrder"] + sortOrder; } catch { sortOrder = 1; } this.SortOrder.Text = sortOrder.ToString(); return; } } using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value)) { DataRow row = dt.Rows[0]; var flags = new ForumFlags(row["Flags"]); this.Name.Text = (string)row["Name"]; this.Description.Text = (string)row["Description"]; this.SortOrder.Text = row["SortOrder"].ToString(); this.HideNoAccess.Checked = flags.IsHidden; this.Locked.Checked = flags.IsLocked; this.IsTest.Checked = flags.IsTest; this.ForumNameTitle.Text = this.Name.Text; this.Moderated.Checked = flags.IsModerated; this.Styles.Text = row["Styles"].ToString(); this.CategoryList.SelectedValue = row["CategoryID"].ToString(); this.Preview.Src = "{0}images/spacer.gif".FormatWith(YafForumInfo.ForumClientFileRoot); ListItem item = this.ForumImages.Items.FindByText(row["ImageURL"].ToString()); if (item != null) { item.Selected = true; this.Preview.Src = "{0}{2}/{1}".FormatWith( YafForumInfo.ForumClientFileRoot, row["ImageURL"], YafBoardFolders.Current.Forums); // path corrected } // populate parent forums list with forums according to selected category this.BindParentList(); if (!row.IsNull("ParentID")) { this.ParentList.SelectedValue = row["ParentID"].ToString(); } if (!row.IsNull("ThemeURL")) { this.ThemeList.SelectedValue = row["ThemeURL"].ToString(); } this.remoteurl.Text = row["RemoteURL"].ToString(); } this.NewGroupRow.Visible = false; }