private static void ProcessFeaturedPosts(Post p, IGraffitiUser user, bool isFeaturedPost, bool isFeaturedCategory) { SiteSettings settings = SiteSettings.Get(); if (p.IsPublished && isFeaturedPost) { settings.FeaturedId = p.Id; settings.Save(); } else if (settings.FeaturedId == p.Id) { settings.FeaturedId = -1; settings.Save(); } Category c = p.Category; if (p.IsPublished && isFeaturedCategory) { c.FeaturedId = p.Id; c.Save(user.Name); } else if (c.FeaturedId == p.Id) { c.FeaturedId = -1; c.Save(user.Name); } }
public static void DestroyDeletedPost(int postid) { Post p = new Post(postid); // Check if post is featured in it's category before deletion Core.Category c = p.Category; if (p.Id == c.FeaturedId) { c.FeaturedId = 0; c.Save(); } // Check site featured post SiteSettings settings = SiteSettings.Get(); if (p.Id == settings.FeaturedId) { settings.FeaturedId = 0; settings.Save(); } PostStatistic.Destroy(PostStatistic.Columns.PostId, postid); Tag.Destroy(Tag.Columns.PostId, postid); Comment.Destroy(Comment.Columns.PostId, postid); DataService.ExecuteNonQuery(new QueryCommand("delete from graffiti_VersionStore where Type = 'post/xml' and ItemId = " + postid)); Post.Destroy(postid); DeletePostDirectory(p); }