posts - 378, comments - 625, trackbacks - 116,
Dan Bartels online engineering logbook... Items that I find useful organized for my use, and indexed by google for yours. Here you can find information about Microsoft C# programming, SQL SERVER 2005, Telligent Systems CommunityServer, Dot Net Nuke, Windows Vista / Longhorn, and just about anything else that would compel me to type.

News

What I am Reading:


Professional Community Server

Past books can be viewed on:

Post Categories

Archives

Coding Techniques

Coding Tools

Community Sites

Deal Finders

Friends Businesses

Microsofties

Smartphones

Utilities

my blogmap
CS 2.1 support for unpublished photos

So I have a very cool gallery mod, I am about to release, but it relies on a late add feature to CS 2.1, unpublished posts.  I took the idea from blogs, and added support for unpublishing posts, and while the control panel mechanics are there and work just fine (you can make an un published photo, or take a published photo and unpublish it) several of the UI controls, or more specifically "thread queries" weren't updated to only display published content.  I have since checked in a fix for this which will be released with the next CS 2.1 service pack (sp3), but want to outline the changes for those with the SDK who might want this change sooner than later...

The fix involves adding a property to the thread query argument in 6 files, and a tweak to the get random post function; the changes are as follows. (line numbers are approximate)

/Galleries/Controls/Aggregate/AggregatePortalPictureScroller.cs (line 380)

public override void DataBind()
{
[...]
query.ApplicationPostType = GalleryPostType.Image;

query.PublishedFilter =
GalleryPostPublishedFilter.Published;

ArrayList pictures = GalleryPosts.GetPictures(query, true, true).Threads;
[...]
}

/Galleries/Controls/PictureDetails.cs (line 108, and line 144)

private void BindData()
{
[...]
query.SectionID = CurrentGallery.SectionID;

query.PublishedFilter = GalleryPostPublishedFilter.Published;

PostSet ps = GalleryPosts.GetPostSet(query);

[...]

pagerQuery.IncludePageIndex =
true;

//Only load published photos into the pager
pagerQuery.PublishedFilter = GalleryPostPublishedFilter.Published;

//For CS 1.2 we are dropping the option to let the user sort
[...]
}

/Galleries/Controls/Slideshow.cs (line 120)

protected override void CreateChildControls()
{
[...]
query.ApplicationPostType = GalleryPostType.Image;

 

query.PublishedFilter = GalleryPostPublishedFilter.Published;

pictures = GalleryPosts.GetPictures(query).Threads;
[...]
}

/Galleries/Components/TrackBackHandler.cs (line 206)

private static bool IsNewTrackBack(GalleryPost post, string trackbackUrl)
{
[...]
query.ReturnFullThread = true;

 

query.PublishedFilter = GalleryPostPublishedFilter.Published;

PostSet ps = GalleryPosts.GetPostSet(query) ;
[...]
}

/Galleries/GalleryPosts.cs (line 256 a new GetRandomPicture method and line 290)

public static GalleryPost GetRandomPicture(int galleryID, int categoryID)
{
CSContext cSContext = CSContext.Current;
string cacheKey = "RandomPicture-Gallery:" + galleryID + "-Category:" + categoryID;
int postID = -1;

if (!cSContext.Items.Contains(cacheKey))
{
   //Get random post does not support moderated posts, so use a thread query
   //postID = GalleryDataProvider.Instance().GetRandomPostID(galleryID, categoryID);

   GalleryThreadQuery
query = new GalleryThreadQuery();
   query.SectionID = galleryID;
   query.PageIndex = 0;
   query.PageSize = 999999;
   query.ApplicationPostType =
GalleryPostType.Image;
   query.PublishedFilter =
GalleryPostPublishedFilter.Published;

   if
(categoryID > 0)
      query.CategoryID = categoryID;
   ArrayList threads = GalleryPosts.GetPictures(query).Threads;
   if(threads != null && threads.Count > 0)
   {
       Random r = new Random();
       int i = r.Next(0, threads.Count-1);
      GalleryPost post = (GalleryPost) threadsIdea;
      cSContext.Items.Add(cacheKey, post.PostID);
      return post;
    }
}
else
   postID = (int)cSContext.Items[cacheKey];

if (postID == -1)
   return null;
else
   return GetPicture(postID);
}

public static GalleryPost GetFirstPicture(int galleryID, int categoryID)
{
[...]
query.SortOrder = g.ThreadSortOrder;

query.PublishedFilter = GalleryPostPublishedFilter.Published;

ThreadSet ts = GalleryPosts.GetPictures(query);
[...]
}

/Galleries/Components/Syndication/GalleryRssHandler.cs (line 115)

protected override CachedFeed BuildFeed()
{
[...]
query.PageSize = GalleryConfig.RssDefaultThreadsPerFeed;

query.PublishedFilter = GalleryPostPublishedFilter.Published;

if (Tags != null && Tags.Length > 0)
[...]
}

/Galleries/Components/Syndication/GalleryCommentRssHandler.cs (line 45)

protected override CachedFeed BuildFeed()
{
[...]
query.PageSize = GalleryConfig.RssDefaultThreadsPerFeed;

query.PublishedFilter = GalleryPostPublishedFilter.Published;

PostSet ps = GalleryPosts.GetPostSet(query) ;
[...]
}

Published Thursday, March 22, 2007 10:38 PM by DanB

Filed under , ,
::

Comments

# Unpublished photo support coming @ Wednesday, March 28, 2007 3:04 AM

Dan Bartels with big news of unpublished photo support coming in the next CS 2.1 Service Pack and in

Dave Burke's Community Server Bits

# Allowing users to upload photos to your gallery @ Thursday, March 29, 2007 11:55 AM

Its finally here, a control which you can put in the public sidebar of your gallery, to allow users to

Dan Bartels

# This Week's News for March 30, 2007 @ Friday, March 30, 2007 9:22 AM

This week... Introducing the Community Server Wiki! The Wiki will initially be used to better serve up

Announcements

# This Week's News for March 30, 2007 @ Friday, March 30, 2007 9:47 AM

This week... Introducing the Community Server Wiki! The Wiki will initially be used to better serve up

Community Server

# CS 2.1 support for unpublished photos @ Sunday, April 01, 2007 1:45 AM

dmwc

# DanBartels.CS.Photos.AddPhoto @ Friday, August 22, 2008 3:47 PM

Its finally here, a control which you can put in the public sidebar of your gallery, to allow users to

Getting Started forum posts from CommunityServer.com

Leave a Comment

(required) 
(required) 
(optional)
(required) 
 
Powered by Community Server (Commercial Edition), by Telligent Systems
powered by god (with a little help from Telligent Systems - Community Server 2.1)