public PingBack(Core core, Blog blog, BlogEntry blogPost, long pingBackId) : base(core) { ItemLoad += new ItemLoadHandler(PingBack_ItemLoad); this.blog = blog; this.blogPost = blogPost; try { LoadItem(pingBackId); } catch (InvalidItemException) { throw new InvalidTrackBackException(); } }
public static void NotifyBlogComment(Core core, Job job) { Comment comment = new Comment(core, job.ItemId); BlogEntry ev = new BlogEntry(core, comment.CommentedItemKey.Id); if (ev.Owner is User && (!comment.OwnerKey.Equals(ev.OwnerKey))) { core.CallingApplication.SendNotification(core, comment.User, (User)ev.Owner, ev.OwnerKey, ev.ItemKey, "_COMMENTED_BLOG_POST", comment.BuildUri(ev)); } core.CallingApplication.SendNotification(core, comment.OwnerKey, comment.User, ev.OwnerKey, ev.ItemKey, "_COMMENTED_BLOG_POST", comment.BuildUri(ev)); }
/// <summary> /// Delete procedure for a blog entry. /// </summary> /// <param name="sender">Object calling load event</param> /// <param name="e">Load EventArgs</param> void AccountBlogWrite_Delete(object sender, EventArgs e) { AuthoriseRequestSid(); long postId = core.Functions.RequestLong("id", 0); db.BeginTransaction(); /*db.UpdateQuery(string.Format("DELETE FROM blog_postings WHERE post_id = {0} AND user_id = {1}", postId, LoggedInMember.UserId));*/ try { BlogEntry post = new BlogEntry(core, postId); if (post.Delete() > 0) { db.UpdateQuery(string.Format("UPDATE user_blog SET blog_entries = blog_entries - 1 WHERE user_id = {0}", LoggedInMember.UserId)); } } catch (InvalidBlogEntryException) { DisplayError("Blog entry does not exist."); return; } SetRedirectUri(BuildUri("manage")); core.Display.ShowMessage("Blog Post Deleted", "The blog post has been deleted from the database."); return; }
/// <summary> /// Default show procedure for account sub module. /// </summary> /// <param name="sender">Object calling load event</param> /// <param name="e">Load EventArgs</param> void AccountBlogWrite_Show(object sender, EventArgs e) { SetTemplate("account_post"); VariableCollection javaScriptVariableCollection = core.Template.CreateChild("javascript_list"); javaScriptVariableCollection.Parse("URI", @"/scripts/jquery.sceditor.bbcode.min.js"); VariableCollection styleSheetVariableCollection = core.Template.CreateChild("style_sheet_list"); styleSheetVariableCollection.Parse("URI", @"/styles/jquery.sceditor.theme.default.min.css"); core.Template.Parse("OWNER_STUB", Owner.UriStubAbsolute); Blog blog = new Blog(core, (User)Owner); /* Title TextBox */ TextBox titleTextBox = new TextBox("title"); titleTextBox.MaxLength = 127; /* Post TextBox */ TextBox postTextBox = new TextBox("post"); postTextBox.IsFormatted = true; postTextBox.Lines = 15; /* Tags TextBox */ TagSelectBox tagsTextBox = new TagSelectBox(core, "tags"); //tagsTextBox.MaxLength = 127; CheckBox publishToFeedCheckBox = new CheckBox("publish-feed"); publishToFeedCheckBox.IsChecked = true; long postId = core.Functions.RequestLong("id", 0); byte licenseId = (byte)0; short categoryId = (short)1; DateTime postTime = core.Tz.Now; SelectBox postYearsSelectBox = new SelectBox("post-year"); for (int i = core.Tz.Now.AddYears(-7).Year; i <= core.Tz.Now.Year; i++) { postYearsSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } postYearsSelectBox.SelectedKey = postTime.Year.ToString(); SelectBox postMonthsSelectBox = new SelectBox("post-month"); for (int i = 1; i < 13; i++) { postMonthsSelectBox.Add(new SelectBoxItem(i.ToString(), core.Functions.IntToMonth(i))); } postMonthsSelectBox.SelectedKey = postTime.Month.ToString(); SelectBox postDaysSelectBox = new SelectBox("post-day"); for (int i = 1; i < 32; i++) { postDaysSelectBox.Add(new SelectBoxItem(i.ToString(), i.ToString())); } postDaysSelectBox.SelectedKey = postTime.Day.ToString(); if (postId > 0 && core.Http.Query["mode"] == "edit") { try { BlogEntry be = new BlogEntry(core, postId); titleTextBox.Value = be.Title; postTextBox.Value = be.Body; licenseId = be.License; categoryId = be.Category; postTime = be.GetPublishedDate(tz); List<Tag> tags = Tag.GetTags(core, be); //string tagList = string.Empty; foreach (Tag tag in tags) { /*if (tagList != string.Empty) { tagList += ", "; } tagList += tag.TagText;*/ tagsTextBox.AddTag(tag); } //tagsTextBox.Value = tagList; if (be.OwnerId != core.LoggedInMemberId) { DisplayError("You must be the owner of the blog entry to modify it."); return; } } catch (InvalidBlogEntryException) { DisplayError(core.Prose.GetString("Blog", "BLOG_ENTRY_DOES_NOT_EXIST")); return; } } else { template.Parse("IS_NEW", "TRUE"); PermissionGroupSelectBox permissionSelectBox = new PermissionGroupSelectBox(core, "permissions", blog.ItemKey); HiddenField aclModeField = new HiddenField("aclmode"); aclModeField.Value = "simple"; template.Parse("S_PERMISSIONS", permissionSelectBox); template.Parse("S_ACLMODE", aclModeField); } template.Parse("S_POST_YEAR", postYearsSelectBox); template.Parse("S_POST_MONTH", postMonthsSelectBox); template.Parse("S_POST_DAY", postDaysSelectBox); template.Parse("S_POST_HOUR", postTime.Hour.ToString()); template.Parse("S_POST_MINUTE", postTime.Minute.ToString()); SelectBox licensesSelectBox = new SelectBox("license"); DataTable licensesTable = db.Query(ContentLicense.GetSelectQueryStub(core, typeof(ContentLicense))); licensesSelectBox.Add(new SelectBoxItem("0", "Default License")); foreach (DataRow licenseRow in licensesTable.Rows) { ContentLicense li = new ContentLicense(core, licenseRow); licensesSelectBox.Add(new SelectBoxItem(li.Id.ToString(), li.Title)); } licensesSelectBox.SelectedKey = licenseId.ToString(); SelectBox categoriesSelectBox = new SelectBox("category"); SelectQuery query = Category.GetSelectQueryStub(core, typeof(Category)); query.AddSort(SortOrder.Ascending, "category_title"); DataTable categoriesTable = db.Query(query); foreach (DataRow categoryRow in categoriesTable.Rows) { Category cat = new Category(core, categoryRow); categoriesSelectBox.Add(new SelectBoxItem(cat.Id.ToString(), cat.Title)); } categoriesSelectBox.SelectedKey = categoryId.ToString(); /* Parse the form fields */ template.Parse("S_TITLE", titleTextBox); template.Parse("S_BLOG_TEXT", postTextBox); template.Parse("S_TAGS", tagsTextBox); template.Parse("S_BLOG_LICENSE", licensesSelectBox); template.Parse("S_BLOG_CATEGORY", categoriesSelectBox); template.Parse("S_PUBLISH_FEED", publishToFeedCheckBox); template.Parse("S_ID", postId.ToString()); foreach (Emoticon emoticon in core.Emoticons) { if (emoticon.Category == "modifier") continue; if (emoticon.Category == "people" && emoticon.Code.Length < 3) { VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_list"); emoticonVariableCollection.Parse("CODE", emoticon.Code); emoticonVariableCollection.Parse("URI", emoticon.File); } else { VariableCollection emoticonVariableCollection = template.CreateChild("emoticon_hidden_list"); emoticonVariableCollection.Parse("CODE", emoticon.Code); emoticonVariableCollection.Parse("URI", emoticon.File); } } Save(new EventHandler(AccountBlogWrite_Save)); if (core.Http.Form["publish"] != null) { AccountBlogWrite_Save(this, new EventArgs()); } }
/// <summary> /// Save procedure for a blog entry. /// </summary> /// <param name="sender">Object calling load event</param> /// <param name="e">Load EventArgs</param> void AccountBlogWrite_Save(object sender, EventArgs e) { string title = core.Http.Form["title"]; //string tags = core.Http.Form["tags"]; string postBody = core.Http.Form["post"]; bool publishToFeed = (core.Http.Form["publish-feed"] != null); byte license = 0; short category = 1; long postId = 0; PublishStatuses publishStatus = PublishStatuses.Published; string postGuid = ""; long currentTimestamp = UnixTime.UnixTimeStamp(); /* * Create a blog if they do not already have one */ Blog myBlog = null; try { myBlog = new Blog(core, LoggedInMember); } catch (InvalidBlogException) { myBlog = Blog.Create(core); } bool postEditTimestamp = false; int postYear, postMonth, postDay, postHour, postMinute; DateTime postTime = core.Tz.DateTimeFromMysql(currentTimestamp); if (core.Http.Form["publish"] != null) { publishStatus = PublishStatuses.Published; } if (core.Http.Form["save"] != null) { publishStatus = PublishStatuses.Draft; } postId = core.Functions.FormLong("id", 0); license = core.Functions.FormByte("license", license); category = core.Functions.FormShort("category", category); try { postYear = core.Functions.FormInt("post-year", 0); postMonth = core.Functions.FormInt("post-month", 0); postDay = core.Functions.FormInt("post-day", 0); postHour = core.Functions.FormInt("post-hour", 0); postMinute = core.Functions.FormInt("post-minute", 0); postEditTimestamp = !string.IsNullOrEmpty(core.Http.Form["edit-timestamp"]); postTime = new DateTime(postYear, postMonth, postDay, postHour, postMinute, 0); } catch { } if (string.IsNullOrEmpty(title)) { SetError("You must give the blog post a title."); return; } if (string.IsNullOrEmpty(postBody)) { SetError("You cannot save an empty blog post. You must post some content."); return; } string sqlPostTime = ""; // update, must happen before save new because it populates postId if (postId > 0) { db.BeginTransaction(); BlogEntry myBlogEntry = new BlogEntry(core, postId); long postTimeRaw; bool doPublish = false; if (postEditTimestamp) { postTimeRaw = tz.GetUnixTimeStamp(postTime); if (postTimeRaw > UnixTime.UnixTimeStamp()) { publishStatus = PublishStatuses.Queued; } } if (publishStatus != myBlogEntry.Status) { switch (publishStatus) { case PublishStatuses.Published: UpdateQuery uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Addition, 1)); switch (myBlogEntry.Status) { case PublishStatuses.Draft: uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Subtraction, 1)); break; case PublishStatuses.Queued: uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Subtraction, 1)); break; } uQuery.AddCondition("user_id", Owner.Id); db.Query(uQuery); doPublish = true; break; case PublishStatuses.Draft: uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Addition, 1)); switch (myBlogEntry.Status) { case PublishStatuses.Published: uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Subtraction, 1)); break; case PublishStatuses.Queued: uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Subtraction, 1)); break; } uQuery.AddCondition("user_id", Owner.Id); db.Query(uQuery); break; case PublishStatuses.Queued: uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Addition, 1)); switch (myBlogEntry.Status) { case PublishStatuses.Published: uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Subtraction, 1)); break; case PublishStatuses.Draft: uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Subtraction, 1)); break; } uQuery.AddCondition("user_id", Owner.Id); db.Query(uQuery); break; } } // Save image attachments { postBody = core.Bbcode.ExtractAndSaveImageData(postBody, myBlogEntry, saveImage); } myBlogEntry.Title = title; myBlogEntry.BodyCache = string.Empty; myBlogEntry.Body = postBody; myBlogEntry.License = license; myBlogEntry.Category = category; myBlogEntry.ModifiedDateRaw = currentTimestamp; if (postEditTimestamp) { myBlogEntry.PublishedDateRaw = tz.GetUnixTimeStamp(postTime); } myBlogEntry.Status = publishStatus; myBlogEntry.Update(); if (publishToFeed && publishStatus == PublishStatuses.Published && doPublish) { core.Search.Index(myBlogEntry); core.CallingApplication.PublishToFeed(core, LoggedInMember, myBlogEntry, myBlogEntry.Title); } Tag.LoadTagsIntoItem(core, myBlogEntry, TagSelectBox.FormTags(core, "tags")); } else if (postId == 0) // else if to make sure only one triggers { long postTimeRaw; // save new if (postEditTimestamp) { postTimeRaw = tz.GetUnixTimeStamp(postTime); } else { postTimeRaw = currentTimestamp; } if (postTimeRaw > UnixTime.UnixTimeStamp()) { publishStatus = PublishStatuses.Queued; } db.BeginTransaction(); BlogEntry myBlogEntry = BlogEntry.Create(core, AccessControlLists.GetNewItemPermissionsToken(core), myBlog, title, postBody, license, publishStatus, category, postTimeRaw); /*AccessControlLists acl = new AccessControlLists(core, myBlogEntry); acl.SaveNewItemPermissions();*/ postGuid = core.Hyperlink.StripSid(string.Format("{0}blog/{1:0000}/{2:00}/{3}", LoggedInMember.UriStubAbsolute, DateTime.Now.Year, DateTime.Now.Month, postId)); myBlogEntry.Guid = postGuid; long updated = myBlogEntry.Update(); if (updated > 0) { } switch (publishStatus) { case PublishStatuses.Published: UpdateQuery uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Addition, 1)); uQuery.AddCondition("user_id", Owner.Id); db.Query(uQuery); break; case PublishStatuses.Draft: uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_drafts", new QueryOperation("blog_drafts", QueryOperations.Addition, 1)); uQuery.AddCondition("user_id", Owner.Id); db.Query(uQuery); break; case PublishStatuses.Queued: uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Addition, 1)); uQuery.AddCondition("user_id", Owner.Id); db.Query(uQuery); break; } Tag.LoadTagsIntoItem(core, myBlogEntry, TagSelectBox.FormTags(core, "tags"), true); // Save image attachments { postBody = core.Bbcode.ExtractAndSaveImageData(postBody, myBlogEntry, saveImage); myBlogEntry.BodyCache = string.Empty; myBlogEntry.Body = postBody; myBlogEntry.Update(); // only triggers if postBody has been updated } if (publishToFeed && publishStatus == PublishStatuses.Published) { core.Search.Index(myBlogEntry); core.CallingApplication.PublishToFeed(core, LoggedInMember, myBlogEntry, myBlogEntry.Title); } } switch (publishStatus) { case PublishStatuses.Draft: SetRedirectUri(BuildUri("drafts")); core.Display.ShowMessage("Draft Saved", "Your draft has been saved."); break; case PublishStatuses.Published: SetRedirectUri(BuildUri("manage")); core.Display.ShowMessage("Blog Post Published", "Your blog post has been published."); break; case PublishStatuses.Queued: SetRedirectUri(BuildUri("queue")); core.Display.ShowMessage("Blog Post Queued", "Your blog post has been placed in the publish queue."); break; } }
/// <summary> /// /// </summary> /// <returns></returns> public override bool ExecuteCron() { // In this cron we will find any queued unpublished blog posts // ready to publish and publish them SelectQuery query = BlogEntry.GetSelectQueryStub(core, typeof(BlogEntry)); query.AddCondition("post_status", (byte)PublishStatuses.Queued); query.AddCondition("post_published_ut", ConditionEquality.LessThanEqual, UnixTime.UnixTimeStamp()); DataTable blogPosts = core.Db.Query(query); foreach (DataRow row in blogPosts.Rows) { BlogEntry be = new BlogEntry(core, row); core.LoadUserProfile(be.OwnerId); core.CreateNewSession(core.PrimitiveCache[be.OwnerId]); UpdateQuery uQuery = new UpdateQuery(typeof(Blog)); uQuery.AddField("blog_entries", new QueryOperation("blog_entries", QueryOperations.Addition, 1)); uQuery.AddField("blog_queued_entries", new QueryOperation("blog_queued_entries", QueryOperations.Subtraction, 1)); uQuery.AddCondition("user_id", be.OwnerId); core.Db.Query(uQuery); uQuery = new UpdateQuery(typeof(BlogEntry)); uQuery.AddField("post_status", (byte)PublishStatuses.Published); uQuery.AddCondition("post_id", be.Id); core.Db.Query(uQuery); core.Search.Index(be); core.CallingApplication.PublishToFeed(core, be.Author, be, be.Title); } return true; }
/// <summary> /// /// </summary> /// <param name="callName"></param> public override void ExecuteCall(string callName) { switch (callName) { case "get_posts": long userId = core.Functions.RequestLong("id", core.Session.LoggedInMember.Id); int page = Math.Max(core.Functions.RequestInt("page", 1), 1); int perPage = Math.Max(Math.Min(20, core.Functions.RequestInt("per_page", 10)), 1); try { Blog blog = new Blog(core, userId); List<BlogEntry> blogEntries = blog.GetEntries(string.Empty, string.Empty, 0, 0, 0, page, perPage); core.Response.WriteObject(blogEntries); } catch (InvalidBlogException) { } break; case "get_post": long postId = core.Functions.RequestLong("id", 0); if (postId > 0) { BlogEntry entry = new BlogEntry(core, postId); if (entry.Access.Can("VIEW")) { core.Response.WriteObject(entry); } } break; } }
public TrackBack(Core core, BlogEntry blogPost, long trackBackId) : this(core, null, blogPost, trackBackId) { }
/// <summary> /// Create a new TrackBack /// </summary> /// <param name="core">Core token</param> /// <param name="entry">Blog entry to attach trackback to</param> /// <param name="uri">Trackback uri</param> /// <param name="blurb">Trackback blurb</param> /// <returns></returns> public static TrackBack Create(Core core, BlogEntry entry, string uri, string blurb) { if (core == null) { throw new NullCoreException(); } if (entry == null) { throw new InvalidBlogEntryException(); } // TODO: validate uri InsertQuery iquery = new InsertQuery(TrackBack.GetTable(typeof(TrackBack))); iquery.AddField("post_id", entry.PostId); iquery.AddField("trackback_uri", uri); iquery.AddField("trackback_blurb", Functions.TrimStringToWord(blurb, 511)); iquery.AddField("trackback_time_ut", UnixTime.UnixTimeStamp()); iquery.AddField("trackback_ip", core.Session.IPAddress.ToString()); long id = core.Db.Query(iquery); return new TrackBack(core, id); }
public TrackBack(Core core, Blog blog, BlogEntry blogPost, DataRow trackBackRow) : base(core) { ItemLoad += new ItemLoadHandler(TrackBack_ItemLoad); this.blog = blog; this.blogPost = blogPost; loadItemInfo(trackBackRow); }
public TrackBack(Core core, BlogEntry blogPost, DataRow trackBackRow) : this(core, null, blogPost, trackBackRow) { }
/// <summary> /// Gets a list of entries in the blog fullfilling a given criteria. /// </summary> /// <param name="category">Category to select</param> /// <param name="post">Post id to select</param> /// <param name="year">Year to select</param> /// <param name="month">Month to select</param> /// <param name="currentPage">Current page</param> /// <param name="perPage">Number to show on each page</param> /// <param name="drafts">Flag to select draft posts or published posts (true for drafts)</param> /// <returns>A list of blog entries</returns> /// <remarks>A number of conditions may be omitted. Integer values can be omitted by passing -1. String values by passing a null or empty string.</remarks> private List<BlogEntry> GetEntries(string category, string tag, long post, int year, int month, int currentPage, int perPage, long currentOffset, bool drafts, bool future, out bool moreContent) { double pessimism = 1.2; List<BlogEntry> entries = new List<BlogEntry>(); moreContent = false; long loggedIdUid = core.LoggedInMemberId; SelectQuery query = null; if (string.IsNullOrEmpty(category) && string.IsNullOrEmpty(tag)) { query = Item.GetSelectQueryStub(core, typeof(BlogEntry)); query.AddField(new DataField(typeof(BlogEntry), "post_id")); if (post > 0) { query.AddCondition("post_id", post); } if (year > 0) { query.AddCondition("YEAR(FROM_UNIXTIME(post_published_ut))", year); } if (month > 0) { query.AddCondition("MONTH(FROM_UNIXTIME(post_published_ut))", month); } } else if (string.IsNullOrEmpty(tag)) { query = Item.GetSelectQueryStub(core, typeof(BlogEntry)); query.AddField(new DataField(typeof(BlogEntry), "post_id")); query.AddCondition("category_path", category); query.AddJoin(JoinTypes.Inner, "global_categories", "post_category", "category_id"); } else { query = Item.GetSelectQueryStub(core, typeof(ItemTag)); query.AddFields(Item.GetFieldsPrefixed(core, typeof(BlogEntry))); query.AddJoin(JoinTypes.Inner, new DataField(typeof(ItemTag), "item_id"), new DataField(typeof(BlogEntry), "post_id")); query.AddCondition("item_type_id", ItemType.GetTypeId(core, typeof(BlogEntry))); query.AddCondition("tag_text_normalised", tag); } // Include blog entries from the past only if future is false if (!future) { query.AddCondition(new DataField(typeof(BlogEntry), "post_published_ut"), ConditionEquality.LessThanEqual, UnixTime.UnixTimeStamp()); } int bpage = currentPage; if (post > 0) { bpage = 1; } int limitStart = (bpage - 1) * perPage; PublishStatuses status = (drafts) ? PublishStatuses.Draft : ((future) ? PublishStatuses.Queued : PublishStatuses.Published); query.AddCondition("post_status", (byte)status); query.AddCondition("user_id", UserId); query.AddSort(SortOrder.Descending, "post_published_ut"); /*query.LimitStart = (bpage - 1) * perPage;*/ if ((currentOffset > 0 && currentPage > 1) || currentOffset == 0) { long lastId = 0; long lastPostTime = 0; QueryCondition qc1 = null; QueryCondition qc2 = null; SelectQuery offsetQuery = new SelectQuery(typeof(BlogEntry)); offsetQuery.AddField(new DataField(typeof(BlogEntry), "post_published_ut")); offsetQuery.AddCondition("post_id", currentOffset); if (currentOffset > 0) { qc1 = query.AddCondition("post_published_ut", ConditionEquality.LessThan, offsetQuery); } query.LimitCount = (int)(perPage * pessimism); while (entries.Count <= perPage) { List<IPermissibleItem> tempBlogEntries = new List<IPermissibleItem>(); /*DataTable blogEntriesTable = db.Query(query); if (blogEntriesTable.Rows.Count == 0) { break; } foreach (DataRow row in blogEntriesTable.Rows) { BlogEntry entry = new BlogEntry(core, this, owner, row); tempBlogEntries.Add(entry); }*/ System.Data.Common.DbDataReader blogReader = core.Db.ReaderQuery(query); if (!blogReader.HasRows) { blogReader.Close(); blogReader.Dispose(); break; } while (blogReader.Read()) { BlogEntry entry = new BlogEntry(core, this, owner, blogReader); tempBlogEntries.Add(entry); } blogReader.Close(); blogReader.Dispose(); core.AcessControlCache.CacheGrants(tempBlogEntries); foreach (IPermissibleItem entry in tempBlogEntries) { if (entry.Access.Can("VIEW")) { if (entries.Count == perPage) { moreContent = true; break; } else { entries.Add((BlogEntry)entry); } } lastId = entry.Id; lastPostTime = ((BlogEntry)entry).PublishedDateRaw; } //query.LimitStart += query.LimitCount; if (qc1 == null) { SelectQuery oQuery = new SelectQuery(typeof(BlogEntry)); oQuery.AddField(new DataField(typeof(BlogEntry), "post_published_ut")); oQuery.AddCondition("post_id", currentOffset); qc1 = query.AddCondition("post_published_ut", ConditionEquality.LessThan, oQuery); } else { qc1.Value = lastId; } if (qc2 == null) { qc2 = query.AddCondition("post_published_ut", ConditionEquality.LessThanEqual, lastPostTime); } else { qc2.Value = lastPostTime; } query.LimitCount = (int)(query.LimitCount * pessimism); if (moreContent || post > 0) { break; } } } else { DataTable blogEntriesTable = db.Query(query); /* Check ACLs, not the most efficient, but will only check mostly newer content which should be viewed first. */ int offset = 0; int i = 0; while (i < limitStart + perPage + 1 && offset < blogEntriesTable.Rows.Count) { List<IPermissibleItem> tempBlogEntries = new List<IPermissibleItem>(); int j = 0; for (j = offset; j < Math.Min(offset + perPage * 2, blogEntriesTable.Rows.Count); j++) { BlogEntry entry = new BlogEntry(core, this, owner, blogEntriesTable.Rows[j]); tempBlogEntries.Add(entry); } if (tempBlogEntries.Count > 0) { core.AcessControlCache.CacheGrants(tempBlogEntries); foreach (IPermissibleItem entry in tempBlogEntries) { if (entry.Access.Can("VIEW")) { if (i >= limitStart + perPage) { moreContent = true; break; } if (i >= limitStart) { entries.Add((BlogEntry)entry); } i++; } } } else { break; } offset = j; } } return entries; }
public PingBack(Core core, BlogEntry blogPost, long pingBackId) : this(core, null, blogPost, pingBackId) { }
public static PingBack Create(Core core, BlogEntry entry, string uri) { if (core == null) { throw new NullCoreException(); } if (entry == null) { throw new InvalidBlogEntryException(); } InsertQuery iquery = new InsertQuery(PingBack.GetTable(typeof(PingBack))); iquery.AddField("post_id", entry.PostId); iquery.AddField("pingback_uri", uri); iquery.AddField("pingback_time_ut", UnixTime.UnixTimeStamp()); iquery.AddField("pingback_ip", core.Session.IPAddress.ToString()); long id = core.Db.Query(iquery); return new PingBack(core, id); }
public PingBack(Core core, BlogEntry blogPost, DataRow pingBackRow) : this(core, null, blogPost, pingBackRow) { }