<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://jay.leask.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Digital Serenity : Community Server, Code</title><link>http://jay.leask.com/archive/tags/Community+Server/Code/default.aspx</link><description>Tags: Community Server, Code</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>Custom Post Pages for site workflow</title><link>http://jay.leask.com/archive/2008/08/26/custom-post-pages-for-site-workflow.aspx</link><pubDate>Tue, 26 Aug 2008 17:35:50 GMT</pubDate><guid isPermaLink="false">8d8a2304-c812-41d6-94bc-4e6dd6490643:66</guid><dc:creator>jleask</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://jay.leask.com/rsscomments.aspx?PostID=66</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://jay.leask.com/commentapi.aspx?PostID=66</wfw:comment><comments>http://jay.leask.com/archive/2008/08/26/custom-post-pages-for-site-workflow.aspx#comments</comments><description>&lt;p&gt;We recently had a client who required a custom post page for workflow purposes:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Please create role &amp;quot;DraftPosts&amp;quot; and allow them to create posts in the &amp;quot;Workflow&amp;quot; blog but only save drafts, not publish.&amp;#160; Also, please make sure they use the site skin, not the control panel skin&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Fairly simple with a few &amp;quot;gotcha&amp;quot; steps.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create the new role &amp;quot;&lt;em&gt;DraftPosts&lt;/em&gt;&amp;quot;      &lt;br /&gt;&lt;a href="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/CustomPostPagesforsiteworkflow_B11D/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="283" alt="image" src="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/CustomPostPagesforsiteworkflow_B11D/image_thumb.png" width="644" border="0" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt;    &lt;li&gt;Update &amp;quot;&lt;em&gt;Workflow&lt;/em&gt;&amp;quot; blog permissions to allow &amp;quot;&lt;em&gt;DraftPosts&lt;/em&gt;&amp;quot; to manage content      &lt;br /&gt;&lt;a href="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/CustomPostPagesforsiteworkflow_B11D/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="278" alt="image" src="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/CustomPostPagesforsiteworkflow_B11D/image_thumb_1.png" width="644" border="0" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;a href="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/CustomPostPagesforsiteworkflow_B11D/image_6.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="260" alt="image" src="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/CustomPostPagesforsiteworkflow_B11D/image_thumb_2.png" width="644" border="0" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;That's fairly simple, but step 2, which I forgot, can cause quite a bit of headache if missed.&amp;#160; The next step is creating your Post Editor page; it's also fairly straight forward.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;From &lt;em&gt;/ControlPanel/Blogs/&lt;/em&gt; copy &lt;em&gt;CreateEditBlogPost.ascx &lt;/em&gt;and &lt;em&gt;PostEditor.aspx&lt;/em&gt; (and associated &lt;em&gt;.cs&lt;/em&gt; &amp;amp; &lt;em&gt;.resx&lt;/em&gt; pages) to your new location.&amp;#160; You'll want the new location to have access to the appropriate theme, so I put it in &lt;em&gt;/Themes/leanandgreen/common/&lt;/em&gt;.&lt;/li&gt;    &lt;li&gt;Update both pages so the class names are unique.&amp;#160; I renamed them to &lt;em&gt;DraftPostsPostEditorPage&lt;/em&gt;&amp;#160; and &lt;em&gt;DraftPostsCreateEditBlogPost &lt;/em&gt;respectively.&lt;/li&gt;    &lt;li&gt;Update both ASPX pages: inherit from the updated code behind pages and pointing them to the correct master pages.&amp;#160; ex.:     &lt;br /&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/em&gt;&lt;em&gt;&amp;lt;%@ Page language=&amp;quot;c#&amp;quot; Codebehind=&amp;quot;DraftPostsPostEditor.aspx.cs&amp;quot; AutoEventWireup=&amp;quot;false&amp;quot;       &lt;br /&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/em&gt;Inherits=&amp;quot;CommunityServer.ControlPanel.Blogs.DraftPostsPostEditorPage&amp;quot;         &lt;br /&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/em&gt;MasterPageFile=&amp;quot;~/Themes/leanandgreen/common/master.Master&amp;quot; %&amp;gt;&lt;/em&gt;&lt;/li&gt;    &lt;li&gt;Assign the &lt;em&gt;Workflow&lt;/em&gt; blog section ID to the &lt;em&gt;CSContext&lt;/em&gt;:      &lt;br /&gt;&lt;em&gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; override protected void OnInit(EventArgs e)        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .......        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MyWeblogSectionID = Weblogs.GetWeblog(&amp;quot;Workflow&amp;quot;).SectionID; &lt;/em&gt;&lt;/li&gt;    &lt;p&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CSContext.Current.SectionID = MyWeblogSectionID;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .......&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&lt;/em&gt;&lt;/p&gt; &lt;/ol&gt;  &lt;p&gt;Lastly, remember they only want the user to be able to save, not publish.&amp;#160; There are various ways of doing this and by far likely better ways than I chose to.&amp;#160; That said, I just hid the &amp;quot;Publish&amp;quot; button!&lt;/p&gt;  &lt;p&gt;Good luck, and don't hesitate to let me know if the above steps didn't work for you!   &lt;/p&gt;&lt;img src="http://jay.leask.com/aggbug.aspx?PostID=66" width="1" height="1"&gt;</description><category domain="http://jay.leask.com/archive/tags/Code/default.aspx">Code</category><category domain="http://jay.leask.com/archive/tags/CSTheme/default.aspx">CSTheme</category><category domain="http://jay.leask.com/archive/tags/Community+Server/default.aspx">Community Server</category></item><item><title>Accessing Blog Permissions (aka: Using roles for Blogs, not Users)</title><link>http://jay.leask.com/archive/2007/12/06/accessing-blog-permissions-aka-using-roles-for-blogs-not-users.aspx</link><pubDate>Thu, 06 Dec 2007 21:22:00 GMT</pubDate><guid isPermaLink="false">8d8a2304-c812-41d6-94bc-4e6dd6490643:30</guid><dc:creator>jleask</dc:creator><slash:comments>64</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://jay.leask.com/rsscomments.aspx?PostID=30</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://jay.leask.com/commentapi.aspx?PostID=30</wfw:comment><comments>http://jay.leask.com/archive/2007/12/06/accessing-blog-permissions-aka-using-roles-for-blogs-not-users.aspx#comments</comments><description>&lt;p&gt;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.&amp;nbsp; 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).&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Customer Request:&lt;/b&gt;     &lt;br&gt;Customizable list of blogs (yes, a &lt;i&gt;Blogroll&lt;/i&gt;, if you will) from within this site.&amp;nbsp; Must be able to add and remove blogs from this list.&lt;/p&gt;  &lt;p&gt;This auto-generated list already existed and it was in our best interest to reuse that.&amp;nbsp; In the past it was done by grabbing all the blogs, removing all the dead ones (no posts) and displaying them all.&amp;nbsp; 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.&amp;nbsp; After talking it over with a few people the decision was made: let's (ab)use roles!&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;a href="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/AccessingBlogPermissionsakaUsingrolesfor_118E4/manageRoles_editePermissions_2.gif" mce_href="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/AccessingBlogPermissionsakaUsingrolesfor_118E4/manageRoles_editePermissions_2.gif"&gt;&lt;img src="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/AccessingBlogPermissionsakaUsingrolesfor_118E4/manageRoles_editePermissions_thumb.gif" style="border-width: 0px;" alt="manageRoles_editePermissions" mce_src="http://jay.leask.com/images/chaotic_ramblings/WindowsLiveWriter/AccessingBlogPermissionsakaUsingrolesfor_118E4/manageRoles_editePermissions_thumb.gif" align="right" border="0" height="333" width="500"&gt;&lt;/a&gt;Membership Roles:&lt;/b&gt;     &lt;br&gt;All membership roles (a site administrative list in &lt;i&gt;Control Panel &amp;gt; Administration &amp;gt; Membership &amp;gt; Manage All Roles&lt;/i&gt;) appear within a blog's settings console (&lt;i&gt;Control Panel &amp;gt; Administration &amp;gt; Blogs &amp;gt; Blogs &lt;/i&gt;(so nice I said it twice)&lt;i&gt; &amp;gt; [open any blog] &amp;gt; Permissions&lt;/i&gt;).&amp;nbsp; They each have a handful of options available to you, of which in this particular exercise we only care about one ... "view".&lt;/p&gt;  &lt;p&gt;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.&amp;nbsp; That is the entire user experience for your site administrators .&amp;nbsp; No new administration pages for you, and no convoluted instructions for your administrators to follow.&amp;nbsp; 1, 2 punch ...&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Building your List:&lt;/b&gt;     &lt;br&gt;The first step here is easy: create an ArrayList of blogs using the &lt;i&gt;Weblogs.GetWeblogs()&lt;/i&gt; method.&amp;nbsp; After that, sort and filter - the real reason we are here though, that's the filter:&lt;/p&gt;  &lt;div class="code" style="clear: both;"&gt;   &lt;div class="legend"&gt;FilterBlogs()&lt;/div&gt;    &lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; font-size: 8pt; width: 97.5%; cursor: text; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;font color="#0000ff"&gt;private&lt;/font&gt; &lt;font color="#008080"&gt;ArrayList&lt;/font&gt; FilterBlogs(ArrayList blogList)       &lt;br&gt;{       &lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;ArrayList&lt;/font&gt; cleanList = &lt;font color="#0000ff"&gt;new&lt;/font&gt; &lt;font color="#008080"&gt;ArrayList&lt;/font&gt; ();       &lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;foreach&lt;/font&gt; (&lt;font color="#408080"&gt;Weblog &lt;/font&gt;blog &lt;font color="#0000ff"&gt;in&lt;/font&gt; blogList)       &lt;br&gt;&amp;nbsp;&amp;nbsp; {       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#408080"&gt;Hashtable &lt;/font&gt;ht = blog.PermissionSet;       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;if&lt;/font&gt; (ht["InAuthorList"] != &lt;font color="#0000ff"&gt;null&lt;/font&gt;)       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#408080"&gt;WeblogPermission &lt;/font&gt;ebl = ht["InAuthorList"] &lt;font color="#0000ff"&gt;as&lt;/font&gt; &lt;font &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;color="#408080"&gt;WeblogPermission&lt;/font&gt;;       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;if&lt;/font&gt; (ebl.View == &lt;font color="#0000ff"&gt;true&lt;/font&gt;)       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cleanList.Add(blog);       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;else&lt;/font&gt;       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cleanList.Add(blog);       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }       &lt;br&gt;&amp;nbsp;&amp;nbsp; }       &lt;br&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;return&lt;/font&gt; cleanList;       &lt;br&gt;} &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The real guts of this is the &lt;a href="http://support.microsoft.com/kb/309357" mce_href="http://support.microsoft.com/kb/309357" target="_blank"&gt;Hashtable&lt;/a&gt; that is returned from Weblog.PermissionSet property.&amp;nbsp; 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".&amp;nbsp; 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).&lt;/p&gt;  &lt;p&gt;Now that we have our record within the hashtable, we need to get our value.&amp;nbsp; 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).&amp;nbsp; See, that wasn't so hard now was it?&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Roles and Users:&lt;/b&gt;     &lt;br&gt;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.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;In Conclusion:&lt;/b&gt;     &lt;br&gt;I'm curious how you would have solved this.&amp;nbsp; 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?&lt;/p&gt;  &lt;p&gt;Oh yeah, I have to thank fellow Telligenti Joel Dewbre (no blog to link) and &lt;a href="http://kevinharder.com/" mce_href="http://kevinharder.com/" target="_blank"&gt;Kevin Harder&lt;/a&gt; for the help they both gave in this little venture.&amp;nbsp; 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!&lt;/p&gt;&lt;img src="http://jay.leask.com/aggbug.aspx?PostID=30" width="1" height="1"&gt;</description><category domain="http://jay.leask.com/archive/tags/Code/default.aspx">Code</category><category domain="http://jay.leask.com/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://jay.leask.com/archive/tags/Community+Server/default.aspx">Community Server</category></item></channel></rss>