I'm using the most current provider. The only modification is to include an additional role as admin. {If Not Isadmin Then Isadmin = IsCurrentUserInRole("EmailBlast")}. I'll include web.config settings in the next post. When I compare this code to the provider I downloaded yesterday (using winmerge), the only difference is the line I added.
I've gone through the documentation again
Imports System.IO
Imports System.Web
Imports DotNetNuke
Imports CuteEditor
Namespace DotNetNuke.HtmlEditor
Public Class CEHtmlEditorProvider
Inherits HtmlEditorProvider
Dim cntlCE As New CuteEditor.Editor
Private Const ProviderType As String = "htmlEditor"
Private _providerConfiguration As ProviderConfiguration = ProviderConfiguration.GetProviderConfiguration(ProviderType)
Private _providerPath As String
Private _editorbodystyle As String = ""
Private _usednnrootimagedirectory As Boolean = True
Private _removeservernamesfromurl As Boolean = False
Private _enablestripscripttags As Boolean = False
Private _removetbodytag As Boolean = False
Private _showcodeviewtoolbar As Boolean = True
Private _userelativelinks As Boolean = False
Private _usesimpleampersand As Boolean = False
Private _renderrichdropdown As Boolean = True
Private _maxhtmllength As Integer = 0
Private _maxtextlength As Integer = 0
Private _customculture As String = ""
Private _disableautoformatting As Boolean = False
Private _disableclasslist As String = ""
Private _helpurl As String = ""
Private _themetype As String = "Office2003_BlueTheme"
Private _breakelement As String = "div"
Private _admin_autoconfigure As String = ""
Private _admin_securitypolicyfile As String = ""
Private _admin_templateitemlist As String = ""
Private _admin_disableitemlist As String = ""
Private _admin_allowpastehtml As Boolean = True
Private _admin_editoronpaste As String = ""
Private _admin_readonly As Boolean = True
Private _admin_showbottombar As Boolean = True
Private _admin_showhtmlmode As Boolean = True
Private _admin_showpreviewmode As Boolean
Private _registered_autoconfigure As String = ""
Private _registered_securitypolicyfile As String = ""
Private _registered_templateitemlist As String = ""
Private _registered_disableitemlist As String = ""
Private _registered_allowpastehtml As Boolean = True
Private _registered_editoronpaste As String = ""
Private _registered_readonly As Boolean = True
Private _registered_showbottombar As Boolean = True
Private _registered_showhtmlmode As Boolean = True
Private _registered_showpreviewmode As Boolean = True
Private _guest_autoconfigure As String = ""
Private _guest_securitypolicyfile As String = ""
Private _guest_templateitemlist As String = ""
Private _guest_disableitemlist As String = ""
Private _guest_allowpastehtml As Boolean = True
Private _guest_editoronpaste As String = ""
Private _guest_readonly As Boolean = True
Private _guest_showbottombar As Boolean = True
Private _guest_showhtmlmode As Boolean = True
Private _guest_showpreviewmode As Boolean = True
Private _temp_autoconfigure As String = ""
Private _temp_securitypolicyfile As String = ""
Private _temp_templateitemlist As String = ""
Private _temp_disableitemlist As String = ""
Private _temp_allowpastehtml As Boolean = True
Private _temp_editoronpaste As String = "ConfirmWord"
Private _temp_readonly As Boolean = True
Private _temp_showbottombar As Boolean = True
Private _temp_showhtmlmode As Boolean = True
Private _temp_showpreviewmode As Boolean = True
Public Sub New()
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
' Read the configuration specific information for this provider
Dim objProvider As Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), Provider)
_providerPath = objProvider.Attributes("providerPath")
If Not IsNull(objProvider.Attributes("UseDNNRootImageDirectory")) Then
_usednnrootimagedirectory = Boolean.Parse(objProvider.Attributes("UseDNNRootImageDirectory"))
End If
If Not IsNull(objProvider.Attributes("RemoveServerNamesFromUrl")) Then
_removeservernamesfromurl = Boolean.Parse(objProvider.Attributes("RemoveServerNamesFromUrl"))
End If
If Not IsNull(objProvider.Attributes("EnableStripScriptTags")) Then
_enablestripscripttags = Boolean.Parse(objProvider.Attributes("EnableStripScriptTags"))
End If
If Not IsNull(objProvider.Attributes("RemoveTBODYTag")) Then
_removetbodytag = Boolean.Parse(objProvider.Attributes("RemoveTBODYTag"))
End If
If Not IsNull(objProvider.Attributes("ShowCodeViewToolBar")) Then
_showcodeviewtoolbar = Boolean.Parse(objProvider.Attributes("ShowCodeViewToolBar"))
End If
If Not IsNull(objProvider.Attributes("UseRelativeLinks")) Then
_userelativelinks = Boolean.Parse(objProvider.Attributes("UseRelativeLinks"))
End If
If Not IsNull(objProvider.Attributes("UseSimpleAmpersand")) Then
_usesimpleampersand = Boolean.Parse(objProvider.Attributes("UseSimpleAmpersand"))
End If
If Not IsNull(objProvider.Attributes("RenderRichDropDown")) Then
_renderrichdropdown = Boolean.Parse(objProvider.Attributes("RenderRichDropDown"))
End If
If Not IsNull(objProvider.Attributes("MaxHTMLLength")) Then
_maxhtmllength = Integer.Parse(objProvider.Attributes("MaxHTMLLength"))
End If
If Not IsNull(objProvider.Attributes("MaxTextLength")) Then
_maxtextlength = Integer.Parse(objProvider.Attributes("MaxTextLength"))
End If
If Not IsNull(objProvider.Attributes("CustomCulture")) Then
_customculture = objProvider.Attributes("CustomCulture")
End If
If Not IsNull(objProvider.Attributes("EditorBodyStyle")) Then
_editorbodystyle = objProvider.Attributes("EditorBodyStyle")
End If
If Not IsNull(objProvider.Attributes("DisableAutoFormatting")) Then
_disableautoformatting = Boolean.Parse(objProvider.Attributes("DisableAutoFormatting"))
End If
If Not IsNull(objProvider.Attributes("DisableClassList")) Then
_disableclasslist = objProvider.Attributes("DisableClassList")
End If
If Not IsNull(objProvider.Attributes("HelpUrl")) Then
_helpurl = objProvider.Attributes("HelpUrl")
End If
If Not IsNull(objProvider.Attributes("ThemeType")) Then
_themetype = objProvider.Attributes("ThemeType")
End If
If Not IsNull(objProvider.Attributes("BreakElement")) Then
_breakelement = objProvider.Attributes("BreakElement")
End If
If Not IsNull(objProvider.Attributes("Admin_AutoConfigure")) Then
_admin_autoconfigure = objProvider.Attributes("Admin_AutoConfigure")
End If
If Not IsNull(objProvider.Attributes("Admin_SecurityPolicyFile")) Then
_admin_securitypolicyfile = objProvider.Attributes("Admin_SecurityPolicyFile")
End If
If Not IsNull(objProvider.Attributes("Admin_TemplateItemList")) Then
_admin_templateitemlist = objProvider.Attributes("Admin_TemplateItemList")
End If
If Not IsNull(objProvider.Attributes("Admin_DisableItemList")) Then
_admin_disableitemlist = objProvider.Attributes("Admin_DisableItemList")
End If
If Not IsNull(objProvider.Attributes("Admin_AllowPasteHtml")) Then
_admin_allowpastehtml = Boolean.Parse(objProvider.Attributes("Admin_AllowPasteHtml"))
End If
If Not IsNull(objProvider.Attributes("Admin_EditorOnPaste")) Then
_admin_editoronpaste = objProvider.Attributes("Admin_EditorOnPaste")
End If
If Not IsNull(objProvider.Attributes("Admin_ReadOnly")) Then
_admin_readonly = Boolean.Parse(objProvider.Attributes("Admin_ReadOnly"))
End If
If Not IsNull(objProvider.Attributes("Admin_ShowBottomBar")) Then
_admin_showbottombar = Boolean.Parse(objProvider.Attributes("Admin_ShowBottomBar"))
End If
If Not IsNull(objProvider.Attributes("Admin_ShowHtmlMode")) Then
_admin_showbottombar = Boolean.Parse(objProvider.Attributes("Admin_ShowHtmlMode"))
End If
If Not IsNull(objProvider.Attributes("Admin_ShowPreviewMode")) Then
_admin_showpreviewmode = Boolean.Parse(objProvider.Attributes("Admin_ShowPreviewMode"))
End If
If Not IsNull(objProvider.Attributes("Registered_AutoConfigure")) Then
_registered_autoconfigure = objProvider.Attributes("Registered_AutoConfigure")
End If
If Not IsNull(objProvider.Attributes("Registered_SecurityPolicyFile")) Then
_registered_securitypolicyfile = objProvider.Attributes("Registered_SecurityPolicyFile")
End If
If Not IsNull(objProvider.Attributes("Registered_TemplateItemList")) Then
_registered_templateitemlist = objProvider.Attributes("Registered_TemplateItemList")
End If
If Not IsNull(objProvider.Attributes("Registered_DisableItemList")) Then
_registered_disableitemlist = objProvider.Attributes("Registered_DisableItemList")
End If
If Not IsNull(objProvider.Attributes("Registered_AllowPasteHtml")) Then
_registered_allowpastehtml = Boolean.Parse(objProvider.Attributes("Registered_AllowPasteHtml"))
End If
If Not IsNull(objProvider.Attributes("Registered_EditorOnPaste")) Then
_registered_editoronpaste = objProvider.Attributes("Registered_EditorOnPaste")
End If
If Not IsNull(objProvider.Attributes("Registered_ReadOnly")) Then
_registered_readonly = Boolean.Parse(objProvider.Attributes("Registered_ReadOnly"))
End If
If Not IsNull(objProvider.Attributes("Registered_ShowBottomBar")) Then
_registered_showbottombar = Boolean.Parse(objProvider.Attributes("Registered_ShowBottomBar"))
End If
If Not IsNull(objProvider.Attributes("Registered_ShowHtmlMode")) Then
_registered_showbottombar = Boolean.Parse(objProvider.Attributes("Registered_ShowHtmlMode"))
End If
If Not IsNull(objProvider.Attributes("Registered_ShowPreviewMode")) Then
_registered_showpreviewmode = Boolean.Parse(objProvider.Attributes("Registered_ShowPreviewMode"))
End If
If Not IsNull(objProvider.Attributes("Guest_AutoConfigure")) Then
_guest_autoconfigure = objProvider.Attributes("Guest_AutoConfigure")
End If
If Not IsNull(objProvider.Attributes("Guest_SecurityPolicyFile")) Then
_guest_securitypolicyfile = objProvider.Attributes("Guest_SecurityPolicyFile")
End If
If Not IsNull(objProvider.Attributes("Guest_TemplateItemList")) Then
_guest_templateitemlist = objProvider.Attributes("Guest_TemplateItemList")
End If
If Not IsNull(objProvider.Attributes("Guest_DisableItemList")) Then
_guest_disableitemlist = objProvider.Attributes("Guest_DisableItemList")
End If
If Not IsNull(objProvider.Attributes("Guest_AllowPasteHtml")) Then
_guest_allowpastehtml = Boolean.Parse(objProvider.Attributes("Guest_AllowPasteHtml"))
End If
If Not IsNull(objProvider.Attributes("Guest_EditorOnPaste")) Then
_guest_editoronpaste = objProvider.Attributes("Guest_EditorOnPaste")
End If
If Not IsNull(objProvider.Attributes("Guest_ReadOnly")) Then
_guest_readonly = Boolean.Parse(objProvider.Attributes("Guest_ReadOnly"))
End If
If Not IsNull(objProvider.Attributes("Guest_ShowBottomBar")) Then
_guest_showbottombar = Boolean.Parse(objProvider.Attributes("Guest_ShowBottomBar"))
End If
If Not IsNull(objProvider.Attributes("Guest_ShowHtmlMode")) Then
_guest_showbottombar = Boolean.Parse(objProvider.Attributes("Guest_ShowHtmlMode"))
End If
If Not IsNull(objProvider.Attributes("Guest_ShowPreviewMode")) Then
_guest_showpreviewmode = Boolean.Parse(objProvider.Attributes("Guest_ShowPreviewMode"))
End If
cntlCE.UseRelativeLinks = _userelativelinks
cntlCE.UseSimpleAmpersand = _usesimpleampersand
cntlCE.RenderRichDropDown = _renderrichdropdown
cntlCE.MaxHTMLLength = _maxhtmllength
cntlCE.MaxTextLength = _maxtextlength
cntlCE.CustomCulture = _customculture
cntlCE.EditorBodyStyle = _editorbodystyle
cntlCE.RemoveServerNamesFromUrl = _removeservernamesfromurl
cntlCE.DisableAutoFormatting = _disableautoformatting
cntlCE.EnableStripScriptTags = _enablestripscripttags
cntlCE.RemoveTBODYTag = _removetbodytag
cntlCE.HelpUrl = _helpurl
Select Case _themetype
Case "Office2003_BlueTheme"
cntlCE.ThemeType = ThemeType.Office2003_BlueTheme
Case "Office2003"
cntlCE.ThemeType = ThemeType.Office2003
Case "OfficeXP"
cntlCE.ThemeType = ThemeType.OfficeXP
Case "Office2000"
cntlCE.ThemeType = ThemeType.Office2000
End Select
Select Case _breakelement
Case "div"
cntlCE.BreakElement = BreakElement.Div
Case "br"
cntlCE.BreakElement = BreakElement.Br
Case "paragraph"
cntlCE.BreakElement = BreakElement.P
End Select
Dim Isadmin, Isregistered As Boolean
' Isadmin = PortalSecurity.IsInRoles("Administrators")
' Isregistered = PortalSecurity.IsInRoles("Registered Users")
Isadmin = IsCurrentUserInRole("Administrators")
If Not Isadmin Then Isadmin = IsCurrentUserInRole("EmailBlast")
Isregistered = IsCurrentUserInRole("Registered Users")
If Isadmin Then
_temp_templateitemlist = _admin_templateitemlist
_temp_disableitemlist = _admin_disableitemlist
_temp_allowpastehtml = _admin_allowpastehtml
_temp_securitypolicyfile = _admin_securitypolicyfile
_temp_readonly = _admin_readonly
_temp_showbottombar = _admin_showbottombar
_temp_showhtmlmode = _admin_showhtmlmode
_temp_showpreviewmode = _admin_showpreviewmode
_temp_editoronpaste = _admin_editoronpaste
ElseIf Isregistered Then
_temp_templateitemlist = _registered_templateitemlist
_temp_disableitemlist = _registered_disableitemlist
_temp_allowpastehtml = _registered_allowpastehtml
_temp_securitypolicyfile = _registered_securitypolicyfile
_temp_readonly = _registered_readonly
_temp_showbottombar = _registered_showbottombar
_temp_showhtmlmode = _registered_showhtmlmode
_temp_showpreviewmode = _registered_showpreviewmode
_temp_editoronpaste = _registered_editoronpaste
_temp_autoconfigure = _registered_autoconfigure
Else
_temp_templateitemlist = _guest_templateitemlist
_temp_disableitemlist = _guest_disableitemlist
_temp_allowpastehtml = _guest_allowpastehtml
_temp_securitypolicyfile = _guest_securitypolicyfile
_temp_readonly = _guest_readonly
_temp_showbottombar = _guest_showbottombar
_temp_showhtmlmode = _guest_showhtmlmode
_temp_showpreviewmode = _guest_showpreviewmode
_temp_editoronpaste = _guest_editoronpaste
_temp_autoconfigure = _guest_autoconfigure
End If
If cntlCE.DisableItemList = "" Then
cntlCE.DisableItemList = "Save"
End If
cntlCE.SecurityPolicyFile = _temp_securitypolicyfile
cntlCE.TemplateItemList = _temp_templateitemlist
cntlCE.DisableItemList = _temp_disableitemlist
cntlCE.AllowPasteHtml = _temp_allowpastehtml
cntlCE.SecurityPolicyFile = _temp_securitypolicyfile
cntlCE.ReadOnly = _temp_readonly
cntlCE.ShowBottomBar = _temp_showbottombar
cntlCE.ShowHtmlMode = _temp_showhtmlmode
cntlCE.ShowPreviewMode = _temp_showpreviewmode
Select Case _temp_editoronpaste
Case "ConfirmWord"
cntlCE.EditorOnPaste = PasteBehavior.ConfirmWord
Case "PasteWord"
cntlCE.EditorOnPaste = PasteBehavior.PasteWord
Case "PasteText"
cntlCE.EditorOnPaste = PasteBehavior.PasteText
Case "Disabled"
cntlCE.EditorOnPaste = PasteBehavior.Disabled
Case Else
cntlCE.EditorOnPaste = PasteBehavior.Default
End Select
Select Case _temp_autoconfigure
Case "Full"
cntlCE.AutoConfigure = AutoConfigure.Full
Case "Full_noform"
cntlCE.AutoConfigure = AutoConfigure.Full_noform
Case "Simple"
cntlCE.AutoConfigure = AutoConfigure.Simple
Case "Minimal"
cntlCE.AutoConfigure = AutoConfigure.Minimal
Case "None"
cntlCE.AutoConfigure = AutoConfigure.None
Case Else
cntlCE.AutoConfigure = AutoConfigure.Minimal
End Select
If _usednnrootimagedirectory = True Then
Dim trim(1) As Char
trim(0) = "/"c
Dim tempfolder As String = "Guest"
If Isadmin Then
tempfolder = ""
ElseIf Isregistered Then
tempfolder = "Member"
End If
tempfolder = _portalSettings.UploadDirectory.TrimEnd(trim) & "/" & tempfolder
Dim phyfolder As String
phyfolder = HttpContext.Current.Server.MapPath(tempfolder)
If Isadmin Then
phyfolder = HttpContext.Current.Server.MapPath(_portalSettings.UploadDirectory.TrimEnd(trim) & "/Admin")
End If
If Not Directory.Exists(phyfolder) Then
Directory.CreateDirectory(phyfolder)
End If
cntlCE.SetSecurityImageGalleryPath(tempfolder)
cntlCE.SetSecurityFilesGalleryPath(tempfolder)
cntlCE.SetSecurityMediaGalleryPath(tempfolder)
cntlCE.SetSecurityFlashGalleryPath(tempfolder)
cntlCE.SetSecurityTemplateGalleryPath(tempfolder)
End If
' If IsCurrentUserInRole("Administrators") = True Then
' cntlCE.AutoConfigure = AutoConfigure.Full
' ElseIf IsCurrentUserInRole("Registered Users") = True Then
' cntlCE.AutoConfigure = AutoConfigure.Full_noform
' Else
' cntlCE.AutoConfigure = AutoConfigure.Simple
' End If
'assign the initialized control as the HtmlEditorControl
Me.HtmlEditorControl = cntlCE
cntlCE.EditorWysiwygModeCss = "~/portal.css"
If cntlCE.DisableClassList = "" Then
cntlCE.DisableClassList = "TabBg,SelectedTab,OtherTabs,ModuleTitle_MenuArrow,ModuleTitle_RootMenuArrow,MainMenu_MenuContainer,MainMenu_MenuIcon,MainMenu_SubMenu,MainMenu_MenuArrow,MainMenu_RootMenuArrow"
End If
cntlCE.FilesPath = ResolveUrl(_providerPath)
cntlCE.DNN_Arg = "portalid=" & _portalSettings.PortalId
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 _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
Public ReadOnly Property ProviderPath() As String
Get
Return _providerPath
End Get
End Property
'The Text, Width, and Height properties are retrieved and set by
'typing the HtmlEditorControl Web.UI.Control to CuteEditor.Editor
'and accessing the FreeTextBox properties Text, Width, and Height
Public Overrides Property Text() As String
Get
Text = CType(Me.HtmlEditorControl, CuteEditor.Editor).Text
End Get
Set(ByVal Value As String)
CType(Me.HtmlEditorControl, CuteEditor.Editor).Text = Value
End Set
End Property
Public Overrides Property Width() As System.Web.UI.WebControls.Unit
Get
Width = CType(Me.HtmlEditorControl, CuteEditor.Editor).Width
End Get
Set(ByVal Value As System.Web.UI.WebControls.Unit)
' CType(Me.HtmlEditorControl, CuteEditor.Editor).Width = Value
End Set
End Property
Public Overrides Property Height() As System.Web.UI.WebControls.Unit
Get
Width = CType(Me.HtmlEditorControl, CuteEditor.Editor).Height
End Get
Set(ByVal Value As System.Web.UI.WebControls.Unit)
CType(Me.HtmlEditorControl, CuteEditor.Editor).Height = Value
End Set
End Property
Public Function ResolveUrl(ByVal url As String) As String
' String is Empty, just return Url
If (url.Length = 0) Then
Return url
End If
' String does not contain a ~, so just return Url
If (url.StartsWith("~") = False) Then
Return url
End If
' There is just the ~ in the Url, return the appPath
If (url.Length = 1) Then
Return Global.ApplicationPath
End If
If (url.ToCharArray()(1) = "/" Or url.ToCharArray()(1) = "\") Then
' Url looks like ~/ or ~\
If (Global.ApplicationPath.Length > 1) Then
Return Global.ApplicationPath + "/" & url.Substring(2)
Else
Return "/" & url.Substring(2)
End If
Else
' Url look like ~something
If (Global.ApplicationPath.Length > 1) Then
Return Global.ApplicationPath & "/" & url.Substring(1)
Else
Return Global.ApplicationPath & url.Substring(1)
End If
End If
End Function
Public Function IsNull(ByVal objField As Object) As Boolean
If Not objField Is Nothing Then
If TypeOf objField Is Integer Then
IsNull = objField.Equals(-1)
ElseIf TypeOf objField Is Single Then
IsNull = objField.Equals(Single.MinValue)
ElseIf TypeOf objField Is Double Then
IsNull = objField.Equals(Double.MinValue)
ElseIf TypeOf objField Is Decimal Then
IsNull = objField.Equals(Decimal.MinValue)
ElseIf TypeOf objField Is Date Then
Dim objDate As DateTime = CType(objField, DateTime)
IsNull = objDate.Date.Equals(Null.NullDate.Date)
ElseIf TypeOf objField Is String Then
IsNull = objField.Equals(Null.NullString)
ElseIf TypeOf objField Is Boolean Then
IsNull = objField.Equals(Null.NullBoolean)
ElseIf TypeOf objField Is Guid Then
IsNull = objField.Equals(Null.NullGuid)
Else ' complex object
IsNull = False
End If
Else
IsNull = True
End If
End Function
End Class
End Namespace