public string BlogFaveComment(int userID, string postGuid) { SueetieBlogComment sueetieBlogComment = SueetieBlogs.GetSueetieBlogComment(postGuid); if (userID > 0) { if (sueetieBlogComment.SueetieCommentID > 0) { string result = "You tagged this comment by " + sueetieBlogComment.Author + " as a favorite!"; UserContent userContent = new UserContent { ContentID = sueetieBlogComment.ContentID, UserID = userID }; int favoriteID = SueetieUsers.CreateFavorite(userContent); if (favoriteID < 0) { result = "You already tagged this comment as a favorite."; } return(result); } else { return("Sorry, we added favorites after this comment was written. Please consider tagging more recent comments as favorites."); } } else { return("Please login or become a member to tag this comment as a favorite"); } }
protected void Page_Load(object sender, EventArgs e) { string path = this.ViewName.ControlPath(); ContentQuery contentQuery = new ContentQuery { NumRecords = this.NumRecords, UserID = this.UserID, ContentTypeID = (int)SueetieContentType.BlogComment, GroupID = this.GroupID, ApplicationID = this.ApplicationID, IsRestricted = this.IsRestricted, TruncateText = false, CacheMinutes = this.CacheMinutes }; List <SueetieBlogComment> sueetieBlogComments = SueetieBlogs.GetSueetieBlogCommentList(contentQuery); foreach (SueetieBlogComment comment in sueetieBlogComments) { Sueetie.Controls.BlogCommentView control = (Sueetie.Controls.BlogCommentView)LoadControl(path); control.Comment = comment; phBlogComments.Controls.Add(control); } }
protected void Page_Load(object sender, EventArgs e) { string path = this.ViewName.ControlPath(); ApplicationQuery applicationQuery = new ApplicationQuery { NumRecords = this.NumRecords, CategoryID = this.CategoryID, GroupID = this.GroupID, IsRestricted = this.IsRestricted, TruncateText = false, CacheMinutes = this.CacheMinutes, SueetieApplicationViewTypeID = (int)SueetieApplicationViewType.Blogs, SortBy = (int)this.BlogSortType }; List <SueetieBlog> sueetieBlogs = SueetieBlogs.GetSueetieBlogList(applicationQuery); foreach (SueetieBlog blog in sueetieBlogs) { Sueetie.Controls.BlogView control = (Sueetie.Controls.BlogView)LoadControl(path); control.Blog = blog; phAggregatedBlogs.Controls.Add(control); } }
public string BlogFavePost(int userID, string postGuid) { SueetieBlogPost sueetieBlogPost = SueetieBlogs.GetSueetieBlogPost(postGuid); if (userID > 0) { if (sueetieBlogPost.SueetiePostID > 0) { string result = "You have tagged " + sueetieBlogPost.Title + " as a favorite!"; UserContent userContent = new UserContent { ContentID = sueetieBlogPost.ContentID, UserID = userID }; int favoriteID = SueetieUsers.CreateFavorite(userContent); if (favoriteID < 0) { result = "You already tagged this post as a favorite."; } return(result); } else { return("Sorry, we added favorites after this post was published. Please consider tagging more recent posts as favorites."); } } else { return("Please login or become a member to tag this post as a favorite"); } }
protected void Page_Load(object sender, EventArgs e) { // Sueetie Modified - Add Calendar Control if (this.Post != null && this.Post.Id != null) { SueetieBlogPost sueetieBlogPost = SueetieBlogs.GetSueetieBlogPost(Post.Id.ToString()); calendarControl = new CalendarControl(); calendarControl.CalendarSueetieBlogPost = sueetieBlogPost; phCalendarControl.Controls.Add(calendarControl); } }
public string BlogCommenterFollow(int userID, string postGuid) { SueetieBlogComment sueetieBlogComment = SueetieBlogs.GetSueetieBlogComment(postGuid); if (userID > 0) { if (sueetieBlogComment.SueetieCommentID > 0) { string result = "You are now following " + sueetieBlogComment.DisplayName; SueetieFollow sueetieFollow = new SueetieFollow { FollowerUserID = userID, FollowingUserID = sueetieBlogComment.UserID, ContentIDFollowed = sueetieBlogComment.SueetieCommentID }; if (sueetieBlogComment.UserID > 0) { if (sueetieFollow.FollowerUserID == sueetieFollow.FollowingUserID) { result = "Sorry, you cannot follow yourself..."; } else { int followID = SueetieUsers.FollowUser(sueetieFollow); if (followID < 0) { result = "You are already following " + sueetieBlogComment.DisplayName; } else { SueetieLogs.LogUserEntry(UserLogCategoryType.Following, sueetieBlogComment.UserID, userID); } } } else { result = "Sorry, " + sueetieBlogComment.Author + " is not a member and thus cannot be followed."; } return(result); } else { return("Sorry, we added following after this comment was posted. Please use a more current comment to follow this member."); } } else { return("Please login or become a member to follow this person."); } }
protected void btnAddUpdate_OnCommand(object sender, CommandEventArgs e) { SueetieBlog sueetieBlog = new SueetieBlog { BlogID = int.Parse(ddlBlogs.SelectedValue), BlogTitle = txtBlogTitle.Text, BlogDescription = txtBlogDescription.Text, IsActive = chkIsActive.Checked, IncludeInAggregateList = chkIncludeInAggregateList.Checked, RegisteredComments = chkRegisteredComments.Checked, BlogAccessRole = !string.IsNullOrEmpty(txtBlogAccessRole.Text) ? txtBlogAccessRole.Text : null, BlogOwnerRole = ddlBlogOwnerRole.SelectedItem.Text }; SueetieBlogs.UpdateSueetieBlog(sueetieBlog); lblResults.Text = "Blog Updated!"; ClearForm(); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> /// <remarks> /// Lets process our .Body content and build up our controls collection /// inside the 'BodyContent' placeholder. /// User controls are insterted into the blog in the following format.. /// [UserControl:~/path/usercontrol.ascx] /// TODO : Expose user control parameters. /// </remarks> protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Sueetie Modified - Create Current Sueetie Blog Post this.CurrentSueetieBlogPost = SueetieBlogs.GetSueetieBlogPost(this.Post.Id.ToString()); this.CurrentSueetieBlog = SueetieBlogs.GetSueetieBlog(SueetieApplications.Current.ApplicationKey); var bodyContent = (PlaceHolder)this.FindControl("BodyContent"); if (bodyContent == null) { // We have no placeholder so we assume this is an old style <% =Body %> theme and do nothing. } else { Utils.InjectUserControls(bodyContent, this.Body); } }
public List <SueetieBlogComment> GetRecentComments(int numRecords, int userID, int applicationID, bool isRestricted) { ContentQuery contentQuery = new ContentQuery { NumRecords = numRecords, UserID = userID, ContentTypeID = (int)SueetieContentType.BlogComment, GroupID = -1, ApplicationID = applicationID, IsRestricted = isRestricted, TruncateText = true }; List <SueetieBlogComment> _sueetieBlogComments = SueetieBlogs.GetSueetieBlogCommentList(contentQuery); foreach (SueetieBlogComment msg in _sueetieBlogComments) { msg.Comment = DataHelper.TruncateText(msg.Comment, SueetieConfiguration.Get().Core.TruncateTextCount); } return(_sueetieBlogComments); }
protected void ddlBlogs_OnSelectedIndexChanged(object sender, EventArgs e) { SueetieBlog _sueetieBlog = SueetieBlogs.GetSueetieBlog(int.Parse(ddlBlogs.SelectedValue)); if (_sueetieBlog.BlogID > 0) { PopulateBlogOwnerRoleList(_sueetieBlog.BlogOwnerRole); txtBlogTitle.Text = _sueetieBlog.BlogTitle; txtBlogDescription.Text = _sueetieBlog.BlogDescription; txtBlogAccessRole.Text = _sueetieBlog.BlogAccessRole; chkIsActive.Checked = _sueetieBlog.IsActive; chkIncludeInAggregateList.Checked = _sueetieBlog.IncludeInAggregateList; chkRegisteredComments.Checked = _sueetieBlog.RegisteredComments; SetButtonState(false); } else { SetButtonState(true); ClearForm(); } lblResults.Text = string.Empty; }
public string CreateBlogAdmin(string _userIDs) { string[] userIDs = _userIDs.Split(','); string newadmins = string.Empty; foreach (string userID in userIDs) { if (!string.IsNullOrEmpty(userID)) { SueetieUser sueetieUser = SueetieUsers.GetUser(Convert.ToInt32(userID)); SueetieBlogs.CreateBlogAdmin(sueetieUser); SueetieBlogUtils.CreateProfile(sueetieUser, "blog"); if (!sueetieUser.IsBlogAdministrator) { Roles.AddUserToRole(sueetieUser.UserName, "BlogAdministrator"); } newadmins += sueetieUser.DisplayName + ","; } } return("The following are now site blog administrators: " + DataHelper.CommaTrim(newadmins)); }
private void ClearForm() { List <SueetieBlog> sueetieBlogs = SueetieBlogs.GetSueetieBlogTitles(); txtBlogTitle.Text = string.Empty; txtBlogDescription.Text = string.Empty; txtBlogAccessRole.Text = string.Empty; chkIsActive.Checked = true; chkIncludeInAggregateList.Checked = true; chkRegisteredComments.Checked = false; PopulateBlogOwnerRoleList(null); ddlBlogs.Items.Clear(); foreach (SueetieBlog sueetieBlog in sueetieBlogs) { if (sueetieBlog.BlogID > 0) { ddlBlogs.Items.Add(new ListItem(sueetieBlog.BlogTitle, sueetieBlog.BlogID.ToString())); } } ddlBlogs.Items.Insert(0, new ListItem(string.Empty, "-1")); ddlBlogs.Items.FindByValue("-1").Selected = true; SetButtonState(true); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e"> /// The <see cref="T:System.EventArgs"/> object that contains the event data. /// </param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.Post == null) { this.Response.Redirect(Utils.RelativeWebRoot); return; } this.NameInputId = string.Format("txtName{0}", DateTime.Now.Ticks); this.EnableCaptchas(); if (!this.Page.IsPostBack && !this.Page.IsCallback) { if (Security.IsAuthorizedTo(Rights.ModerateComments)) { if (this.Request.QueryString["deletecomment"] != null) { this.DeleteComment(); } else if (this.Request.QueryString["deletecommentandchildren"] != null) { this.DeleteCommentAndChildren(); } else if (!string.IsNullOrEmpty(this.Request.QueryString["approvecomment"])) { this.ApproveComment(); } else if (!string.IsNullOrEmpty(this.Request.QueryString["approveallcomments"])) { this.ApproveAllComments(); } } var path = string.Format( "{0}themes/{1}/CommentView.ascx", Utils.RelativeWebRoot, BlogSettings.Instance.Theme); bool canViewUnpublishedPosts = Security.IsAuthorizedTo(AuthorizationCheck.HasAny, new[] { Rights.ViewUnmoderatedComments, Rights.ModerateComments }); if (this.NestingSupported) { // newer, nested comments if (this.Post != null) { this.AddNestedComments(path, this.Post.NestedComments, this.phComments, canViewUnpublishedPosts); } } else { // old, non nested code // Add approved Comments foreach (var comment in this.Post.Comments.Where( comment => comment.Email != "pingback" && comment.Email != "trackback")) { if (comment.IsApproved) { this.CommentCounter++; } if (!comment.IsApproved && BlogSettings.Instance.EnableCommentsModeration) { continue; } var control = (CommentViewBase)this.LoadControl(path); control.Comment = comment; control.Post = this.Post; this.phComments.Controls.Add(control); } // Add unapproved comments if (canViewUnpublishedPosts) { foreach (var comment in this.Post.Comments) { if (comment.Email == "pingback" || comment.Email == "trackback") { continue; } if (comment.IsApproved) { continue; } var control = (CommentViewBase)this.LoadControl(path); control.Comment = comment; control.Post = this.Post; this.phComments.Controls.Add(control); } } } var pingbacks = new List <CommentViewBase>(); foreach (var comment in this.Post.Comments) { var control = (CommentViewBase)this.LoadControl(path); if (comment.Email != "pingback" && comment.Email != "trackback") { continue; } control.Comment = comment; control.Post = this.Post; pingbacks.Add(control); } if (pingbacks.Count > 0) { var litTrackback = new Literal(); var sb = new StringBuilder(); sb.AppendFormat("<h3 id=\"trackbackheader\">Pingbacks and trackbacks ({0})", pingbacks.Count); sb.Append( "<a id=\"trackbacktoggle\" style=\"float:right;width:20px;height:20px;border:1px solid #ccc;text-decoration:none;text-align:center\""); sb.Append(" href=\"javascript:toggle_visibility('trackbacks','trackbacktoggle');\">+</a>"); sb.Append("</h3><div id=\"trackbacks\" style=\"display:none\">"); litTrackback.Text = sb.ToString(); this.phTrckbacks.Controls.Add(litTrackback); foreach (var c in pingbacks) { this.phTrckbacks.Controls.Add(c); } var closingDiv = new Literal { Text = @"</div>" }; this.phTrckbacks.Controls.Add(closingDiv); } else { this.phTrckbacks.Visible = false; } // Sueetie Modified - Add Require Login to Comment Function phPleaseLogin.Visible = false; if (BlogSettings.Instance.IsCommentsEnabled && Security.IsAuthorizedTo(Rights.CreateComments)) { if (this.Post != null && (!this.Post.HasCommentsEnabled || (BlogSettings.Instance.DaysCommentsAreEnabled > 0 && this.Post.DateCreated.AddDays(BlogSettings.Instance.DaysCommentsAreEnabled) < DateTime.Now.Date))) { this.phAddComment.Visible = false; this.lbCommentsDisabled.Visible = true; } SueetieBlog sueetieBlog = SueetieBlogs.GetSueetieBlog(SueetieApplications.Current.ApplicationKey); if (sueetieBlog.RegisteredComments && !SueetieContext.Current.User.IsRegistered) { phPleaseLogin.Visible = true; phAddComment.Visible = false; } else { this.BindCountries(); this.GetCookie(); this.recaptcha.UserUniqueIdentifier = this.hfCaptcha.Value = Guid.NewGuid().ToString(); } } else { this.phAddComment.Visible = false; } } this.Page.ClientScript.GetCallbackEventReference(this, "arg", null, string.Empty); }
protected void Page_Load(object sender, EventArgs e) { ContentQuery contentQuery = new ContentQuery { ContentTypeID = (int)SueetieContentType.BlogPost, CacheMinutes = 5, SueetieContentViewTypeID = (int)SueetieContentViewType.AggregateBlogPostList }; List <SueetieBlogPost> sueetieBlogPosts = SueetieBlogs.GetSueetieBlogPostList(contentQuery); var dataItems = from post in sueetieBlogPosts orderby post.DateCreated descending select post; const int maxItemsInFeed = 10; // Determine whether we're outputting an Atom or RSS feed bool outputAtom = (Request.QueryString["Type"] == "ATOM"); bool outputRss = !outputAtom; if (outputRss) { Response.ContentType = "application/rss+xml"; } else if (outputAtom) { Response.ContentType = "application/atom+xml"; } // Create the feed and specify the feed's attributes SyndicationFeed myFeed = new SyndicationFeed(); myFeed.Title = TextSyndicationContent.CreatePlaintextContent("Most Recent Posts on " + SiteSettings.Instance.SiteName); myFeed.Description = TextSyndicationContent.CreatePlaintextContent("A syndication of the most recently published posts on " + SiteSettings.Instance.SiteName); myFeed.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl("~/Default.aspx")))); myFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(GetFullyQualifiedUrl(Request.RawUrl)))); myFeed.Copyright = TextSyndicationContent.CreatePlaintextContent("Copyright " + SiteSettings.Instance.SiteName); myFeed.Language = "en-us"; List <SyndicationItem> feedItems = new List <SyndicationItem>(); foreach (SueetieBlogPost p in dataItems.Take(maxItemsInFeed)) { if (outputAtom && p.Author == null) { continue; } SyndicationItem item = new SyndicationItem(); item.Title = TextSyndicationContent.CreatePlaintextContent(p.BlogTitle + " - " + p.Title); item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(GetFullyQualifiedUrl(p.Permalink)))); item.Summary = TextSyndicationContent.CreateHtmlContent(p.PostContent); item.Categories.Add(new SyndicationCategory(p.BlogTitle)); item.PublishDate = p.DateCreated; item.Id = GetFullyQualifiedUrl(p.Permalink); SyndicationPerson authInfo = new SyndicationPerson(); authInfo.Email = p.Email; authInfo.Name = p.DisplayName; item.Authors.Add(authInfo); feedItems.Add(item); } myFeed.Items = feedItems; XmlWriterSettings outputSettings = new XmlWriterSettings(); outputSettings.Indent = true; XmlWriter feedWriter = XmlWriter.Create(Response.OutputStream, outputSettings); if (outputAtom) { Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(myFeed); atomFormatter.WriteTo(feedWriter); } else if (outputRss) { Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(myFeed); rssFormatter.WriteTo(feedWriter); } feedWriter.Close(); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!Security.IsAuthorizedTo(Rights.ViewPublicPosts)) { Response.Redirect("~/"); } bool shouldThrow404 = false; CommentView1.Visible = ShowCommentsForm; disqus_box.Visible = ShowDisqusForm; var requestId = Request.QueryString["id"]; Guid id; if ((!Utils.StringIsNullOrWhitespace(requestId)) && requestId.TryParse(out id)) { Post post = Post.GetPost(id); if (post != null) { if (!Page.IsPostBack && !Page.IsCallback && Request.RawUrl.Contains("?id=")) { // If there's more than one post that has the same RelativeLink // this post has then don't do a 301 redirect. if (Post.Posts.FindAll(delegate(Post p) { return(p.RelativeLink.Equals(post.RelativeLink)); } ).Count < 2) { Response.Clear(); Response.StatusCode = 301; Response.AppendHeader("location", post.RelativeLink.ToString()); Response.End(); } } else if (!post.IsVisible) { shouldThrow404 = true; } else { this.Post = post; var settings = BlogSettings.Instance; string encodedPostTitle = Server.HtmlEncode(Post.Title); string path = Utils.RelativeWebRoot + "themes/" + settings.Theme + "/PostView.ascx"; PostViewBase postView = (PostViewBase)LoadControl(path); postView.Post = Post; postView.ID = Post.Id.ToString().Replace("-", string.Empty); postView.Location = ServingLocation.SinglePost; pwPost.Controls.Add(postView); if (settings.EnableRelatedPosts) { related.Visible = true; related.Item = this.Post; } CommentView1.Post = Post; Page.Title = encodedPostTitle; AddMetaKeywords(); AddMetaDescription(); base.AddMetaTag("author", Server.HtmlEncode(Post.AuthorProfile == null ? Post.Author : Post.AuthorProfile.FullName)); List <Post> visiblePosts = Post.Posts.FindAll(delegate(Post p) { return(p.IsVisible); }); if (visiblePosts.Count > 0) { AddGenericLink("last", visiblePosts[0].Title, visiblePosts[0].RelativeLink); AddGenericLink("first", visiblePosts[visiblePosts.Count - 1].Title, visiblePosts[visiblePosts.Count - 1].RelativeLink); } InitNavigationLinks(); phRDF.Visible = settings.EnableTrackBackReceive; base.AddGenericLink("application/rss+xml", "alternate", encodedPostTitle + " (RSS)", postView.CommentFeed + "?format=ATOM"); base.AddGenericLink("application/rss+xml", "alternate", encodedPostTitle + " (ATOM)", postView.CommentFeed + "?format=ATOM"); if (BlogSettings.Instance.EnablePingBackReceive) { Response.AppendHeader("x-pingback", "http://" + Request.Url.Authority + Utils.RelativeWebRoot + "pingback.axd"); } string commentNotificationUnsubscribeEmailAddress = Request.QueryString["unsubscribe-email"]; if (!string.IsNullOrEmpty(commentNotificationUnsubscribeEmailAddress)) { if (Post.NotificationEmails.Contains(commentNotificationUnsubscribeEmailAddress)) { Post.NotificationEmails.Remove(commentNotificationUnsubscribeEmailAddress); Post.Save(); phCommentNotificationUnsubscription.Visible = true; } } // Sueetie Modified - Set CurrentContentID if (SueetieBlogs.GetSueetieBlogPost(post.Id.ToString()) != null) { base.CurrentContentID = SueetieBlogs.GetSueetieBlogPost(post.Id.ToString()).ContentID; } else { base.CurrentContentID = -1; } } } } else { shouldThrow404 = true; } if (shouldThrow404) { Response.Redirect(Utils.RelativeWebRoot + "error404.aspx", true); } }