Working with configurations

The editor needs a valid configuration file and a valid toolbar file in order to work. So on loading the editor on a given page a few checks are done to determine what configuration and what toolfile to load. First of all it should be noted that config- and toolbar files are stored in the provider's directory, e.g. Desktopmodules/dnnWerk.RadEditorProvider. Configuration files are stored in the /ConfigFile subfolder and toolbar configurations are stored in the /ToolsFile subfolder there.

You can have dedicated configuration sets for four pre-defined user groups in a portal:
  • Everyone
  • Registered Users
  • Administrators
  • Hosts

where each of those group configurations can also be bound to a given page within a portal.

A typical use case for this feature would be that a registered users in a discussion forum will have a more limited toolbar set than administrators. Or think of a contact form on a portal page that you want to use the HTML editor for. That would be make a use case for an extremly limited toolbar configuration.

If you want to create a new configuration for a given group within your portal, follow the steps below:
  1. Select an existing configuration set to start with from the tree in the left column
  2. Click on Copy Selected
  3. In the option list Bind To Role select the target group that the config set is for
  4. if the config set should only be available on a given page in your portal, make sure that Bind to current Portal is unchecked, then select a page from the pages tree that is being displayed. If Bind to current Portal is checked, the config set will be valid for the whole portal. if Bind to current Portal is unchecked and no page is being selected in the pages tree, that set is valid for the whole installation, e.g. all portals in your installation.
  5. Click on Create

You can delete a configuration set by selecting it from the tree in the left column and clicking on Delete in the top toolbar. Note that you cannot delete the Everyone configuration set as this is the default set is loaded if no other set is being found.

WorkingWithConfig.jpg

The config files have structure like this:

ConfigFile.Host.PortalId.0.xml (this would be a config file for host useres used in the portal with the id 0)
ConfigFile.Registered.xml (a config file for all registered users)

ToolsFile.Admin.TabId.36.xml (a toolbar file for admins, used only on the tab with ID 36)
ToolsFile.TabId.59.xml (a toolbar file for everyone, used only on the tab with ID 59)

So what is exactly happening when the editor is loaded?


If the current user is a host user, the provider checks if...
... there is config file for the current tab that is only for hosts
... there is a config file for the current portal that is only for host
... there is a config file for hosts

If the current user is an admin user, the provider checks if...
... there is config file for the current tab that is only for admins
... there is a config file for the current portal that is only for admins
... there is a config file for admins

If the current user is a registered user, the provider checks if...
... there is config file for the current tab that is only for registered users
... there is a config file for the current portal that is only for registered users
... there is a config file for registered users

If none of the above apply another check is done to see if...
... there is a config for the current tab
... there is a config file for the current portal

If still no config has been found, the default configuration is used to load the editor (e.g. ToolsFile.xml and ConfigFile.xml)


        Public ReadOnly Property ConfigFile() As String
            Get
                'get current user
                Dim objUserInfo As UserInfo = UserController.GetCurrentUserInfo
                'load default tools file
                Dim tempConfigFile As String = _configFile
                'get absolute path of default tools file
                Dim path As String = HttpContext.Current.Server.MapPath(tempConfigFile).ToLower

                Dim rolepath As String = ""
                Dim tabpath As String = ""
                Dim portalpath As String = ""

                'lookup host specific config file
                If Not objUserInfo Is Nothing Then

                    If objUserInfo.IsSuperUser Then


                        rolepath = path.Replace(".xml", ".Host.xml")
                        tabpath = path.Replace(".xml", ".Host.TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                        portalpath = path.Replace(".xml", ".Host.PortalId." & PortalSettings.PortalId.ToString & ".xml")

                        If System.IO.File.Exists(tabpath) Then
                            Return tempConfigFile.ToLower.Replace(".xml", ".Host.TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                        End If
                        If System.IO.File.Exists(portalpath) Then
                            Return tempConfigFile.ToLower.Replace(".xml", ".Host.PortalId." & PortalSettings.PortalId.ToString & ".xml")
                        End If
                        If System.IO.File.Exists(rolepath) Then
                            Return tempConfigFile.ToLower.Replace(".xml", ".Host.xml")
                        End If

                    End If

                End If

                'lookup admin specific config file
                If (DotNetNuke.Security.PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)) Then

                    rolepath = path.Replace(".xml", ".Admin.xml")
                    tabpath = path.Replace(".xml", ".Admin.TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                    portalpath = path.Replace(".xml", ".Admin.PortalId." & PortalSettings.PortalId.ToString & ".xml")

                    If System.IO.File.Exists(tabpath) Then
                        Return tempConfigFile.ToLower.Replace(".xml", ".Admin.TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                    End If
                    If System.IO.File.Exists(portalpath) Then
                        Return tempConfigFile.ToLower.Replace(".xml", ".Admin.PortalId." & PortalSettings.PortalId.ToString & ".xml")
                    End If
                    If System.IO.File.Exists(rolepath) Then
                        Return tempConfigFile.ToLower.Replace(".xml", ".Admin.xml")
                    End If

                End If

                'lookup registered users specific config file
                If (DotNetNuke.Security.PortalSecurity.IsInRole(PortalSettings.RegisteredRoleName)) Then

                    rolepath = path.Replace(".xml", ".Registered.xml")
                    tabpath = path.Replace(".xml", ".Registered.TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                    portalpath = path.Replace(".xml", ".Registered.PortalId." & PortalSettings.PortalId.ToString & ".xml")

                    If System.IO.File.Exists(tabpath) Then
                        Return tempConfigFile.ToLower.Replace(".xml", ".Registered.TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                    End If
                    If System.IO.File.Exists(portalpath) Then
                        Return tempConfigFile.ToLower.Replace(".xml", ".Registered.PortalId." & PortalSettings.PortalId.ToString & ".xml")
                    End If
                    If System.IO.File.Exists(rolepath) Then
                        Return tempConfigFile.ToLower.Replace(".xml", ".Registered.xml")
                    End If

                End If

                'lookup tab specific config file
                tabpath = path.Replace(".xml", ".TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                If System.IO.File.Exists(tabpath) Then
                    Return tempConfigFile.ToLower.Replace(".xml", ".TabId." & PortalSettings.ActiveTab.TabID.ToString & ".xml")
                End If

                'lookup portal specific config file
                portalpath = path.Replace(".xml", ".PortalId." & PortalSettings.PortalId.ToString & ".xml")
                If System.IO.File.Exists(portalpath) Then
                    Return tempConfigFile.ToLower.Replace(".xml", ".PortalId." & PortalSettings.PortalId.ToString & ".xml")
                End If

                'nothing else found, return default file
                Return tempConfigFile

            End Get
        End Property

Last edited Sep 6, 2010 at 1:35 PM by proeder, version 8

Comments

No comments yet.