/// <summary> /// Sends a new user notification email to all emails in the NotificationOnUserRegisterEmailList /// Setting /// </summary> /// <param name="user">The user.</param> /// <param name="userId">The user id.</param> public void SendRegistrationNotificationEmail([NotNull] MembershipUser user, int userId) { var emails = this.BoardSettings.NotificationOnUserRegisterEmailList.Split(';'); var subject = this.Get <ILocalization>().GetTextFormatted( "NOTIFICATION_ON_USER_REGISTER_EMAIL_SUBJECT", this.BoardSettings.Name); var notifyAdmin = new TemplateEmail("NOTIFICATION_ON_USER_REGISTER") { TemplateParams = { ["{adminlink}"] = BuildLink.GetLinkNotEscaped( ForumPages.admin_edituser, true, "u={0}", userId), ["{user}"] = user.UserName, ["{email}"] = user.Email } }; Parallel.ForEach( emails.Where(email => email.Trim().IsSet()), email => notifyAdmin.SendEmail(new MailAddress(email.Trim()), subject)); }
/// <summary> /// The bind create new poll row. /// </summary> private void BindCreateNewPollRow() { this.CreatePoll.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.PollEdit, "{0}", this.ParamsToSend()); this.CreatePoll.DataBind(); this.NewPollRow.Visible = true; }
/// <summary> /// Send Email Verification to changed Email Address /// </summary> /// <param name="newEmail"> /// The new email. /// </param> /// <param name="userId"> /// The user Id. /// </param> /// <param name="userName"> /// The user Name. /// </param> public void SendEmailChangeVerification([NotNull] string newEmail, [NotNull] int userId, string userName) { var hashInput = $"{System.DateTime.UtcNow}{newEmail}{Security.CreatePassword(20)}"; var hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashInput, "md5"); // Create Email var changeEmail = new TemplateEmail("CHANGEEMAIL") { TemplateParams = { ["{user}"] = userName, ["{link}"] = $"{BuildLink.GetLinkNotEscaped(ForumPages.Approve, true, "k={0}", hash)}\r\n\r\n", ["{newemail}"] = newEmail, ["{key}"] = hash } }; // save a change email reference to the db this.GetRepository <CheckEmail>().Save(userId, hash, newEmail); // send a change email message... changeEmail.SendEmail( new MailAddress(newEmail), this.Get <ILocalization>().GetText("COMMON", "CHANGEEMAIL_SUBJECT")); // show a confirmation BoardContext.Current.AddLoadMessage( string.Format(this.Get <ILocalization>().GetText("PROFILE", "mail_sent"), newEmail), MessageTypes.info); }
/// <summary> /// Get the Sitemap URLs. /// </summary> /// <param name="portalId">The portal id.</param> /// <param name="portalSettings">The portal settings.</param> /// <param name="version">The version.</param> /// <returns> /// The List with URLs. /// </returns> public override List <SitemapUrl> GetUrls(int portalId, PortalSettings portalSettings, string version) { var urls = new List <SitemapUrl>(); if (BoardContext.Current == null) { return(urls); } var forumList = BoardContext.Current.GetRepository <Forum>().ListAll( BoardContext.Current.BoardSettings.BoardID, UserMembershipHelper.GuestUserId); urls.AddRange( forumList.Select( forum => new SitemapUrl { Url = BuildLink.GetLinkNotEscaped( ForumPages.Topics, true, "f={0}", forum.Item1.ID), Priority = (float)0.8, LastModified = DateTime.Now, ChangeFrequency = SitemapChangeFrequency.Always })); return(urls); }
/// <summary> /// Sends the verification email. /// </summary> /// <param name="user">The user.</param> /// <param name="email">The email.</param> /// <param name="userId">The user identifier.</param> /// <param name="newUsername">The new username.</param> public void SendVerificationEmail( [NotNull] MembershipUser user, [NotNull] string email, int?userId, string newUsername = null) { CodeContracts.VerifyNotNull(email, "email"); CodeContracts.VerifyNotNull(user, "user"); var hashInput = $"{System.DateTime.UtcNow}{email}{Security.CreatePassword(20)}"; var hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashInput, "md5"); // save verification record... this.GetRepository <CheckEmail>().Save(userId, hash, user.Email); var subject = this.Get <ILocalization>().GetTextFormatted( "VERIFICATION_EMAIL_SUBJECT", this.BoardSettings.Name); var verifyEmail = new TemplateEmail("VERIFYEMAIL") { TemplateParams = { ["{link}"] = BuildLink.GetLinkNotEscaped(ForumPages.Approve, true, "k={0}", hash), ["{key}"] = hash, ["{username}"] = user.UserName } }; verifyEmail.SendEmail(new MailAddress(email, newUsername ?? user.UserName), subject); }
/// <summary> /// Sends a new user notification email to all emails in the NotificationOnUserRegisterEmailList /// Setting /// </summary> /// <param name="user">The user.</param> /// <param name="userId">The user id.</param> public void SendRegistrationNotificationEmail([NotNull] AspNetUsers user, int userId) { if (this.BoardSettings.NotificationOnUserRegisterEmailList.IsNotSet()) { return; } var emails = this.BoardSettings.NotificationOnUserRegisterEmailList.Split(';'); var subject = string.Format( this.Get <ILocalization>().GetText( "COMMON", "NOTIFICATION_ON_USER_REGISTER_EMAIL_SUBJECT", this.BoardSettings.Language), this.BoardSettings.Name); var notifyAdmin = new TemplateEmail("NOTIFICATION_ON_USER_REGISTER") { TemplateLanguageFile = this.BoardSettings.Language, TemplateParams = { ["{adminlink}"] = BuildLink.GetLinkNotEscaped( ForumPages.Admin_EditUser, true, "u={0}", userId), ["{user}"] = user.UserName, ["{email}"] = user.Email } }; emails.Where(email => email.Trim().IsSet()) .ForEach(email => notifyAdmin.SendEmail(new MailAddress(email.Trim()), subject)); }
/// <summary> /// Sends the verification email. /// </summary> /// <param name="user">The user.</param> /// <param name="email">The email.</param> /// <param name="userId">The user identifier.</param> /// <param name="newUsername">The new username.</param> public void SendVerificationEmail( [NotNull] AspNetUsers user, [NotNull] string email, int?userId, string newUsername = null) { CodeContracts.VerifyNotNull(email, "email"); CodeContracts.VerifyNotNull(user, "user"); var code = HttpUtility.UrlEncode( this.Get <IAspNetUsersHelper>().GenerateEmailConfirmationResetToken(user.Id)); // save verification record... this.GetRepository <CheckEmail>().Save(userId, code, user.Email); var subject = this.Get <ILocalization>().GetTextFormatted( "VERIFICATION_EMAIL_SUBJECT", this.BoardSettings.Name); var verifyEmail = new TemplateEmail("VERIFYEMAIL") { TemplateParams = { ["{link}"] = BuildLink.GetLinkNotEscaped(ForumPages.Account_Approve, true, "code={0}", code), ["{key}"] = code, ["{username}"] = user.UserName } }; verifyEmail.SendEmail(new MailAddress(email, newUsername ?? user.UserName), subject); }
/// <summary> /// The process request. /// </summary> /// <param name="context"> /// The context. /// </param> public void ProcessRequest([NotNull] HttpContext context) { var siteMap = new SiteMap(); var forumList = this.GetRepository <Forum>().ListAll( BoardContext.Current.BoardSettings.BoardID, UserMembershipHelper.GuestUserId); forumList.ForEach( forum => siteMap.Add( new UrlLocation { Url = BuildLink.GetLinkNotEscaped( ForumPages.Topics, true, "f={0}", forum.Item1.ID), Priority = 0.8D, LastModified = forum.Item1.LastPosted ?? DateTime.UtcNow, ChangeFrequency = UrlLocation.ChangeFrequencies.always })); context.Response.Clear(); var xs = new XmlSerializer(typeof(SiteMap)); context.Response.ContentType = "text/xml"; xs.Serialize(context.Response.Output, siteMap); context.Response.End(); }
/// <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) { // check if this feature is disabled if (!this.Get <BoardSettings>().AllowPrivateMessages) { BuildLink.RedirectInfoPage(InfoMessage.Disabled); } if (this.IsPostBack) { return; } if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v").IsSet()) { this.View = PmViewConverter.FromQueryString(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v")); this.hidLastTab.Value = $"View{(int)this.View}"; } this.PageLinks.AddRoot(); this.PageLinks.AddLink( this.Get <BoardSettings>().EnableDisplayName ? this.PageContext.CurrentUserData.DisplayName : this.PageContext.PageUserName, BuildLink.GetLink(ForumPages.cp_profile)); this.PageLinks.AddLink(this.GetText("TITLE")); this.NewPM.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.pmessage); this.NewPM2.NavigateUrl = this.NewPM.NavigateUrl; }
/// <summary> /// The method creates SyndicationFeed for topic announcements. /// </summary> /// <param name="feedType"> /// The FeedType. /// </param> /// <param name="atomFeedByVar"> /// The Atom feed checker. /// </param> /// <returns> /// The <see cref="YafSyndicationFeed"/>. /// </returns> private YafSyndicationFeed GetLatestAnnouncementsFeed(RssFeeds feedType, bool atomFeedByVar) { var syndicationItems = new List <SyndicationItem>(); var dt = this.GetRepository <Topic>().AnnouncementsAsDataTable( this.PageContext.PageBoardID, 10, this.PageContext.PageUserID); var urlAlphaNum = FormatUrlForFeed(BaseUrlBuilder.BaseUrl); var feed = new YafSyndicationFeed( this.GetText("POSTMESSAGE", "ANNOUNCEMENT"), feedType, atomFeedByVar ? SyndicationFormats.Atom.ToInt() : SyndicationFormats.Rss.ToInt(), urlAlphaNum); dt.Rows.Cast <DataRow>().Where(row => !row["TopicMovedID"].IsNullOrEmptyDBField()).ForEach( row => { var lastPosted = Convert.ToDateTime(row["LastPosted"]) + this.Get <IDateTime>().TimeOffset; if (syndicationItems.Count <= 0) { feed.Authors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["UserID"].ToType <long>(), null, null)); feed.LastUpdatedTime = DateTime.UtcNow + this.Get <IDateTime>().TimeOffset; } feed.Contributors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["LastUserID"].ToType <long>(), null, null)); syndicationItems.AddSyndicationItem( row["Topic"].ToString(), row["Message"].ToString(), null, BuildLink.GetLinkNotEscaped( ForumPages.Posts, true, "t={0}", this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("t")), $"urn:{urlAlphaNum}:ft{feedType}:st{(atomFeedByVar ? SyndicationFormats.Atom.ToInt() : SyndicationFormats.Rss.ToInt())}:tid{this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("t")}:lmid{row["LastMessageID"]}:{this.PageContext.PageBoardID}" .Unidecode(), lastPosted, feed); }); feed.Items = syndicationItems; return(feed); }
/// <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.PageContext.QueryIDs = new QueryStringIDHelper("u"); if (this.PageContext.CurrentForumPage.IsAdminPage && this.PageContext.IsAdmin && this.PageContext.QueryIDs.ContainsKey("u")) { this.currentUserId = this.PageContext.QueryIDs["u"].ToType <int>(); } else { this.currentUserId = this.PageContext.PageUserID; } if (this.IsPostBack) { return; } // check if it's a link from the avatar picker if (this.Get <HttpRequestBase>().QueryString.Exists("av")) { // save the avatar right now... this.GetRepository <User>().SaveAvatar( this.currentUserId, $"{BaseUrlBuilder.BaseUrl}{this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("av")}", null, null); // clear the cache for this user... this.Get <IRaiseEvent>().Raise(new UpdateUserEvent(this.currentUserId)); } this.NoAvatar.Text = this.GetText("CP_EDITAVATAR", "NOAVATAR"); var addAdminParam = string.Empty; if (this.PageContext.CurrentForumPage.IsAdminPage) { addAdminParam = $"u={this.currentUserId}"; } this.OurAvatar.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.avatar, addAdminParam); this.OurAvatar.Text = this.GetText("CP_EDITAVATAR", "OURAVATAR_SELECT"); this.noteRemote.Text = this.GetTextFormatted( "NOTE_REMOTE", this.Get <BoardSettings>().AvatarWidth.ToString(), this.Get <BoardSettings>().AvatarHeight.ToString()); this.noteLocal.Text = this.GetTextFormatted( "NOTE_LOCAL", this.Get <BoardSettings>().AvatarWidth.ToString(), this.Get <BoardSettings>().AvatarHeight, (this.Get <BoardSettings>().AvatarSize / 1024).ToString()); this.BindData(); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { this.ViewPostsLink.NavigateUrl = BuildLink.GetLinkNotEscaped( ForumPages.Search, "postedby={0}", !this.CurrentUserDataHelper.IsGuest ? this.Get <BoardSettings>().EnableDisplayName ? this.CurrentUserDataHelper.DisplayName : this.CurrentUserDataHelper.UserName : UserMembershipHelper.GuestUserName); this.ReportUserRow.Visible = this.Get <BoardSettings>().StopForumSpamApiKey.IsSet(); // load ip address history for user... this.IPAddresses.Take(5).ForEach( ipAddress => this.IpAddresses.Text += $@"<a href=""{string.Format(this.Get<BoardSettings>().IPInfoPageURL, ipAddress)}"" target=""_blank"" title=""{this.GetText("COMMON", "TT_IPDETAILS")}""> {ipAddress} </a> <br />"); // if no ip disable BanIp checkbox if (!this.IPAddresses.Any()) { this.BanIps.Checked = false; this.BanIps.Enabled = false; this.ReportUserRow.Visible = false; } // show post count... this.PostCount.Text = this.AllPostsByUser.Count().ToString(); // get user's info this.CurrentUser = this.GetRepository <User>().UserList( this.PageContext.PageBoardID, this.CurrentUserId.ToType <int?>(), null, null, null, false).FirstOrDefault(); // there is no such user if (this.CurrentUser?.Suspended != null) { this.SuspendedTo.Visible = true; // is user suspended? this.SuspendedTo.Text = $"<div class=\"alert alert-info\" role=\"alert\">{this.GetText("PROFILE", "ENDS")} {this.Get<IDateTime>().FormatDateTime(this.CurrentUser.Suspended)}</div>"; } this.DataBind(); }
/// <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.PageContext.IsGuest) { BuildLink.AccessDenied(); } if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m").IsSet()) { if (!int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m"), out this.messageID)) { this.Get <HttpResponseBase>().Redirect( BuildLink.GetLink(ForumPages.error, "Incorrect message value: {0}", this.messageID)); } this.ReturnBtn.Visible = true; } if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f").IsSet()) { // We check here if the user have access to the option if (this.PageContext.IsGuest) { this.Get <HttpResponseBase>().Redirect(BuildLink.GetLinkNotEscaped(ForumPages.info, "i=4")); } if (!int.TryParse(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f"), out this.forumID)) { this.Get <HttpResponseBase>().Redirect( BuildLink.GetLink(ForumPages.error, "Incorrect forum value: {0}", this.forumID)); } this.ReturnModBtn.Visible = true; } this.originalRow = this.GetRepository <Message>().SecAsDataTable(this.messageID, this.PageContext.PageUserID); if (this.originalRow.Rows.Count <= 0) { this.Get <HttpResponseBase>().Redirect( BuildLink.GetLink(ForumPages.error, "Incorrect message value: {0}", this.messageID)); } if (this.IsPostBack) { return; } this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, BuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); this.BindData(); }
/// <summary> /// Raises the Load event. /// </summary> /// <param name="e"> /// The e. /// </param> protected override void OnLoad([NotNull] EventArgs e) { base.OnLoad(e); var buttonGroup = new HtmlGenericControl("div"); buttonGroup.Attributes.Add(HtmlTextWriterAttribute.Class.ToString(), "btn-group mb-3 d-none d-md-block"); this.Controls.Add(buttonGroup); // get the localized character set var charSet = this.GetText("LANGUAGE", "CHARSET").Split('/'); charSet.ForEach( t => { // get the current selected character (if there is one) var selectedLetter = this.CurrentLetter; // go through all letters in a set t.ForEach( letter => { // create a link to this letter var link = new HyperLink { ToolTip = this.GetTextFormatted( "ALPHABET_FILTER_BY", letter.ToString()), Text = letter.ToString(), NavigateUrl = BuildLink.GetLinkNotEscaped( ForumPages.Members, "letter={0}", letter == '#' ? '_' : letter) }; if (selectedLetter != char.MinValue && selectedLetter == letter) { // current letter is selected, use specified style link.CssClass = "btn btn-secondary active"; } else { link.CssClass = "btn btn-secondary"; } buttonGroup.Controls.Add(link); }); }); }
/// <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.PageContext.IsGuest) { BuildLink.AccessDenied(); } if (this.Get <HttpRequestBase>().QueryString.Exists("m")) { this.messageID = Security.StringToIntOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("m")); this.ReturnBtn.Visible = true; } if (this.Get <HttpRequestBase>().QueryString.Exists("f")) { // We check here if the user have access to the option if (this.PageContext.IsGuest) { this.Get <HttpResponseBase>().Redirect(BuildLink.GetLinkNotEscaped(ForumPages.Info, "i=4")); } this.forumID = Security.StringToIntOrRedirect(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("f")); this.ReturnModBtn.Visible = true; } this.originalMessage = this.GetRepository <Message>().GetMessageWithAccess(this.messageID, this.PageContext.PageUserID); if (this.originalMessage == null) { this.Get <HttpResponseBase>().Redirect( BuildLink.GetLink(ForumPages.Error, "Incorrect message value: {0}", this.messageID)); } this.PageLinks.AddForum(this.originalMessage.Item4.ID); this.PageLinks.AddTopic(this.originalMessage.Item1.TopicName, this.originalMessage.Item1.ID); this.PageLinks.AddLink(this.GetText("TITLE"), string.Empty); if (this.IsPostBack) { return; } this.BindData(); }
/// <summary> /// Sends a spam bot notification to admins. /// </summary> /// <param name="user">The user.</param> /// <param name="userId">The user id.</param> public void SendSpamBotNotificationToAdmins([NotNull] MembershipUser user, int userId) { // Get Admin Group ID var adminGroupId = this.GetRepository <Group>().List(boardId: BoardContext.Current.PageBoardID) .Where(group => group.Name.Contains("Admin")).Select(group => group.ID).FirstOrDefault(); if (adminGroupId <= 0) { return; } using (var dt = this.GetRepository <User>().EmailsAsDataTable(BoardContext.Current.PageBoardID, adminGroupId)) { dt.Rows.Cast <DataRow>().ForEach( row => { var emailAddress = row.Field <string>("Email"); if (emailAddress.IsNotSet()) { return; } var subject = this.Get <ILocalization>().GetTextFormatted( "COMMON", "NOTIFICATION_ON_BOT_USER_REGISTER_EMAIL_SUBJECT", this.BoardSettings.Name); var notifyAdmin = new TemplateEmail("NOTIFICATION_ON_BOT_USER_REGISTER") { TemplateParams = { ["{adminlink}"] = BuildLink.GetLinkNotEscaped( ForumPages.Admin_EditUser, true, "u={0}", userId), ["{user}"] = user.UserName, ["{email}"] = user.Email } }; notifyAdmin.SendEmail(new MailAddress(emailAddress), subject); }); } }
/// <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.Get <HttpRequestBase>().QueryString.Exists("t") || !this.PageContext.ForumReadAccess || !this.PageContext.BoardSettings.AllowEmailTopic) { BuildLink.AccessDenied(); } if (this.IsPostBack) { return; } if (this.PageContext.Settings.LockedForum == 0) { this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, BuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.PageContext.PageCategoryName, BuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID)); } this.PageLinks.AddForum(this.PageContext.PageForumID); this.PageLinks.AddLink( this.PageContext.PageTopicName, BuildLink.GetLink(ForumPages.posts, "t={0}", this.PageContext.PageTopicID)); this.Subject.Text = this.PageContext.PageTopicName; var emailTopic = new TemplateEmail { TemplateParams = { ["{link}"] = BuildLink.GetLinkNotEscaped( ForumPages.posts, true, "t={0}", this.PageContext.PageTopicID), ["{user}"] = this.PageContext.PageUserName } }; this.Message.Text = emailTopic.ProcessTemplate("EMAILTOPIC"); }
/// <summary> /// The send password reset. /// </summary> /// <param name="user"> /// The user. /// </param> /// <param name="code"> /// The code. /// </param> public void SendPasswordReset([NotNull] AspNetUsers user, [NotNull] string code) { // re-send verification email instead of lost password... var verifyEmail = new TemplateEmail("RESET_PASS"); var subject = this.Get <ILocalization>().GetTextFormatted( "RESET_PASS_EMAIL_SUBJECT", this.Get <BoardSettings>().Name); verifyEmail.TemplateParams["{link}"] = BuildLink.GetLinkNotEscaped( ForumPages.Account_ResetPassword, true, "code={0}", code); verifyEmail.TemplateParams["{forumname}"] = this.Get <BoardSettings>().Name; verifyEmail.TemplateParams["{forumlink}"] = $"{BoardInfo.ForumURL}"; verifyEmail.SendEmail(new MailAddress(user.Email, user.UserName), subject); }
/// <summary> /// Initializes a new instance of the <see cref="YafSyndicationFeed" /> class. /// </summary> /// <param name="subTitle">The sub title.</param> /// <param name="feedType">The feed source.</param> /// <param name="sf">The feed type Atom/RSS.</param> /// <param name="urlAlphaNum">The alphanumerically encoded base site Url.</param> public YafSyndicationFeed([NotNull] string subTitle, YafRssFeeds feedType, int sf, [NotNull] string urlAlphaNum) { this.Copyright = new TextSyndicationContent($"Copyright {DateTime.Now.Year} {YafContext.Current.BoardSettings.Name}"); this.Description = new TextSyndicationContent( $"{YafContext.Current.BoardSettings.Name} - {(sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get<ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get<ILocalization>().GetText("RSSFEED"))}"); this.Title = new TextSyndicationContent( $"{(sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get<ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get<ILocalization>().GetText("RSSFEED"))} - {YafContext.Current.BoardSettings.Name} - {subTitle}"); // Alternate link this.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(BaseUrlBuilder.BaseUrl))); // Self Link var slink = new Uri( BuildLink.GetLinkNotEscaped(ForumPages.rsstopic, true, $"pg={feedType.ToInt()}&ft={sf}")); this.Links.Add(SyndicationLink.CreateSelfLink(slink)); this.Generator = "YetAnotherForum.NET"; this.LastUpdatedTime = DateTime.UtcNow; this.Language = YafContext.Current.Get <ILocalization>().LanguageCode; this.ImageUrl = new Uri( $"{BaseUrlBuilder.BaseUrl}{BoardInfo.ForumClientFileRoot}{BoardFolders.Current.Logos}/{YafContext.Current.BoardSettings.ForumLogo}"); this.Id = $"urn:{urlAlphaNum}:{(sf == YafSyndicationFormats.Atom.ToInt() ? YafContext.Current.Get<ILocalization>().GetText("ATOMFEED") : YafContext.Current.Get<ILocalization>().GetText("RSSFEED"))}:{YafContext.Current.BoardSettings.Name}:{subTitle}:{YafContext.Current.PageBoardID}" .Unidecode(); this.Id = this.Id.Replace(" ", string.Empty); // this.Id = "urn:uuid:{0}".FormatWith(Guid.NewGuid().ToString("D")); this.BaseUri = slink; this.Authors.Add( new SyndicationPerson( YafContext.Current.BoardSettings.ForumEmail, "Forum Admin", BaseUrlBuilder.BaseUrl)); this.Categories.Add(new SyndicationCategory(FeedCategories)); }
/// <summary> /// The process request. /// </summary> /// <param name="context"> /// The context. /// </param> public void ProcessRequest([NotNull] HttpContext context) { var siteMap = new SiteMap(); var forumList = this.GetRepository <Forum>().ListAll( BoardContext.Current.BoardSettings.BoardID, this.Get <IAspNetUsersHelper>().GuestUserId); forumList.ForEach( forum => siteMap.Add( new UrlLocation { Url = BuildLink.GetLinkNotEscaped( ForumPages.Topics, true, "f={0}&name={1}", forum.Item1.ID, forum.Item1.Name), Priority = 0.8D, LastModified = forum.Item1.LastPosted.HasValue ? forum.Item1.LastPosted.Value.ToString( "yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture) : DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:sszzz", CultureInfo.InvariantCulture), ChangeFrequency = UrlLocation.ChangeFrequencies.always })); context.Response.Clear(); var xs = new XmlSerializer(typeof(SiteMap)); context.Response.ContentType = "text/xml"; xs.Serialize(context.Response.Output, siteMap); context.Response.End(); }
/// <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) { // check if this feature is disabled if (!this.Get <BoardSettings>().AllowPrivateMessages) { BuildLink.RedirectInfoPage(InfoMessage.Disabled); } if (this.IsPostBack) { return; } if (this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v").IsSet()) { this.View = PmViewConverter.FromQueryString(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("v")); this.hidLastTab.Value = $"View{(int)this.View}"; } this.NewPM.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.PostPrivateMessage); this.NewPM2.NavigateUrl = this.NewPM.NavigateUrl; }
/// <summary> /// Add a new syndication person. /// </summary> /// <param name="userEmail">The email.</param> /// <param name="userId">The user Id.</param> /// <param name="userName">The user name.</param> /// <param name="userDisplayName"> The user display name.</param> /// <returns>The SyndicationPerson.</returns> public static SyndicationPerson NewSyndicationPerson( string userEmail, int userId, string userName, string userDisplayName) { string userNameToShow; if (BoardContext.Current.BoardSettings.EnableDisplayName) { userNameToShow = userDisplayName.IsNotSet() ? BoardContext.Current.Get<IAspNetUsersHelper>().GetDisplayNameFromID(userId) : userDisplayName; } else { userNameToShow = userName.IsNotSet() ? BoardContext.Current.Get<IAspNetUsersHelper>().GetUserNameFromID(userId) : userName; } return new SyndicationPerson( userEmail, userNameToShow, BuildLink.GetLinkNotEscaped(ForumPages.UserProfile, true, "u={0}&name={1}", userId, userNameToShow)); }
/// <summary> /// Add a new syndication person. /// </summary> /// <param name="userEmail">The email.</param> /// <param name="userId">The user Id.</param> /// <param name="userName">The user name.</param> /// <param name="userDisplayName"> The user display name.</param> /// <returns>The SyndicationPerson.</returns> public static SyndicationPerson NewSyndicationPerson( string userEmail, long userId, string userName, string userDisplayName) { string userNameToShow; if (YafContext.Current.BoardSettings.EnableDisplayName) { userNameToShow = userDisplayName.IsNotSet() ? UserMembershipHelper.GetDisplayNameFromID(userId) : userDisplayName; } else { userNameToShow = userName.IsNotSet() ? UserMembershipHelper.GetUserNameFromID(userId) : userName; } return(new SyndicationPerson( userEmail, userNameToShow, BuildLink.GetLinkNotEscaped(ForumPages.profile, true, "u={0}&name={1}", userId, userNameToShow))); }
/// <summary> /// The moderators list_ on item data bound. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void ModeratorsList_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var modForums = e.Item.FindControlAs <DropDownList>("ModForums"); var modLink = e.Item.FindControlAs <UserLink>("ModLink"); var mod = this.completeModsList.Find(m => m.ModeratorID.Equals(modLink.UserID)); (from forumsItem in mod.ForumIDs let forumListItem = new ListItem { Value = forumsItem.ForumID.ToString(), Text = forumsItem.ForumName } where !modForums.Items.Contains(forumListItem) select forumsItem).ForEach( forumsItem => modForums.Items.Add( new ListItem { Value = forumsItem.ForumID.ToString(), Text = forumsItem.ForumName })); if (modForums.Items.Count > 0) { modForums.Items.Insert(0, new ListItem(this.GetTextFormatted("VIEW_FORUMS", modForums.Items.Count), "intro")); modForums.Items.Insert(1, new ListItem("--------------------------", "break")); } else { modForums.Visible = false; } // User Buttons var adminUserButton = e.Item.FindControlAs <ThemeButton>("AdminUserButton"); var pm = e.Item.FindControlAs <ThemeButton>("PM"); var email = e.Item.FindControlAs <ThemeButton>("Email"); adminUserButton.Visible = this.PageContext.IsAdmin; var itemDataItem = (Moderator)e.Item.DataItem; var userid = itemDataItem.ModeratorID.ToType <int>(); var displayName = this.Get <BoardSettings>().EnableDisplayName ? itemDataItem.DisplayName : itemDataItem.Name; var modAvatar = e.Item.FindControlAs <Image>("ModAvatar"); modAvatar.ImageUrl = this.GetAvatarUrlFileName(userid, itemDataItem.Avatar, itemDataItem.AvatarImage, itemDataItem.Email); modAvatar.AlternateText = displayName; modAvatar.ToolTip = displayName; if (userid == this.PageContext.PageUserID) { return; } var isFriend = this.GetRepository <Buddy>().CheckIsFriend(this.PageContext.PageUserID, userid); pm.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <BoardSettings>().AllowPrivateMessages; if (pm.Visible) { if (mod.Block.BlockPMs) { pm.Visible = false; } if (this.PageContext.IsAdmin || isFriend) { pm.Visible = true; } } pm.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.PostPrivateMessage, "u={0}", userid); pm.ParamTitle0 = displayName; // email link email.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <BoardSettings>().AllowEmailSending; if (!email.Visible) { return; } if (mod.Block.BlockEmails && !this.PageContext.IsAdmin) { email.Visible = false; } if (this.PageContext.IsAdmin || isFriend) { email.Visible = true; } email.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.Email, "u={0}", userid); email.ParamTitle0 = displayName; }
/// <summary> /// The admins list_ on item data bound. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void AdminsList_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var adminAvatar = e.Item.FindControlAs <Image>("AdminAvatar"); var itemDataItem = (DataRowView)e.Item.DataItem; var userid = itemDataItem["UserID"].ToType <int>(); var displayName = this.Get <BoardSettings>().EnableDisplayName ? itemDataItem.Row["DisplayName"].ToString() : itemDataItem.Row["Name"].ToString(); adminAvatar.ImageUrl = this.GetAvatarUrlFileName( itemDataItem.Row["UserID"].ToType <int>(), itemDataItem.Row["Avatar"].ToString(), itemDataItem.Row["AvatarImage"].ToString().IsSet(), itemDataItem.Row["Email"].ToString()); adminAvatar.AlternateText = displayName; adminAvatar.ToolTip = displayName; // User Buttons var adminUserButton = e.Item.FindControlAs <ThemeButton>("AdminUserButton"); var pm = e.Item.FindControlAs <ThemeButton>("PM"); var email = e.Item.FindControlAs <ThemeButton>("Email"); adminUserButton.Visible = this.PageContext.IsAdmin; if (userid == this.PageContext.PageUserID) { return; } var blockFlags = new UserBlockFlags(itemDataItem.Row["BlockFlags"].ToType <int>()); var isFriend = this.GetRepository <Buddy>().CheckIsFriend(this.PageContext.PageUserID, userid); pm.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <BoardSettings>().AllowPrivateMessages; if (pm.Visible) { if (blockFlags.BlockPMs) { pm.Visible = false; } if (this.PageContext.IsAdmin || isFriend) { pm.Visible = true; } } pm.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.PostPrivateMessage, "u={0}", userid); pm.ParamTitle0 = displayName; // email link email.Visible = !this.PageContext.IsGuest && this.User != null && this.Get <BoardSettings>().AllowEmailSending; if (email.Visible) { if (blockFlags.BlockEmails) { email.Visible = false; } if (this.PageContext.IsAdmin && isFriend) { email.Visible = true; } email.NavigateUrl = BuildLink.GetLinkNotEscaped(ForumPages.Email, "u={0}", userid); email.ParamTitle0 = displayName; } }
/// <summary> /// Handles the ItemCommand event of the UserList control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param> public void UserListItemCommand([NotNull] object source, [NotNull] RepeaterCommandEventArgs e) { switch (e.CommandName) { case "edit": BuildLink.Redirect(ForumPages.admin_edituser, "u={0}", e.CommandArgument); break; case "resendEmail": var commandArgument = e.CommandArgument.ToString().Split(';'); var checkMail = this.GetRepository <CheckEmail>().ListTyped(commandArgument[0]).FirstOrDefault(); if (checkMail != null) { var verifyEmail = new TemplateEmail("VERIFYEMAIL"); var subject = this.Get <ILocalization>() .GetTextFormatted("VERIFICATION_EMAIL_SUBJECT", this.Get <BoardSettings>().Name); verifyEmail.TemplateParams["{link}"] = BuildLink.GetLinkNotEscaped( ForumPages.Approve, true, "k={0}", checkMail.Hash); verifyEmail.TemplateParams["{key}"] = checkMail.Hash; verifyEmail.TemplateParams["{forumname}"] = this.Get <BoardSettings>().Name; verifyEmail.TemplateParams["{forumlink}"] = BoardInfo.ForumURL; verifyEmail.SendEmail(new MailAddress(checkMail.Email, commandArgument[1]), subject); this.PageContext.AddLoadMessage( this.GetText("ADMIN_ADMIN", "MSG_MESSAGE_SEND"), MessageTypes.success); } else { var userFound = this.Get <IUserDisplayName>().Find(commandArgument[1]).FirstOrDefault(); var user = this.Get <MembershipProvider>().GetUser(userFound.Name, false); this.Get <ISendNotification>().SendVerificationEmail(user, commandArgument[0], userFound.ID); } break; case "delete": if (!Config.IsAnyPortal) { UserMembershipHelper.DeleteUser(e.CommandArgument.ToType <int>()); } this.GetRepository <User>().Delete(e.CommandArgument.ToType <int>()); this.BindData(); break; case "approve": UserMembershipHelper.ApproveUser(e.CommandArgument.ToType <int>()); this.BindData(); break; case "deleteall": // vzrus: Should not delete the whole providers portal data? Under investigation. var daysValueAll = this.PageContext.CurrentForumPage.FindControlRecursiveAs <TextBox>("DaysOld").Text.Trim(); if (!ValidationHelper.IsValidInt(daysValueAll)) { this.PageContext.AddLoadMessage( this.GetText("ADMIN_ADMIN", "MSG_VALID_DAYS"), MessageTypes.warning); return; } if (!Config.IsAnyPortal) { UserMembershipHelper.DeleteAllUnapproved(System.DateTime.UtcNow.AddDays(-daysValueAll.ToType <int>())); } else { this.GetRepository <User>().DeleteOld(this.PageContext.PageBoardID, daysValueAll.ToType <int>()); } this.BindData(); break; case "approveall": UserMembershipHelper.ApproveAll(); // vzrus: Should delete users from send email list this.GetRepository <User>().ApproveAll(this.PageContext.PageBoardID); this.BindData(); break; } }
/// <summary> /// The method creates YAF SyndicationFeed for topics in a forum. /// </summary> /// <param name="feed"> /// The YAF SyndicationFeed. /// </param> /// <param name="feedType"> /// The FeedType. /// </param> /// <param name="atomFeedByVar"> /// The Atom feed checker. /// </param> /// <param name="lastPostIcon"> /// The icon for last post link. /// </param> /// <param name="lastPostName"> /// The last post name. /// </param> /// <param name="forumId"> /// The forum id. /// </param> private void GetTopicsFeed( [NotNull] ref YafSyndicationFeed feed, YafRssFeeds feedType, bool atomFeedByVar, [NotNull] string lastPostIcon, [NotNull] string lastPostName, int forumId) { var syndicationItems = new List <SyndicationItem>(); // vzrus changed to separate DLL specific code using (var dt = this.GetRepository <Topic>().RssListAsDataTable(forumId, this.Get <BoardSettings>().TopicsFeedItemsCount)) { var urlAlphaNum = FormatUrlForFeed(BaseUrlBuilder.BaseUrl); feed = new YafSyndicationFeed( $"{this.GetText("DEFAULT", "FORUM")}:{this.PageContext.PageForumName}", feedType, atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt(), urlAlphaNum); foreach (DataRow row in dt.Rows) { var lastPosted = Convert.ToDateTime(row["LastPosted"]) + this.Get <IDateTime>().TimeOffset; if (syndicationItems.Count <= 0) { feed.Authors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["LastUserID"].ToType <long>(), null, null)); feed.LastUpdatedTime = DateTime.UtcNow + this.Get <IDateTime>().TimeOffset; // Alternate Link // feed.Links.Add(new SyndicationLink(new Uri(BuildLink.GetLinkNotEscaped(ForumPages.Posts, true)))); } feed.Contributors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["LastUserID"].ToType <long>(), null, null)); syndicationItems.AddSyndicationItem( row["Topic"].ToString(), GetPostLatestContent( BuildLink.GetLinkNotEscaped( ForumPages.Posts, true, "m={0}#post{0}", row["LastMessageID"]), lastPostIcon, lastPostName, lastPostName, row["LastMessage"].ToString(), !row["LastMessageFlags"].IsNullOrEmptyDBField() ? row["LastMessageFlags"].ToType <int>() : 22, false), null, BuildLink.GetLinkNotEscaped(ForumPages.Posts, true, "t={0}", row["TopicID"]), $"urn:{urlAlphaNum}:ft{feedType}:st{(atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt())}:tid{row["TopicID"]}:lmid{row["LastMessageID"]}:{this.PageContext.PageBoardID}" .Unidecode(), lastPosted, feed); } feed.Items = syndicationItems; } }
/// <summary> /// The method creates YafSyndicationFeed for posts. /// </summary> /// <param name="feed"> /// The YafSyndicationFeed. /// </param> /// <param name="feedType"> /// The FeedType. /// </param> /// <param name="atomFeedByVar"> /// The Atom feed checker. /// </param> /// <param name="topicId"> /// The TopicID /// </param> private void GetPostsFeed( [NotNull] ref YafSyndicationFeed feed, YafRssFeeds feedType, bool atomFeedByVar, int topicId) { var syndicationItems = new List <SyndicationItem>(); var showDeleted = false; var userId = 0; if (this.Get <BoardSettings>().ShowDeletedMessagesToAll) { showDeleted = true; } if (!showDeleted && (this.Get <BoardSettings>().ShowDeletedMessages && !this.Get <BoardSettings>().ShowDeletedMessagesToAll || this.PageContext.IsAdmin || this.PageContext.IsForumModerator)) { userId = this.PageContext.PageUserID; } using ( var dt = this.GetRepository <Message>().PostListAsDataTable( topicId, this.PageContext.PageUserID, userId, 0, showDeleted, true, false, DateTimeHelper.SqlDbMinTime(), DateTime.UtcNow, DateTimeHelper.SqlDbMinTime(), DateTime.UtcNow, 0, this.Get <BoardSettings>().PostsPerPage, 2, 0, 0, false, -1)) { // convert to linq... var rowList = dt.AsEnumerable(); // last page posts var dataRows = rowList.Take(this.Get <BoardSettings>().PostsPerPage); var altItem = false; var urlAlphaNum = FormatUrlForFeed(BaseUrlBuilder.BaseUrl); feed = new YafSyndicationFeed( $"{this.GetText("PROFILE", "TOPIC")}{this.PageContext.PageTopicName} - {this.Get<BoardSettings>().PostsPerPage}", feedType, atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt(), urlAlphaNum); foreach (var row in dataRows) { var posted = Convert.ToDateTime(row["Edited"]) + this.Get <IDateTime>().TimeOffset; if (syndicationItems.Count <= 0) { feed.Authors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["UserID"].ToType <long>(), null, null)); feed.LastUpdatedTime = DateTime.UtcNow + this.Get <IDateTime>().TimeOffset; } List <SyndicationLink> attachementLinks = null; // if the user doesn't have download access we simply don't show enclosure links. if (this.PageContext.ForumDownloadAccess) { attachementLinks = this.GetMediaLinks(row["MessageID"].ToType <int>()); } feed.Contributors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["UserID"].ToType <long>(), null, null)); syndicationItems.AddSyndicationItem( row["Topic"].ToString(), this.Get <IFormatMessage>().FormatSyndicationMessage( row["Message"].ToString(), new MessageFlags(row["Flags"]), altItem, 4000), null, BuildLink.GetLinkNotEscaped(ForumPages.Posts, true, "m={0}&find=lastpost", row["MessageID"]), $"urn:{urlAlphaNum}:ft{feedType}:st{(atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt())}:meid{row["MessageID"]}:{this.PageContext.PageBoardID}" .Unidecode(), posted, feed, attachementLinks); // used to format feeds altItem = !altItem; } feed.Items = syndicationItems; } }
/// <summary> /// The method creates YafSyndicationFeed for topics in a forum. /// </summary> /// <param name="feed"> /// The YafSyndicationFeed. /// </param> /// <param name="feedType"> /// The FeedType. /// </param> /// <param name="atomFeedByVar"> /// The Atom feed checker. /// </param> /// <param name="lastPostIcon"> /// The icon for last post link. /// </param> /// <param name="lastPostName"> /// The last post name. /// </param> private void GetPostLatestFeed( [NotNull] ref YafSyndicationFeed feed, YafRssFeeds feedType, bool atomFeedByVar, [NotNull] string lastPostIcon, [NotNull] string lastPostName) { var syndicationItems = new List <SyndicationItem>(); using ( var dataTopics = this.GetRepository <Topic>().RssLatestAsDataTable( this.PageContext.PageBoardID, this.Get <BoardSettings>().ActiveDiscussionsCount <= 50 ? this.Get <BoardSettings>().ActiveDiscussionsCount : 50, this.PageContext.PageUserID, this.Get <BoardSettings>().UseStyledNicks, this.Get <BoardSettings>().NoCountForumsInActiveDiscussions)) { var urlAlphaNum = FormatUrlForFeed(BaseUrlBuilder.BaseUrl); feed = new YafSyndicationFeed( this.GetText("ACTIVE_DISCUSSIONS"), feedType, atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt(), urlAlphaNum); var altItem = false; foreach (DataRow row in dataTopics.Rows) { // don't render moved topics if (row["TopicMovedID"].IsNullOrEmptyDBField()) { var lastPosted = Convert.ToDateTime(row["LastPosted"]) + this.Get <IDateTime>().TimeOffset; if (syndicationItems.Count <= 0) { feed.LastUpdatedTime = lastPosted + this.Get <IDateTime>().TimeOffset; feed.Authors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["UserID"].ToType <long>(), row["UserName"].ToString(), row["UserDisplayName"].ToString())); } feed.Contributors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["LastUserID"].ToType <long>(), row["LastUserName"].ToString(), row["LastUserDisplayName"].ToString())); var messageLink = BuildLink.GetLinkNotEscaped( ForumPages.Posts, true, "m={0}#post{0}", row["LastMessageID"]); syndicationItems.AddSyndicationItem( row["Topic"].ToString(), GetPostLatestContent( messageLink, lastPostIcon, lastPostName, lastPostName, row["LastMessage"].ToString(), !row["LastMessageFlags"].IsNullOrEmptyDBField() ? row["LastMessageFlags"].ToType <int>() : 22, altItem), null, BuildLink.GetLinkNotEscaped( ForumPages.Posts, true, "t={0}", row["TopicID"].ToType <int>()), $"urn:{urlAlphaNum}:ft{feedType}:st{(atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt())}:tid{row["TopicID"]}:mid{row["LastMessageID"]}:{this.PageContext.PageBoardID}" .Unidecode(), lastPosted, feed); } altItem = !altItem; } feed.Items = syndicationItems; } }
/// <summary> /// The method creates YAF SyndicationFeed for forums in a category. /// </summary> /// <param name="feed"> /// The YAF Syndication Feed. /// </param> /// <param name="feedType"> /// The FeedType. /// </param> /// <param name="atomFeedByVar"> /// The Atom feed checker. /// </param> /// <param name="categoryId"> /// The category id. /// </param> private void GetForumFeed( [NotNull] ref YafSyndicationFeed feed, YafRssFeeds feedType, bool atomFeedByVar, [NotNull] int?categoryId) { var syndicationItems = new List <SyndicationItem>(); using (var dt = this.GetRepository <Forum>().ListReadAsDataTable(this.PageContext.PageBoardID, this.PageContext.PageUserID, categoryId, null, false, false)) { var urlAlphaNum = FormatUrlForFeed(BaseUrlBuilder.BaseUrl); feed = new YafSyndicationFeed( this.GetText("DEFAULT", "FORUM"), feedType, atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt(), urlAlphaNum); foreach (DataRow row in dt.Rows) { if (row["TopicMovedID"].IsNullOrEmptyDBField() && row["LastPosted"].IsNullOrEmptyDBField()) { continue; } var lastPosted = Convert.ToDateTime(row["LastPosted"]) + this.Get <IDateTime>().TimeOffset; if (syndicationItems.Count <= 0) { if (row["LastUserID"].IsNullOrEmptyDBField() || row["LastUserID"].IsNullOrEmptyDBField()) { break; } feed.Authors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["LastUserID"].ToType <long>(), null, null)); feed.LastUpdatedTime = DateTime.UtcNow + this.Get <IDateTime>().TimeOffset; // Alternate Link // feed.Links.Add(new SyndicationLink(new Uri(BuildLink.GetLinkNotEscaped(ForumPages.topics, true)))); } if (!row["LastUserID"].IsNullOrEmptyDBField()) { feed.Contributors.Add( SyndicationItemExtensions.NewSyndicationPerson( string.Empty, row["LastUserID"].ToType <long>(), null, null)); } syndicationItems.AddSyndicationItem( row["Forum"].ToString(), this.HtmlEncode(row["Description"].ToString()), null, BuildLink.GetLinkNotEscaped(ForumPages.topics, true, "f={0}", row["ForumID"]), $"urn:{urlAlphaNum}:ft{feedType}:st{(atomFeedByVar ? YafSyndicationFormats.Atom.ToInt() : YafSyndicationFormats.Rss.ToInt())}:fid{row["ForumID"]}:lmid{row["LastMessageID"]}:{this.PageContext.PageBoardID}" .Unidecode(), lastPosted, feed); } feed.Items = syndicationItems; } }