Digital Serenity

Digital Serenity is the blog of John McPherson Leask III (Jay). His mind wanders from food to travels, every-day activities and humor to sports, podcasting and technology - though mostly the focus of Digital Serenity will be his technological exploits.

December 2007 - Posts

IHasAFlavor I haven't talked about many of my side projects here, and little by little I'll start showcasing them; but this one is one of the "closer-to-home" ones that I've done, plus someone kindly inspired me to talk about it, so here I am.

San Francisco Cheesequake is an artisinal cheesecake maker in San Francisco - and also my eldest brother.  Peter has been baking for years and has found a niche in the cheesecake market with some of his recipes:

  • Baklava
  • Candycap Mushroom
  • Chanterelle Apricot Brandy
  • Chocolate Port Poached Pears
  • Masala Spiced Chaisquake

Yes, those are cheesecake names - and only a few of the over 25 different flavors he markets on his website.  Seriously, they are amazing.

A little about the site

It's a simple template driven site using PHP and MySQL.  The logo was designed by a local San Francisco artist and sent on to me to tie into a website, the site design was a simple inspiration from said logo. 

sfcheesequake_home

There are database administration points for the Cheesecakes listing as well as the contact list (which can be filled out from the "Mailing List" or "Contact Us" forms) and the Professional & Personal testimonials with plans to include the Wine Pairings in an administrative database panel.

sfcheesequake_admin

Overall I'm pretty happy with the site.  It follows what I consider to be the important things in designing websites today:

  • Make your navigation intuitive
  • Make your content manageable
  • Keep your designs simple

In other words: it's all about the user experience.  Far too often a great website goes to *** because a Project Manager can't control the client or the designer decides to get too crazy and give the client too many options - or worse yet, a programmer ignores designs and business rules and goes off on their own tangent.  Thankfully I'm in a company right (shoutout to Telligent!) now where all of those things seem to be under good control.

Anyway, the point here is less about the site and more about pimping my brothers artisinal cheesecake business.  Go check the site out, see if there are any flavors you like - and while overnight shipping a cheesecake isn't inexpensive, the cakes are WELL worth it (get them for company events and charge the company UPS/FedEx account!).  You know these things sell for 7 or more bux A SLICE at restaurants around San Francisco???  Must be doing SOMETHING right!

By the way, tell him I sent you - I doubt he'll cut anything off the price, but if enough of you do he might send me free cheesecake!!!!  (Peter, I have GOT to try that Masala Spiced Chaisquake ::hint hint::)

Posted by jleask | with no comments
Filed under: ,

There are usually 3 or 4 hundred different ways to skin a cat within .NET - and programming in general for that matter - so in no way will I ever declare MY way of doing things THE way of doing things ... they are just A way.  With that said I present to you my solution for displaying a blog in a custom list based on it's "role" (aka: Permissions Settings).

Customer Request:
Customizable list of blogs (yes, a Blogroll, if you will) from within this site.  Must be able to add and remove blogs from this list.

This auto-generated list already existed and it was in our best interest to reuse that.  In the past it was done by grabbing all the blogs, removing all the dead ones (no posts) and displaying them all.  It's just a custom little list to show the blogs by author - nice, easy, clean; now they want the ability to remove a blog from THIS list without removing it from any of its groups or aggregate post lists.  After talking it over with a few people the decision was made: let's (ab)use roles!

manageRoles_editePermissionsMembership Roles:
All membership roles (a site administrative list in Control Panel > Administration > Membership > Manage All Roles) appear within a blog's settings console (Control Panel > Administration > Blogs > Blogs (so nice I said it twice) > [open any blog] > Permissions).  They each have a handful of options available to you, of which in this particular exercise we only care about one ... "view".

First, create a role "InAuthorList" - Second, select your blog and click the checkbox to the right of "InAuthorList" and below "View" in the blog permissions screen.  That is the entire user experience for your site administrators .  No new administration pages for you, and no convoluted instructions for your administrators to follow.  1, 2 punch ...

Building your List:
The first step here is easy: create an ArrayList of blogs using the Weblogs.GetWeblogs() method.  After that, sort and filter - the real reason we are here though, that's the filter:

FilterBlogs()
private ArrayList FilterBlogs(ArrayList blogList)
{
   ArrayList cleanList = new ArrayList ();
   foreach (Weblog blog in blogList)
   {
     Hashtable ht = blog.PermissionSet;
     if (ht["InAuthorList"] != null)
     {
       WeblogPermission ebl = ht["InAuthorList"] as WeblogPermission;
       if (ebl.View == true)
       {
         cleanList.Add(blog);
       }
     }
     else
     {
       cleanList.Add(blog);
     }
   }
   return cleanList;
}

The real guts of this is the Hashtable that is returned from Weblog.PermissionSet property.  A hashtable is a list of key/value pairs - first you have to access the record you are looking for, and for our purposes that is the role we created earlier "InAuthorList".  While I shouldn't have to check that it's not null, since roles can be deleted by site administrators it's smart to check for that and have a backup plan (mine is to add everything if the role is non-existant).

Now that we have our record within the hashtable, we need to get our value.  First, set the record to a Community Server WeblogPermission object, then test that the "View" (our key) option is "true" (our value - and yes we're testing against the boolean true, not a string - when we cast the record as a WeblogPermission, it knew to cast he string "true" to a boolean).  See, that wasn't so hard now was it?

Roles and Users:
While we didn't use them the way they are designed to be used, generally when dealing with roles you are more concerned with wether a user is in the role than if the role should be displayed - and with a simple "IsUserInRole" check you can - but since that's not what I was focusing on, I'm going to leave that for another post.

In Conclusion:
I'm curious how you would have solved this.  Really, the only reason to have people read these thoughts is to get their opinions ... so tell me: How would you have solved the clients request with minimal effort?

Oh yeah, I have to thank fellow Telligenti Joel Dewbre (no blog to link) and Kevin Harder for the help they both gave in this little venture.  I'm still very new to customizing Community Server and while it's very customizable if you know what you're doing ... well ... I'm still learning what I'm doing!

Posted by jleask | with no comments
Filed under: , ,