I am trying to find documentation on how to implement security on a custom intra-site module. All documentation I have found to date relates to modules developed outside of the sitefinity web site solution. For example:
http://www.sitefinity.com/blogs/ivan/posts/09-03-22/products_module_implementing_permissions.aspx
This solution, however, does not apply to inline modules which do not use embedded templates. I tried to modify the solution presented in this article to "fit" within the context of inline modules as presented below:
using System;
using Telerik.Cms.Engine;
using Telerik.Cms.Engine.Security;
using Telerik.Cms.Engine.WebControls;
using Telerik.Cms.Engine.WebControls.Admin;
namespace App_Code.BranchOpPlan
{
public class BranchOpPermissionsView : PermissionsView<
BranchOpPlanControlPanel
>
{
private const string TemplateName = "SMO.Modules.BranchOpPlans.BopPermissionsView.ascx";
#region Overriden methods
/* by overriding the permissions methods, we can substitute the permissions for generic content
* module with permissions for products module, while we leave the base class to perform the
* business logic based on these permissions */
/// <
summary
>
/// Gets the permissions.
/// </
summary
>
/// <
returns
></
returns
>
protected override GlobalPermissions GetPermissions()
{
return Host.BranchManager.Permissions;
}
/// <
summary
>
/// Gets the permission.
/// </
summary
>
/// <
returns
></
returns
>
protected override GlobalPermission GetPermission()
{
return Host.BranchManager.GetPermission();
}
/// <
summary
>
/// Gets the permission.
/// </
summary
>
/// <
param
name
=
"requestRights"
>The request rights.</
param
>
/// <
returns
></
returns
>
protected override GlobalPermission GetPermission(int requestRights)
{
return Host.BranchManager.GetPermission(requestRights);
}
/// <
summary
>
/// Gets the permission.
/// </
summary
>
/// <
param
name
=
"contentOwnerId"
>The content owner id.</
param
>
/// <
returns
></
returns
>
protected override GlobalPermission GetPermission(Guid contentOwnerId)
{
return Host.BranchManager.GetPermission(contentOwnerId);
}
/// <
summary
>
/// Gets the permission.
/// </
summary
>
/// <
param
name
=
"contentOwnerId"
>The content owner id.</
param
>
/// <
param
name
=
"requestRights"
>The request rights.</
param
>
/// <
returns
></
returns
>
protected override GlobalPermission GetPermission(Guid contentOwnerId, int requestRights)
{
return Host.BranchManager.GetPermission(contentOwnerId, requestRights);
}
/// <
summary
>
/// Gets the permission.
/// </
summary
>
/// <
param
name
=
"contentOwner"
>The content owner.</
param
>
/// <
returns
></
returns
>
protected override GlobalPermission GetPermission(IContent contentOwner)
{
return Host.BranchManager.GetPermission(contentOwner);
}
/// <
summary
>
/// Gets the permission.
/// </
summary
>
/// <
param
name
=
"contentOwner"
>The content owner.</
param
>
/// <
param
name
=
"requestRights"
>The request rights.</
param
>
/// <
returns
></
returns
>
protected override GlobalPermission GetPermission(IContent contentOwner, int requestRights)
{
return Host.BranchManager.GetPermission(contentOwner, requestRights);
}
/// <
summary
>
/// Gets or sets the path to a custom layout template for the control.
/// </
summary
>
/// <
value
></
value
>
[WebSysTemplate(TemplateName, "BranchOpPermissionsView_Description", "", false, "2010-06-29")]
public override string LayoutTemplatePath
{
get
{
return base.LayoutTemplatePath;
}
set
{
base.LayoutTemplatePath = value;
}
}
/// <
summary
>
/// Gets the type from the assembly containing the embedded localization resource.
/// Override if embedded templates are using ASP.NET localization.
/// </
summary
>
/// <
value
></
value
>
public override Type LocalizationAssemblyInfo
{
get
{
return typeof(GenericControlPanel);
}
set
{
base.LocalizationAssemblyInfo = value;
}
}
/// <
summary
>
/// Gets the type from the assembly containing the embedded resources.
/// Cannot be null reference.
/// </
summary
>
/// <
value
></
value
>
public override Type AssemblyInfo
{
get
{
return typeof(ContentView);
}
set
{
base.AssemblyInfo = value;
}
}
/// <
summary
>
/// Gets the name of the embedded layout template. This property must be overridden to provide the path (key) to an embedded resource file.
/// </
summary
>
protected override string LayoutTemplateName
{
get
{
return TemplateName;
}
}
#endregion
}
}
I also modified my inline module's class to inherit from SecuredModule and implemented a BranchPlanManager class to control the security for this module.
In the end, no matter what I try I continually get this error whenever I click on the permission view for this module in sitefinity:
Invalid resource name
(SMO.Modules.BranchOpPlans.BopPermissionsView.ascx) for assembly
(Telerik.Cms.Engine, Version=3.6.1936.2, Culture=neutral,
PublicKeyToken=dfeaee0e3978ac79) or empty template.
It blows up in the Telerik.Framework.Web.ControlsUtils class:
I have up to this point literally copied the entire solution found in the article, and I still can't get it to work. Any feedback would be appreciated.
Cheers,