DNN Provider 4.0 - Customize Toolbar by Role?

Last post 11-13-2006, 9:16 PM by Adam. 65 replies.
Page 1 of 4 (66 items)   1 2 3 4 Next >
Sort Posts: Previous Next
  •  02-10-2005, 10:30 AM 4032

    DNN Provider 4.0 - Customize Toolbar by Role?

    I am evaluating the DotNetNuke Provider 4.0. What I really want to be able to do is to have a different set of toolbar buttons appear for different DNN user groups. For example, administrators would get the full set of buttons, group X would loose the table buttons, group Y would only have the B U I buttons.
     
    I can see that it is possible to configure different toolbar layouts, but how can this be tied to the DNN user group? If this would involve modifying the code of the provider, please give me clear instructions as I am a junior programmer!
     
    Thanks
  •  02-10-2005, 10:55 AM 4034 in reply to 4032

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

     
    Yes, you can have different set of tool buttons appear fro different DNN role.  You have to modify the code of the provider.
     
    Please follow the steps:
     
    1. Create s function IsCurrentUserInRole in the CEHtmlEditorProvider.vb
     
    IsCurrentUserInRole Public Shared Function IsCurrentUserInRole(ByRef roleName As String) As Boolean
                If (roleName = "" Or System.Web.HttpContext.Current.User.Identity.Name = "") Then
                    Return False
                End If
                Dim _portalSettings As PortalSettings = CType(System.Web.HttpContext.Current.Items("PortalSettings"), PortalSettings)
                Dim objUsers As UserController = New UserController
                Dim objUser As UserInfo = objUsers.GetUser(_portalSettings.PortalId, Int32.Parse(Current.User.Identity.Name))
                Dim _roleController As RoleController = New RoleController
                Dim str As String() = _roleController.GetRolesByUser(objUser.UserID, _portalSettings.PortalId)
                Dim isInRole As Boolean = False
                Dim strInfo As String
                For Each strInfo In str
                    If (rInfo.RoleName() = roleName) Then
                        isInRole = True
                    End If
                Next
                Return isInRole
            End Function
     
    2. In the Public Sub New() .. End Sub, add the following code:
     
    Title
    cntlCE.SecurityPolicyFile = "Guest.config"

    If IsCurrentUserInRole("Administrators") = True Then
        cntlCE.SecurityPolicyFile = "Admin.config"
    ElseIf IsCurrentUserInRole("Site Editor") = True Then
        cntlCE.SecurityPolicyFile = "default.config"
    ElseIf IsCurrentUserInRole("Registered Users") = True Then
        cntlCE.SecurityPolicyFile = "Default.config"
    End If

    Hope it helps. Keep me posted.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  02-10-2005, 2:50 PM 4042 in reply to 4032

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Thanks for replying so quckly !

     
    I got the idea here and I think we want to be specifying an AutoConfigure option rather than a Security config file, in order to configure the toolbars, right?
     
    I modified your code a little, however I have a problem - I am always getting the same configuration, no matter which of my three groups I put my test user in. How come the code isn't detecting the group?
     
    Here's my code:
     
            Public Sub New()

                .........

                If IsCurrentUserInRole("Full HTML Editor") = True Then
                    cntlCE.AutoConfigure = AutoConfigure.Full
                ElseIf IsCurrentUserInRole("Default HTML Editor") = True Then
                    cntlCE.AutoConfigure = AutoConfigure.Simple
                ElseIf IsCurrentUserInRole("Minimal HTML Editor") = True Then
                    cntlCE.AutoConfigure = AutoConfigure.Minimal
                Else
                    cntlCE.AutoConfigure = AutoConfigure.Simple
                End If
                Me.HtmlEditorControl = cntlCE
            End Sub

            'Detect the DNN Role the current user is in
            Public Shared Function IsCurrentUserInRole(ByRef roleName As String) As Boolean
                If (roleName = "" Or System.Web.HttpContext.Current.User.Identity.Name = "") Then
                    Return False
                End If
                Dim _portalSettings As PortalSettings = CType(System.Web.HttpContext.Current.Items("PortalSettings"), PortalSettings)
                Dim objUsers As UserController = New UserController
                Dim objUser As UserInfo = objUsers.GetUser(_portalSettings.PortalId, Int32.Parse(HttpContext.Current.User.Identity.Name))
                Dim _roleController As RoleController = New RoleController
                Dim str As String() = _roleController.GetRolesByUser(objUser.UserID, _portalSettings.PortalId)
                Dim isInRole As Boolean = False
                Dim strInfo As String
                For Each strInfo In str
                    If (strInfo = roleName) Then
                        isInRole = True
                    End If
                Next
                Return isInRole
            End Function
  •  02-10-2005, 2:57 PM 4043 in reply to 4042

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

  •  02-10-2005, 6:46 PM 4050 in reply to 4032

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    I am using DNN 2.1.2
  •  02-10-2005, 8:23 PM 4051 in reply to 4050

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    I checked the DNN code again. I think the following code will resolve the problem.
     

     

    Title

    Public Shared Function IsCurrentUserInRole(ByRef roleName As String) As Boolean

        If (roleName = "" Or System.Web.HttpContext.Current.User.Identity.Name = "") Then

            Return False

        End If

        Dim _portalSettings As PortalSettings = CType(System.Web.HttpContext.Current.Items("PortalSettings"), PortalSettings)

        Dim objUsers As UserController = New UserController

        Dim objUser As UserInfo = objUsers.GetUser(_portalSettings.PortalId, Int32.Parse(HttpContext.Current.User.Identity.Name))

        Dim _roleController As RoleController = New RoleController

        Dim _roleinfo As RoleInfo = New RoleInfo

        Dim str As String() = _roleController.GetRolesByUser(objUser.UserID, _portalSettings.PortalId)

        Dim isInRole As Boolean = False

        Dim strInfo As String

        For Each strInfo In str

            _roleinfo = _roleController.GetRole(Int32.Parse(strInfo))

            If (_roleinfo.RoleName = roleName) Then

                isInRole = True

               Exit For

            End If

        Next

        Return isInRole

    End Function


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  02-11-2005, 9:05 AM 4054 in reply to 4032

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Perfect! This is now working exactly as needed. Thanks again.
  •  04-07-2005, 9:22 AM 5427 in reply to 4054

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    I have the same requirement, but I would not even consider myself a Jr. Programer.

    Is there a way a package could be made available for DNN that would have pre-determined configurable roles?

    As it is now it appears that I can have multiple configs for any role I wish, but I need to do a re-compile.
    Each portal already has the Administrators and Registered Users roles. Make the Registered Users role the lowest on the scale. If you added another generic role, say Site Staff CS, then a easily configurable deployment package could be created. And it would not require a recompile. Even non-programers like me could make it work because all we would need to do is add the appropriate roles and edit the config file.
     
    This would really make the editor appealing to many DNN users who are looking for an alternative to FTB.
     
    Thanks.
  •  04-07-2005, 1:54 PM 5448 in reply to 5427

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    jhoelz,
     
    Thanks for the good point.
     
    We will adjust the provider and provide this solution.
     
    The new provider should be available tomorrow.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-07-2005, 2:23 PM 5454 in reply to 5448

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Adam,
     
    As a new user I hope you don't think I being too pushy, but If I have been thinking about this and would like to make a suggestion, or two
     
    If you make the Administrator Role and the Registered User role as defaults then if the additional Roles can not be matched to exisiting, already created roles make the roles for use with CS named as CS Advanced, CS Normal, or something that would denote them as roles specifically for CS with a consistant prefix so they will be grouped in the Role Manager together.
     
    Make sense?
  •  04-07-2005, 4:50 PM 5459 in reply to 5454

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Man... who is this Adam guy??  lol.
     
    Just because of him, my decision as to which editor to use in DNN to replace that crappy FTB was made entirely too easy.
     
    Not to mention, it has templates... lol.  Templates are king. 
  •  04-08-2005, 8:00 AM 5462 in reply to 5459

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Guys,
     
    The new provider for DNN 3.x is done.

    Please download the control from:
     
     
    With this new provider, we fully integrated the Cute Editor with DNN 3.0 security roles.

    Typical Scenarios:

    Case I:

    You have a commuinity site.  You allow all the users post and input the new content in a particular module.

    But you want to have set some toolbar limitations based on the user roles.

     1.  The admins should have access to all the editor toolbars.
     2.  The registed users should have access to some simple editor toolbars.
     3.  The visitors should read only.

    You can achieved this using the editor configurations below:

     <add name="CEHtmlEditorProvider"
            type="DotNetNuke.HtmlEditor.CEHtmlEditorProvider, DotNetNuke.CEHtmlEditorProvider"
            providerPath="~\Providers\HtmlEditorProviders\CEHtmlEditorProvider\CuteSoft_Client\CuteEditor\" 
            Admin_AutoConfigure = "Full"
            Registered_AutoConfigure = "Simple"
            Guest_ReadOnly = "true"
     />        
    </providers>


    Case 2: 

    You have a commuinity site.  You allow all the users post and input the new content in a particular module.

    However in this case you want to control user access to the server resources.

     1.  The admins/registed users/visitors should have different image/document/flash/media folder. 
     2.  The admins can upload files/delete files/create folders/delete folders.
     3.  The registed users can upload files but can't delete files/create folders/delete folders. 
     4.  The visitors users can use the existing images/flashes/medias/documents, but can't upload files/delete files/create folders/delete folders.
     5.  The registed users can't upload more than 200k files. The max image dimension restriction is 640X 480.
     5.  The registed users can only upload *.gif, *.jpg,*.doc.*.zip files.

    .........

    You can achieved this using the following steps:

    1. Modify your editor configurations and Map Each role to a specific security policy file:

     <add name="CEHtmlEditorProvider"
            type="DotNetNuke.HtmlEditor.CEHtmlEditorProvider, DotNetNuke.CEHtmlEditorProvider"
            providerPath="~\Providers\HtmlEditorProviders\CEHtmlEditorProvider\CuteSoft_Client\CuteEditor\" 
            Admin_SecurityPolicyFile = "admin.config"
            Registered_SecurityPolicyFile= "member.config"
            Guest_SecurityPolicyFile= "guest.config"
     />        
    </providers>

    2. Create your own security policy files or edit the existing security policy file.


    Admin.configmember.configguest.config
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <security name="RestrictUploadedImageDimension">false</security>
     <security name="AutoResizeUploadedImages">false</security>
     <security name="MaxImageWidth">6400</security>
     <security name="MaxImageHeight">4800</security>
     <security name="MaxImageSize">10000</security>
     <security name="MaxMediaSize">10000</security>
     <security name="MaxFlashSize">1000</security>
     <security name="MaxDocumentSize">10000</security>
     <security name="ImageGalleryPath">~/Admins</security>
     <security name="MediaGalleryPath">~/Admins</security>
     <security name="FlashGalleryPath">~/Admins</security>
     <security name="FilesGalleryPath">~/Admins</security>
     <security name="ThumbnailWidth">80</security>
     <security name="ThumbnailHeight">80</security>
     <security name="ThumbnailColumns">5</security>
     <security name="ThumbnailRows">3</security>
     <security name="AllowUpload">true</security>
     <security name="AllowDelete">true</security>
     <security name="AllowCopy">true</security>
     <security name="AllowMove">true</security <security name="AllowCreateFolder">true</security>
     <security name="AllowDeleteFolder">true</security>
     <security name="ImageFilters">
      <item>.jpg</item>
      <item>.jpeg</item>
      <item>.gif</item>
      <item>.png</item>
     </security>
     <security name="MediaFilters">
      <item>.avi</item>
      <item>.mpg</item>
      <item>.mpeg</item>
      <item>.mp3</item>
     </security>
     <security name="DocumentFilters">
      <item>.txt</item>
      <item>.doc</item>
      <item>.pdf</item>
      <item>.zip</item>
      <item>.rar</item>
      <item>.avi</item>
      <item>.mpg</item>
      <item>.mpeg</item>
      <item>.mp3</item>
      <item>.jpg</item>
      <item>.jpeg</item>
      <item>.gif</item>
      <item>.png</item>
     </security>
    </configuration>
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <security name="RestrictUploadedImageDimension">true</security>
     <security name="AutoResizeUploadedImages">true</security>
     <security name="MaxImageWidth">640</security>
     <security name="MaxImageHeight">480</security>
     <security name="MaxImageSize">200</security>
     <security name="MaxMediaSize">200</security>
     <security name="MaxFlashSize">200</security>
     <security name="MaxDocumentSize">200</security>
     <security name="ImageGalleryPath">~/member</security>
     <security name="MediaGalleryPath">~/member</security>
     <security name="FlashGalleryPath">~/member</security>
     <security name="FilesGalleryPath">~/member</security>
     <security name="ThumbnailWidth">80</security>
     <security name="ThumbnailHeight">80</security>
     <security name="ThumbnailColumns">5</security>
     <security name="ThumbnailRows">3</security>
     <security name="AllowUpload">true</security>
     <security name="AllowDelete">false</security>
     <security name="AllowCopy">false</security>
     <security name="AllowMove">false</security>  <security name="AllowCreateFolder">false</security>
     <security name="AllowDeleteFolder">false</security>
     <security name="ImageFilters">
      <item>.jpg</item>
      <item>.jpeg</item>
      <item>.gif</item>
      <item>.png</item>
     </security>
     <security name="MediaFilters">
      <item>.avi</item>
      <item>.mpg</item>
      <item>.mpeg</item>
      <item>.mp3</item>
     </security>
     <security name="DocumentFilters">
      <item>.doc</item>
      <item>.zip</item>
     </security>
    </configuration>
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <security name="RestrictUploadedImageDimension">true</security>
     <security name="AutoResizeUploadedImages">false</security>
     <security name="MaxImageWidth">1</security>
     <security name="MaxImageHeight">1</security>
     <security name="MaxImageSize">1</security>
     <security name="MaxMediaSize">1</security>
     <security name="MaxFlashSize">1</security>
     <security name="MaxDocumentSize">1</security>
     <security name="ImageGalleryPath">~/guest</security>
     <security name="MediaGalleryPath">~/guest</security>
     <security name="FlashGalleryPath">~/guest</security>
     <security name="FilesGalleryPath">~/guest</security>
     <security name="ThumbnailWidth">80</security>
     <security name="ThumbnailHeight">80</security>
     <security name="ThumbnailColumns">5</security>
     <security name="ThumbnailRows">3</security>
     <security name="AllowUpload">false</security>
     <security name="AllowDelete">false</security>
     <security name="AllowCopy">false</security>
     <security name="AllowMove">false</security>
     <security name="AllowCreateFolder">false</security>
     <security name="AllowDeleteFolder">false</security>
     <security name="ImageFilters">
      <item>.jpg</item>
      <item>.jpeg</item>
      <item>.gif</item>
      <item>.png</item>
     </security>
     <security name="MediaFilters">
      <item>.avi</item>
      <item>.mpg</item>
      <item>.mpeg</item>
      <item>.mp3</item>
     </security>
     <security name="DocumentFilters">
      <item>.doc</item>
      <item>.zip</item>
    </configuration>

    Let me know if you have any questions or inputs.






     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-08-2005, 8:22 AM 5467 in reply to 5462

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Looks fantastic!

    Downloading and Installing now.

    Thanks!

  •  04-08-2005, 8:52 AM 5468 in reply to 5467

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Admin works great.
     
    Registered user gives me this...
     
     

    Server Error in '/' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.] DotNetNuke.Security.PortalSecurity.HasNecessaryPermission(SecurityAccessLevel AccessLevel, PortalSettings PortalSettings, ModuleInfo ModuleConfiguration, String UserName) +185 DotNetNuke.UI.Containers.ActionButton.Page_Load(Object sender, EventArgs e) +294 [ModuleLoadException: An error has occurred.] DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(String FriendlyMessage, Control UserCtrl, Exception exc) +292 DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(Control UserCtrl, Exception exc) +27 DotNetNuke.UI.Containers.ActionButton.Page_Load(Object sender, EventArgs e) +1447 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Control.LoadRecursive() +98 System.Web.UI.Page.ProcessRequestMain() +750 [PageLoadException: An error has occurred.] DotNetNuke.Services.Exceptions.Exceptions.ProcessPageLoadException(Exception exc, String URL) +344 DotNetNuke.Framework.PageBase.Page_Error(Object Source, EventArgs e) +363 System.Web.UI.TemplateControl.OnError(EventArgs e) +109 System.Web.UI.Page.HandleError(Exception e) +68 System.Web.UI.Page.ProcessRequestMain() +2100 System.Web.UI.Page.ProcessRequest() +218 System.Web.UI.Page.ProcessRequest(HttpContext context) +18 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
     
    I'll play with it a bit.
     
    One other note... Remember to create the folders for your uploads per role.
  •  04-08-2005, 9:15 AM 5469 in reply to 5468

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    With both senarios Admin logins work fine, but I get the same error as above when trying to edit as a registered user.

    Am I missing something?

  •  04-08-2005, 9:24 AM 5471 in reply to 5469

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Line 40 of Guest config is missing the closing tag.
     
    FYI
     
    Still can't get registered users to work...
  •  04-08-2005, 9:36 AM 5473 in reply to 5469

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Sorry to be such a pain, but I have another.
     
    The security roles for guest are set to restrict access to "guest" folder, yet they can see all folders back to root.
     
    Also, I would guess that you should be able to combine both configs so that you can control access to resources AND tool bars, yet if I add Guest_AutoConfigure="simple.config" it seems to have no impact.
     
    I'm sure it's me missing something simple, but any help would be appreciated.
     
    Just to confirm I have this right...
     
    <htmlEditor defaultProvider="CEHtmlEditorProvider" >
                <providers>
       <clear/>
                   <add name="CEHtmlEditorProvider"
             type="DotNetNuke.HtmlEditor.CEHtmlEditorProvider, DotNetNuke.CEHtmlEditorProvider"
             providerPath="~\Providers\HtmlEditorProviders\CEHtmlEditorProvider\CuteSoft_Client\CuteEditor\" 
             Admin_SecurityPolicyFile = "admin.config"
             Registered_Users_SecurityPolicyFile= "member.config"
             Guest_SecurityPolicyFile= "guest.config"
             Guest_AutoConfigure="simple" />        
     </providers>
             </htmlEditor>
  •  04-08-2005, 9:44 AM 5474 in reply to 5473

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    Something odd is going on.
     
    If I give "Unauthenticated" users edit permission on a text html module, they can edit it with the editor, but if they want to insert an image they can see all the way back to root.
     
    If logged in as administrator you can only see the "uploads" folder.
  •  04-08-2005, 1:29 PM 5482 in reply to 5474

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

    I've uploaded the wrong file to the server.
     
    I'll fix it in 10 minutes.

    Keep me posted.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-08-2005, 1:37 PM 5483 in reply to 5482

    Re: DNN Provider 4.0 - Customize Toolbar by Role?

Page 1 of 4 (66 items)   1 2 3 4 Next >
View as RSS news feed in XML