Sitefinity CMS

Secured Intra-Site Module with LINQ Provider Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Adding New Modules to Sitefinity > Intra-site Modules > Secured Intra-Site Module with LINQ Provider

Glossary Item Box

This sample demonstrates how to implement secured Intra-Site module using provider pattern (the same pattern we use for our pluggable modules). The benefit of implementing an Intra-Site module in this manner is that you will create a rather robust and flexible module, while on the other hand implementing user interface will be much simpler, because you will do it with User Controls. The sample module is Contacts module.

Download the Sample Code from here.


For data access, LINQ to SQL provider has been used.

 

What is Supplied in This Sample?

In the App_Code folder you will find the Contacts folder which contains the code for Contacts module:

  1. Configuration folder – contains classes for contacts module section in web.config and provider declaration
  2. ConfigHelper.cs  - helper class which gets you <telerik> .. <contacts> section from the web.config file
  3. SectionHandler.cs – class which handles the <telerik> .. <contacts> section from the web.config file
  4. Interfaces folder – contains interfaces of an object we will be using in Contacts module
  5. IContact.cs – interface describing contact object
  6. IDepartment.cs – interface describing department object
  7. LINQData folder – folder containing Contacts.dbml file and classes extending LINQ objects
  8. Contacts.dbml – class representing the contacts module database tables as LINQ objects
  9. Contact.cs – class extending Contact LINQ object
  10. Department.cs – class extending Department LINQ object
  11. Providers folder – contains Contacts provider base class and LINQ to SQL provider implementation
  12. BaseContactsProvider.cs – base abstract class which must be implemented by any Contacts provider
  13. LinqContactsProvider.cs – LINQ to SQL Contacts provider implementation (this class inherits BaseContactsProvider)
  14. Security folder – folder containing classes for implementation of role-based permissions
  15. GlobalPermission.cs - inherits ApplicationPermission that is the base class for permissions.  Manages global permissions in the Contacts module.
  16. GlobalPermissions.cs - implements the ISecured interface. Represents the specified secured object that will be protected.
  17. ContactsManager.cs – Contacts module API class
  18. ContactsModule.cs – main module class for Contacts module
  19. IContactsControlPanel.cs – interface that defines the required members of Contacts module Control Panel

  20.  

    In the App_Data folder you will find Sitefinity.mdf database, used to build this sample.

     

    In the ContactsModule folder you will find the user interface elements of Contacts module:

    1. Admin folder – user controls for the admin side of the module
    2. ControlPanel.ascx and ControlPanel.ascx.cs – user control representing Control panel
    3. CommandPanel.ascx and CommandPanel.ascx.cs – user control representing Command panel
    4. Scripts folder – external java script files used by the module
    5. CommandPanel.js – implements certain client-side functionalities of Departmens treeview
    6. ContactsList.ascx and ContactsList.ascx.cs – represents public control for displaying list of controls
    7. SingleContact.ascx and SingleContact.ascx.cs – represents public control for displaying single contact
    8.  

      Finally, you will find the web.config file with the declaration and implementation of <telerik> .. <contacts> section.

       

      How to Install This Sample?

      1. Create a new Sitefinity Web site.
      2. Download the sample code from here.
      3. Copy the App_Code folder from the sample to your Web site.
      4. Copy the Sitefinity.mdf database from App_Data folder from the sample to the App_Data folder in your Web site.
      5. Copy the ContactsModule folder from the sample to your folder.
      6. Register the <telerik> .. <contacts> section in your web.config file. It should look like this:
        web.config Copy Code
        <sectionGroup name="telerik">
         

           
        <section name="contacts"
        type= "Samples.Contacts.Configuration.SectionHandler"  requirePermission="false" />
         

        </sectionGroup>
      7. Register the Contacts module with Sitefinity. It should look like this:
        web.confi Copy Code
        <modules>
         

           
        <add type="Sample.Contacts.ContactsModule"/>
         

        </modules>
      8. Declare the <telerik> .. <contacts> section. It should look like this:
        Example Title Copy Code
        <telerik>
         

         
        <contacts defaultProvider="Sitefinity">
           
        <providers>
              
        <clear/>
              
        <add name="Sitefinity"  type="Samples.Contacts.Providers.LinqContactsProvider" visible="true"/>
             
        </providers>
          
        </contacts>
        </
        telerik>
      9. Run the Web site.

      See Also