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.

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

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 Aug 25, 2010 at 5:04 PM by proeder, version 4

Comments

No comments yet.