+1-888-365-2779
Try Now
More in this section
Categories
Bloggers
Blogs RSS feed

In the mean time series (part 5): "Products" module - simple implementation with enabled permissions and workflow

by Ivan Osmak

Ok, this will be a ridiculously simple and short post. This, precisely, is the reason why you should buy a CMS and not build one on your own. In this post, we will turn on the workflow for our products module in no more than two steps and less than five minutes.

NOTE #1: As always, this post is a part of the sequential series so I assume you have set up the project as it was described in the introductory article and that you have enabled permissions on your module as I have described in this article.

NOTE #2: Workflow feature is not available in the Community version of Sitefinity.

Enabling workflow on products module

Even though I don’t suspect that I need to explain what workflow control is, let me just briefly illustrate with two screenshots, what exactly we are about to do. Namely, we want to be able to control who can create, who can approve and who can publish the products. Once we turn on the workflow, new buttons, similar to the one in Figure 1, will appear in the view mode of our product.

 
Figure 1: after creating the product, a “Send for approval” button has appeared in the view mode

To determine who can do what in the workflow process, we will also enhance our permissions control with two additional permissions: Approve and Publish. Once we are done with that, our Permissions View control will look like the one on Figure 2:


Figure 2: Permissions control of the products module, after we have enhanced it with workflow permissions

Step 1 – enable workflow on the Products module

In order to enable workflow on the products module, all we have to do is open web.config and set the allowWorkflow property of the products generic content provider to true. Navigate to this element in web.config – telerik/cmsEngine/providers and modify the products provider element to look as this:

<add name="Products" allowWorkflow="true" urlRewriteFormat="[Name].aspx" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" securityProviderName="" allowVersioning="False" applicationName="/Products" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data" /> 

And we are done with the step 1.

Step 2 – enable workflow permissions on Products module

The second step is to enable workflow permissions, which are already present in the permissions template and only need to be uncommented. Open following file in your project:

~/Sitefinity/Admin/ControlTemplates/Products/ControlPanelPermissions.ascx

And uncomment the last two permissions, marked by “Uncomment this block when using workflow”. Here are the lines I am referring to and which should be uncommented:

<tr> 
   <th> 
      <asp:Literal runat="server" Text="<%$Resources:Approve %>"></asp:Literal> 
   </th> 
   <td> 
      <asp:CheckBox ID="allowApprove" Text="<%$Resources:Allow %>" runat="server" onclick="CheckBoxHandler(this, this.parentNode.parentNode.getElementsByTagName('input')[1].id)" /> 
   </td> 
   <td> 
      <asp:CheckBox ID="denyApprove" Text="<%$Resources:Deny %>" runat="server" onclick="CheckBoxHandler(this, this.parentNode.parentNode.getElementsByTagName('input')[0].id)" /> 
   </td> 
</tr> 
<tr> 
   <th> 
      <asp:Literal runat="server" Text="<%$Resources:Publish %>"></asp:Literal> 
   </th> 
   <td> 
      <asp:CheckBox ID="allowPublish" Text="<%$Resources:Allow %>" runat="server" onclick="CheckBoxHandler(this, this.parentNode.parentNode.getElementsByTagName('input')[1].id)" /> 
   </td> 
   <td> 
      <asp:CheckBox ID="denyPublish" Text="<%$Resources:Deny %>" runat="server" onclick="CheckBoxHandler(this, this.parentNode.parentNode.getElementsByTagName('input')[0].id)" /> 
   </td> 
</tr> 

And this is all you have to do in order to enable the workflow on the products module (or any other Generic Content based module for that matter). Save your project, create some additional roles and test the new workflow feature.

The complete source code for this sample you can download from here.

Leave a comment