/// <summary> /// The mark as read_ click. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> protected void MarkAsRead_Click(object source, EventArgs e) { if (this.View == PMView.Outbox) { return; } using (DataView dv = DB.pmessage_list(this.PageContext.PageUserID, null, null).DefaultView) { if (this.View == PMView.Inbox) { dv.RowFilter = "IsRead = False AND IsDeleted = False AND IsArchived = False"; } else if (this.View == PMView.Archive) { dv.RowFilter = "IsRead = False AND IsArchived = True"; } foreach (DataRowView item in dv) { DB.pmessage_markread(item["UserPMessageID"]); // Clearing cache with old permissions data... this.PageContext.Cache.Remove( YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID))); } } this.BindData(); }
/// <summary> /// The save user_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void SaveUser_Click([NotNull] object sender, [NotNull] EventArgs e) { if (this.Page.IsValid) { bool autoWatchTopicsEnabled = false; var value = this.rblNotificationType.SelectedValue.ToEnum <UserNotificationSetting>(); if (value == UserNotificationSetting.TopicsIPostToOrSubscribeTo) { autoWatchTopicsEnabled = true; } // save the settings... DB.user_savenotification( this.PageContext.PageUserID, this.PMNotificationEnabled.Checked, autoWatchTopicsEnabled, this.rblNotificationType.SelectedValue, this.DailyDigestEnabled.Checked); // clear the cache for this user... UserMembershipHelper.ClearCacheForUserId(this.PageContext.PageUserID); // Clearing cache with old Active User Lazy Data ... this.PageContext.Cache.Remove( YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID))); this.PageContext.AddLoadMessage(this.GetText("SAVED_NOTIFICATION_SETTING")); } }
protected void BindData() { // Latest forum posts // Shows the latest n number of posts on the main forum list page string cacheKey = YafCache.GetBoardCacheKey(Constants.Cache.ForumActiveDiscussions); DataTable activeTopics = null; if (PageContext.IsGuest) { // allow caching since this is a guest... activeTopics = YafCache.Current [cacheKey] as DataTable; } if (activeTopics == null) { activeTopics = YAF.Classes.Data.DB.topic_latest(PageContext.PageBoardID, PageContext.BoardSettings.ActiveDiscussionsCount, PageContext.PageUserID); if (PageContext.IsGuest) { YafCache.Current.Insert(cacheKey, activeTopics, null, DateTime.Now.AddMinutes(PageContext.BoardSettings.ActiveDiscussionsCacheTimeout), TimeSpan.Zero); } } LatestPosts.DataSource = activeTopics; }
private void list_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "add") { YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_replacewords_edit); } else if (e.CommandName == "edit") { YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_replacewords_edit, "i={0}", e.CommandArgument); } else if (e.CommandName == "delete") { YAF.Classes.Data.DB.replace_words_delete(e.CommandArgument); YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ReplaceWords)); BindData(); } else if (e.CommandName == "export") { DataTable replaceDT = YAF.Classes.Data.DB.replace_words_list(PageContext.PageBoardID, null); replaceDT.DataSet.DataSetName = "YafReplaceWordsList"; replaceDT.TableName = "YafReplaceWords"; replaceDT.Columns.Remove("ID"); replaceDT.Columns.Remove("BoardID"); Response.ContentType = "text/xml"; Response.AppendHeader("Content-Disposition", "attachment; filename=YafReplaceWordsExport.xml"); replaceDT.DataSet.WriteXml(Response.OutputStream); Response.End(); } else if (e.CommandName == "import") { YafBuildLink.Redirect(ForumPages.admin_replacewords_import); } }
/// <summary> /// The add_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Add_Click(object sender, EventArgs e) { short sortOrder = 0; if (!ValidationHelper.IsValidPosShort(this.txtExecOrder.Text.Trim())) { PageContext.AddLoadMessage("The sort order value should be a positive integer from 0 to 32767."); return; } if (!short.TryParse(this.txtExecOrder.Text.Trim(), out sortOrder)) { PageContext.AddLoadMessage("You must enter an number value from 0 to 32767 for sort order."); return; } DB.bbcode_save( BBCodeID, PageContext.PageBoardID, this.txtName.Text.Trim(), this.txtDescription.Text, this.txtOnClickJS.Text, this.txtDisplayJS.Text, this.txtEditJS.Text, this.txtDisplayCSS.Text, this.txtSearchRegEx.Text, this.txtReplaceRegEx.Text, this.txtVariables.Text, this.chkUseModule.Checked, this.txtModuleClass.Text, sortOrder); PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.CustomBBCode)); ReplaceRulesCreator.ClearCache(); YafBuildLink.Redirect(ForumPages.admin_bbcode); }
protected void Save_Click(object sender, System.EventArgs e) { // Forum object accessMaskID = null; if (Request.QueryString ["i"] != null) { accessMaskID = Request.QueryString ["i"]; } YAF.Classes.Data.DB.accessmask_save(accessMaskID, PageContext.PageBoardID, Name.Text, ReadAccess.Checked, PostAccess.Checked, ReplyAccess.Checked, PriorityAccess.Checked, PollAccess.Checked, VoteAccess.Checked, ModeratorAccess.Checked, EditAccess.Checked, DeleteAccess.Checked, UploadAccess.Checked, DownloadAccess.Checked ); YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_accessmasks); }
/// <summary> /// The archive selected_ click. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> protected void ArchiveSelected_Click(object source, EventArgs e) { if (this.View != PMView.Inbox) { return; } long archivedCount = 0; foreach (GridViewRow item in this.MessagesView.Rows) { if (((CheckBox)item.FindControl("ItemCheck")).Checked) { DB.pmessage_archive(this.MessagesView.DataKeys[item.RowIndex].Value); archivedCount++; } } this.BindData(); this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(PageContext.PageUserID))); this.PageContext.AddLoadMessage(archivedCount == 1 ? this.PageContext.Localization.GetText("MSG_ARCHIVED") : this.PageContext.Localization.GetText("MSG_ARCHIVED+").FormatWith( archivedCount)); }
/// <summary> /// The list_ item command. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> protected void List_ItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "edit": // redirect to editing page YafBuildLink.Redirect(ForumPages.admin_editaccessmask, "i={0}", e.CommandArgument); break; case "delete": // attmempt to delete access masks if (DB.accessmask_delete(e.CommandArgument)) { // remove cache of forum moderators PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); BindData(); } else { // used masks cannot be deleted PageContext.AddLoadMessage("You cannot delete this access mask because it is in use."); } // quit switch break; } }
/// <summary> /// The delete selected_ click. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> protected void DeleteSelected_Click(object source, EventArgs e) { long nItemCount = 0; foreach (GridViewRow item in this.MessagesView.Rows) { if (((CheckBox)item.FindControl("ItemCheck")).Checked) { if (this.View == PMView.Outbox) { DB.pmessage_delete(this.MessagesView.DataKeys[item.RowIndex].Value, true); } else { DB.pmessage_delete(this.MessagesView.DataKeys[item.RowIndex].Value); } nItemCount++; } } this.BindData(); this.PageContext.AddLoadMessage(nItemCount == 1 ? this.PageContext.Localization.GetText("msgdeleted1") : this.PageContext.Localization.GetTextFormatted("msgdeleted2", nItemCount)); this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(PageContext.PageUserID))); }
/// <summary> /// The bb code list_ item command. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void bbCodeList_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "add") { YafBuildLink.Redirect(ForumPages.admin_bbcode_edit); } else if (e.CommandName == "edit") { YafBuildLink.Redirect(ForumPages.admin_bbcode_edit, "b={0}", e.CommandArgument); } else if (e.CommandName == "delete") { DB.bbcode_delete(e.CommandArgument); PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.CustomBBCode)); BindData(); } else if (e.CommandName == "export") { List <int> bbCodeIds = GetSelectedBBCodeIDs(); if (bbCodeIds.Count > 0) { // export this list as XML... DataTable dtBBCode = DB.bbcode_list(PageContext.PageBoardID, null); // remove all but required bbcodes... foreach (DataRow row in dtBBCode.Rows) { int id = Convert.ToInt32(row["BBCodeID"]); if (!bbCodeIds.Contains(id)) { // remove from this table... row.Delete(); } } // store delete changes... dtBBCode.AcceptChanges(); // export... dtBBCode.DataSet.DataSetName = "YafBBCodeList"; dtBBCode.TableName = "YafBBCode"; dtBBCode.Columns.Remove("BBCodeID"); dtBBCode.Columns.Remove("BoardID"); Response.ContentType = "text/xml"; Response.AppendHeader("Content-Disposition", "attachment; filename=YafBBCodeExport.xml"); dtBBCode.DataSet.WriteXml(Response.OutputStream); Response.End(); } else { PageContext.AddLoadMessage("Nothing selected to export."); } } else if (e.CommandName == "import") { YafBuildLink.Redirect(ForumPages.admin_bbcode_import); } }
private static void ClearCaches() { // clear moderatorss cache YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); // clear category cache... YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumCategory)); }
/// <summary> /// The clear caches. /// </summary> private void ClearCaches() { // clear moderatorss cache PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); // clear category cache... PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumCategory)); }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void save_Click(object sender, EventArgs e) { string code = this.Code.Text.Trim(); string emotion = this.Emotion.Text.Trim(); string icon = this.Icon.SelectedItem.Text.Trim(); int sortOrder; if (emotion.Length > 50) { PageContext.AddLoadMessage("An emotion description is too long."); return; } if (code.Length == 0) { PageContext.AddLoadMessage("Please enter the code to use for this emotion."); return; } if (code.Length > 10) { PageContext.AddLoadMessage("The code to use for this emotion should not be more then 10 symbols."); return; } if (!new System.Text.RegularExpressions.Regex(@"\[.+\]").IsMatch(code)) { PageContext.AddLoadMessage("Please enter the code to use for this emotion in square brackets."); return; } if (emotion.Length == 0) { PageContext.AddLoadMessage("Please enter an emotion for this icon."); return; } if (this.Icon.SelectedIndex < 1) { PageContext.AddLoadMessage("Please select an icon to use for this emotion."); return; } // Ederon 9/4/2007 if (!int.TryParse(this.SortOrder.Text, out sortOrder) || sortOrder < 0 || sortOrder > 255) { PageContext.AddLoadMessage("Sort order must be number between 0 and 255."); return; } DB.smiley_save(Request.QueryString.GetFirstOrDefault("s"), PageContext.PageBoardID, code, icon, emotion, sortOrder, 0); // invalidate the cache... PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.Smilies)); ReplaceRulesCreator.ClearCache(); YafBuildLink.Redirect(ForumPages.admin_smilies); }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { string[] ipParts = this.mask.Text.Trim().Split('.'); // do some validation... string ipError = string.Empty; if (ipParts.Length != 4) { ipError += "Invalid IP address."; } // see if they are numbers... ulong number; foreach (string ip in ipParts) { if (!ulong.TryParse(ip, out number)) { if (ip.Trim() != "*") { if (ip.Trim().Length == 0) { ipError += "\r\nOne of the IP section does not have a value. Valid values are 0-255 or \"*\" for a wildcard."; } else { ipError += "\r\n\"{0}\" is not a valid IP section value.".FormatWith(ip); } break; } } else { // try parse succeeded... verify number amount... if (number > 255) { ipError += "\r\n\"{0}\" is not a valid IP section value (must be less then 255).".FormatWith(ip); } } } // show error(s) if not valid... if (ipError.IsSet()) { PageContext.AddLoadMessage(ipError); return; } DB.bannedip_save(Request.QueryString.GetFirstOrDefault("i"), PageContext.PageBoardID, this.mask.Text.Trim(), this.BanReason.Text.Trim(), this.PageContext.PageUserID); // clear cache of banned IPs for this board PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BannedIP)); // go back to banned IP's administration page YafBuildLink.Redirect(ForumPages.admin_bannedip); }
protected void BindData() { // Active users // Call this before forum_stats to clean up active users ActiveUsers1.ActiveUserTable = YAF.Classes.Data.DB.active_list(PageContext.PageBoardID, null); // "Active Users" Count and Most Users Count DataRow activeStats = YAF.Classes.Data.DB.active_stats(PageContext.PageBoardID); ActiveUserCount.Text = FormatActiveUsers(activeStats); // Forum Statistics string key = YafCache.GetBoardCacheKey(Constants.Cache.BoardStats); DataRow statisticsDataRow = ( DataRow )Cache [key]; if (statisticsDataRow == null) { statisticsDataRow = YAF.Classes.Data.DB.board_poststats(PageContext.PageBoardID); Cache.Insert(key, statisticsDataRow, null, DateTime.Now.AddMinutes(PageContext.BoardSettings.ForumStatisticsCacheTimeout), TimeSpan.Zero); } // show max users... if (!statisticsDataRow.IsNull("MaxUsers")) { MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), statisticsDataRow ["MaxUsers"], YafDateTime.FormatDateTimeTopic(statisticsDataRow ["MaxUsersWhen"])); } else { MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), activeStats ["ActiveUsers"], YafDateTime.FormatDateTimeTopic(DateTime.Now)); } // Posts and Topic Count... StatsPostsTopicCount.Text = String.Format(PageContext.Localization.GetText("stats_posts"), statisticsDataRow ["posts"], statisticsDataRow ["topics"], statisticsDataRow ["forums"]); // Last post if (!statisticsDataRow.IsNull("LastPost")) { StatsLastPostHolder.Visible = true; LastPostUserLink.UserID = Convert.ToInt32(statisticsDataRow ["LastUserID"]); LastPostUserLink.UserName = statisticsDataRow ["LastUser"].ToString(); StatsLastPost.Text = String.Format(PageContext.Localization.GetText("stats_lastpost"), YafDateTime.FormatDateTimeTopic(( DateTime )statisticsDataRow ["LastPost"])); } else { StatsLastPostHolder.Visible = false; } // Member Count StatsMembersCount.Text = String.Format(PageContext.Localization.GetText("stats_members"), statisticsDataRow ["members"]); // Newest Member StatsNewestMember.Text = PageContext.Localization.GetText("stats_lastmember"); NewestMemberUserLink.UserID = Convert.ToInt32(statisticsDataRow ["LastMemberID"]); NewestMemberUserLink.UserName = statisticsDataRow ["LastMember"].ToString(); }
protected void save_Click(object sender, EventArgs e) { String [] ipParts = mask.Text.Trim().Split('.'); // do some validation... string ipError = ""; if (ipParts.Length != 4) { ipError += "Invalid IP address."; } // see if they are numbers... ulong number; foreach (string ip in ipParts) { if (!ulong.TryParse(ip, out number)) { if (ip.Trim() != "*") { if (ip.Trim().Length == 0) { ipError += "\r\nOne of the IP section does not have a value. Valid values are 0-255 or \"*\" for a wildcard."; } else { ipError += String.Format("\r\n\"{0}\" is not a valid IP section value.", ip); } break; } } else { // try parse succeeded... verify number amount... if (number > 255) { ipError += String.Format("\r\n\"{0}\" is not a valid IP section value (must be less then 255).", ip); } } } // show error(s) if not valid... if (!String.IsNullOrEmpty(ipError)) { PageContext.AddLoadMessage(ipError); return; } YAF.Classes.Data.DB.bannedip_save(Request.QueryString ["i"], PageContext.PageBoardID, mask.Text.Trim()); // clear cache of banned IPs for this board YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BannedIP)); // go back to banned IP's administration page YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.admin_bannedip); }
/// <summary> /// Handles click on save button. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { // go through all roles displayed on page for (int i = 0; i < this.UserGroups.Items.Count; i++) { // get current item RepeaterItem item = this.UserGroups.Items[i]; // get role ID from it int roleID = int.Parse(((Label)item.FindControl("GroupID")).Text); // get role name string roleName = string.Empty; using (DataTable dt = DB.group_list(this.PageContext.PageBoardID, roleID)) { foreach (DataRow row in dt.Rows) { roleName = (string)row["Name"]; } } // is user supposed to be in that role? bool isChecked = ((CheckBox)item.FindControl("GroupMember")).Checked; // save user in role DB.usergroup_save(this.CurrentUserID, roleID, isChecked); // update roles if this user isn't the guest if (!UserMembershipHelper.IsGuestUser(this.CurrentUserID)) { // get user's name string userName = UserMembershipHelper.GetUserNameFromID(this.CurrentUserID); // add/remove user from roles in membership provider if (isChecked && !RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.AddUserToRole(userName, roleName); } else if (!isChecked && RoleMembershipHelper.IsUserInRole(userName, roleName)) { RoleMembershipHelper.RemoveUserFromRole(userName, roleName); } // Clearing cache with old permisssions data... this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.CurrentUserID))); } } // update forum moderators cache just in case something was changed... this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); // clear the cache for this user... UserMembershipHelper.ClearCacheForUserId(this.CurrentUserID); this.BindData(); }
/// <summary> /// The bind data. /// </summary> private void BindData() { using (DataTable dt = DB.pmessage_list(Security.StringToLongOrRedirect(this.Request.QueryString.GetFirstOrDefault("pm")))) { if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; // if the pm isn't from or two the current user--then it's access denied if ((int)row["ToUserID"] != this.PageContext.PageUserID && (int)row["FromUserID"] != this.PageContext.PageUserID) { YafBuildLink.AccessDenied(); } this.SetMessageView( row["FromUserID"], row["ToUserID"], Convert.ToBoolean(row["IsInOutbox"]), Convert.ToBoolean(row["IsArchived"])); // get the return link to the pm listing if (this.IsOutbox) { this.PageLinks.AddLink(this.GetText("SENTITEMS"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=out")); } else if (this.IsArchived) { this.PageLinks.AddLink(this.GetText("ARCHIVE"), YafBuildLink.GetLink(ForumPages.cp_pm, "v=arch")); } else { this.PageLinks.AddLink(this.GetText("INBOX"), YafBuildLink.GetLink(ForumPages.cp_pm)); } this.PageLinks.AddLink(row["Subject"].ToString()); this.Inbox.DataSource = dt; } else { YafBuildLink.Redirect(ForumPages.cp_pm); } } this.DataBind(); if (!this.IsOutbox) { DB.pmessage_markread(this.Request.QueryString.GetFirstOrDefault("pm")); // Clearing cache with old permissions data... this.PageContext.Cache.Remove( YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID))); } }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click([NotNull] object sender, [NotNull] EventArgs e) { string languageFile = "english.xml"; var cultures = StaticDataHelper.Cultures().AsEnumerable().Where( c => c.Field <string>("CultureTag").Equals(this.Culture.SelectedValue)); if (cultures.Any()) { languageFile = cultures.First().Field <string>("CultureFile"); } DB.board_save( this.PageContext.PageBoardID, languageFile, this.Culture.SelectedValue, this.Name.Text, this.AllowThreaded.Checked); // save poll group this.PageContext.BoardSettings.BoardPollID = this.PollGroupListDropDown.SelectedIndex.ToType <int>() > 0 ? this.PollGroupListDropDown.SelectedValue.ToType <int>() : 0; this.PageContext.BoardSettings.Language = languageFile; this.PageContext.BoardSettings.Culture = this.Culture.SelectedValue; this.PageContext.BoardSettings.Theme = this.Theme.SelectedValue; // allow null/empty as a mobile theme many not be desired. this.PageContext.BoardSettings.MobileTheme = this.MobileTheme.SelectedValue ?? String.Empty; this.PageContext.BoardSettings.ShowTopicsDefault = this.ShowTopic.SelectedValue.ToType <int>(); this.PageContext.BoardSettings.AllowThemedLogo = this.AllowThemedLogo.Checked; this.PageContext.BoardSettings.FileExtensionAreAllowed = this.FileExtensionAllow.SelectedValue.ToType <int>() == 0 ? true : false; this.PageContext.BoardSettings.NotificationOnUserRegisterEmailList = this.NotificationOnUserRegisterEmailList.Text.Trim(); this.PageContext.BoardSettings.EmailModeratorsOnModeratedPost = this.EmailModeratorsOnModeratedPost.Checked; this.PageContext.BoardSettings.AllowDigestEmail = this.AllowDigestEmail.Checked; this.PageContext.BoardSettings.DefaultSendDigestEmail = this.DefaultSendDigestEmail.Checked; this.PageContext.BoardSettings.DefaultNotificationSetting = this.DefaultNotificationSetting.SelectedValue.ToEnum <UserNotificationSetting>(); // save the settings to the database ((YafLoadBoardSettings)this.PageContext.BoardSettings).SaveRegistry(); // Reload forum settings this.PageContext.BoardSettings = null; // Clearing cache with old users permissions data to get new default styles... this.PageContext.Cache.Remove((x) => x.StartsWith(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData))); YafBuildLink.Redirect(ForumPages.admin_admin); }
/// <summary> /// The create user wizard 1_ continue button click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e) { // vzrus: to clear the cache to show user in the list at once this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.UsersOnlineStatus)); this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BoardUserStats)); // redirect to the main forum URL YafBuildLink.Redirect(ForumPages.forum); }
/// <summary> /// The login 1_ authenticate. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { var userName = this.Login1.FindControlAs <TextBox>("UserName"); var password = this.Login1.FindControlAs <TextBox>("Password"); e.Authenticated = PageContext.CurrentMembership.ValidateUser(userName.Text.Trim(), password.Text.Trim()); // vzrus: to clear the cache to show user in the list at once this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.UsersOnlineStatus)); }
/// <summary> /// The save_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Save_Click(object sender, EventArgs e) { // retrieve access mask ID from parameter (if applicable) object accessMaskID = null; if (Request.QueryString.GetFirstOrDefault("i") != null) { accessMaskID = Request.QueryString.GetFirstOrDefault("i"); } if (this.Name.Text.Trim().Length <= 0) { PageContext.AddLoadMessage("You must enter a name for the Access Mask."); return; } short sortOrder = 0; if (!ValidationHelper.IsValidPosShort(this.SortOrder.Text.Trim())) { PageContext.AddLoadMessage("The Sort Order value should be a positive integer from 0 to 32767."); return; } if (!short.TryParse(this.SortOrder.Text.Trim(), out sortOrder)) { PageContext.AddLoadMessage("You must enter a number value from 0 to 32767 for sort order."); return; } // save it DB.accessmask_save( accessMaskID, PageContext.PageBoardID, this.Name.Text, this.ReadAccess.Checked, this.PostAccess.Checked, this.ReplyAccess.Checked, this.PriorityAccess.Checked, this.PollAccess.Checked, this.VoteAccess.Checked, this.ModeratorAccess.Checked, this.EditAccess.Checked, this.DeleteAccess.Checked, this.UploadAccess.Checked, this.DownloadAccess.Checked, sortOrder); // clear cache PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); // get back to access masks administration YafBuildLink.Redirect(ForumPages.admin_accessmasks); }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load(object sender, EventArgs e) { FormsAuthentication.SignOut(); // Clearing user cache with permissions data and active users cache... this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(this.PageContext.PageUserID))); this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.UsersOnlineStatus)); Session.Abandon(); YafBuildLink.Redirect(ForumPages.forum); }
protected void Logout_Click(object sender, EventArgs e) { FormsAuthentication.SignOut(); // Clearing user cache with permissions data and active users cache... YafContext.Current.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(YafContext.Current.PageUserID))); YafContext.Current.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.UsersOnlineStatus)); Session.Abandon(); Response.Redirect(Request.RawUrl); }
/// <summary> /// The delete all_ click. /// </summary> /// <param name="source"> /// The source. /// </param> /// <param name="e"> /// The e. /// </param> protected void DeleteAll_Click(object source, EventArgs e) { long nItemCount = 0; object toUserID = null; object fromUserID = null; bool isoutbox = false; if (this.View == PMView.Outbox) { fromUserID = this.PageContext.PageUserID; isoutbox = true; } else { toUserID = this.PageContext.PageUserID; } using (DataView dv = DB.pmessage_list(toUserID, fromUserID, null).DefaultView) { if (this.View == PMView.Inbox) { dv.RowFilter = "IsDeleted = False AND IsArchived = False"; } else if (this.View == PMView.Outbox) { dv.RowFilter = "IsInOutbox = True"; } else if (this.View == PMView.Archive) { dv.RowFilter = "IsArchived = True"; } foreach (DataRowView item in dv) { if (isoutbox) { DB.pmessage_delete(item["UserPMessageID"], true); } else { DB.pmessage_delete(item["UserPMessageID"]); } nItemCount++; } } this.BindData(); this.PageContext.AddLoadMessage(this.PageContext.Localization.GetTextFormatted("msgdeleted2", nItemCount)); this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(PageContext.PageUserID))); }
/// <summary> /// The create p messages. /// </summary> /// <returns> /// The number of created p messages. /// </returns> private int CreatePMessages() { int userID = this.PageContext.PageUserID; int numPMessages = 0; if (!int.TryParse(PMessagesNumber.Text.Trim(), out numPMessages)) { return(0); } if (numPMessages <= 0) { return(0); } string _fromUser = From.Text.Trim(); string _toUser = To.Text.Trim(); if (numPMessages > this.createCommonLimit) { numPMessages = this.createCommonLimit; } int i = 0; for (i = 0; i < numPMessages; i++) { this.randomGuid = Guid.NewGuid().ToString(); DB.pmessage_save( DB.user_get(YafContext.Current.PageBoardID, Membership.GetUser(_fromUser).ProviderUserKey), DB.user_get(YafContext.Current.PageBoardID, Membership.GetUser(_toUser).ProviderUserKey), this.TopicPrefixTB.Text.Trim() + this.randomGuid, this.pmessagePrefix + this.randomGuid + " " + PMessageText.Text.Trim(), 6); } if (this.MarkRead.Checked) { int userAID = DB.user_get(YafContext.Current.PageBoardID, Membership.GetUser(_toUser).ProviderUserKey); foreach (DataRow dr in DB.pmessage_list(null, userAID, null).Rows) { DB.pmessage_markread(dr["PMessageID"]); // Clearing cache with old permissions data... this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ActiveUserLazyData.FormatWith(userAID))); } } return(i); }
/// <summary> /// Handles post moderation events/buttons. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void List_ItemCommand(object sender, RepeaterCommandEventArgs e) { // which command are we handling switch (e.CommandName.ToLower()) { case "approve": // approve post DB.message_approve(e.CommandArgument); // Update statistics this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BoardStats)); // re-bind data BindData(); // tell user message was approved PageContext.AddLoadMessage(GetText("APPROVED")); // send notification to watching users... this.Get <YafSendNotification>().ToWatchingUsers(e.CommandArgument.ToType <int>()); break; case "delete": // delete message DB.message_delete(e.CommandArgument, true, string.Empty, 1, true); // Update statistics this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BoardStats)); // re-bind data BindData(); // tell user message was deleted PageContext.AddLoadMessage(GetText("DELETED")); break; } // see if there are any items left... DataTable dt = DB.message_unapproved(PageContext.PageForumID); if (dt.Rows.Count == 0) { // nope -- redirect back to the moderate main... YafBuildLink.Redirect(ForumPages.moderate_index); } }
/// <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) { // Latest forum posts // Shows the latest n number of posts on the main forum list page string cacheKey = YafCache.GetBoardCacheKey(Constants.Cache.ForumActiveDiscussions); DataTable activeTopics = null; if (this.PageContext.IsGuest) { // allow caching since this is a guest... activeTopics = this.PageContext.Cache[cacheKey] as DataTable; } if (activeTopics == null) { activeTopics = DB.topic_latest( this.PageContext.PageBoardID, this.PageContext.BoardSettings.ActiveDiscussionsCount, this.PageContext.PageUserID, this.PageContext.BoardSettings.UseStyledNicks, this.PageContext.BoardSettings.NoCountForumsInActiveDiscussions); // Set colorOnly parameter to true, as we get all but color from css in the place if (this.PageContext.BoardSettings.UseStyledNicks) { new StyleTransform(this.PageContext.Theme).DecodeStyleByTable(ref activeTopics, true, "LastUserStyle"); } if (this.PageContext.IsGuest) { this.PageContext.Cache.Insert( cacheKey, activeTopics, null, DateTime.UtcNow.AddMinutes(this.PageContext.BoardSettings.ActiveDiscussionsCacheTimeout), TimeSpan.Zero); } } bool groupAccess = this.Get <YafPermissions>().Check(this.PageContext.BoardSettings.PostLatestFeedAccess); this.AtomFeed.Visible = this.PageContext.BoardSettings.ShowAtomLink && groupAccess; this.RssFeed.Visible = this.PageContext.BoardSettings.ShowRSSLink && groupAccess; this.lastPostToolTip = this.PageContext.Localization.GetText("DEFAULT", "GO_LAST_POST"); this.LatestPosts.DataSource = activeTopics; this.LatestPosts.DataBind(); }
/// <summary> /// The post reply handle new post. /// </summary> /// <returns> /// The post reply handle new post. /// </returns> protected long PostReplyHandleNewPost(out long topicId) { long messageId = 0; if (!this.PageContext.ForumPostAccess) { YafBuildLink.AccessDenied(); } // make message flags var messageFlags = new MessageFlags { IsHtml = this._forumEditor.UsesHTML, IsBBCode = this._forumEditor.UsesBBCode, IsPersistent = this.PostOptions1.PersistantChecked, /* Bypass Approval if Admin or Moderator.*/ IsApproved = this.PageContext.IsAdmin || this.PageContext.IsModerator }; string blogPostID = this.HandlePostToBlog(this._forumEditor.Text, this.TopicSubjectTextBox.Text); // Save to Db topicId = DB.topic_save( this.PageContext.PageForumID, this.TopicSubjectTextBox.Text.Trim(), this._forumEditor.Text, this.PageContext.PageUserID, this.Priority.SelectedValue, this.User != null ? null : this.From.Text, this.Request.UserHostAddress, null, blogPostID, messageFlags.BitValue, ref messageId); this.UpdateWatchTopic(this.PageContext.PageUserID, (int)topicId); // clear caches as stats changed if (messageFlags.IsApproved) { this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BoardStats)); this.PageContext.Cache.Remove(YafCache.GetBoardCacheKey(Constants.Cache.BoardUserStats)); } return(messageId); }
private void UserList_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { switch (e.CommandName) { case "edit": YAF.Classes.Utils.YafBuildLink.Redirect(YAF.Classes.Utils.ForumPages.mod_forumuser, "f={0}&u={1}", PageContext.PageForumID, e.CommandArgument); break; case "remove": YAF.Classes.Data.DB.userforum_delete(e.CommandArgument, PageContext.PageForumID); BindData(); // clear moderatorss cache YafCache.Current.Remove(YafCache.GetBoardCacheKey(Constants.Cache.ForumModerators)); break; } }