From 938446cfe56e111c64244edc15493075aa1882f7 Mon Sep 17 00:00:00 2001 From: "Kestas \"Chris\" Kuliukas" Date: Wed, 30 Oct 2019 04:09:39 +0800 Subject: [PATCH] Allow multiple DesktopModules per PackageID By allowing a DesktopModule to have an explicit FriendlyName and Description set by the install manifest, instead of using the Package FriendlyName and Description, allows multiple DesktopModules per Package Fixes #2887 Reimplementation of #2887 and #2886 --- .../Entities/Modules/DesktopModuleInfo.cs | 6 + .../Installer/Installers/ModuleInstaller.cs | 117 ++++++++++-------- 2 files changed, 70 insertions(+), 53 deletions(-) diff --git a/DNN Platform/Library/Entities/Modules/DesktopModuleInfo.cs b/DNN Platform/Library/Entities/Modules/DesktopModuleInfo.cs index 78c97144789..60f392a033f 100644 --- a/DNN Platform/Library/Entities/Modules/DesktopModuleInfo.cs +++ b/DNN Platform/Library/Entities/Modules/DesktopModuleInfo.cs @@ -409,6 +409,12 @@ public void ReadXml(XmlReader reader) case "moduleName": this.ModuleName = reader.ReadElementContentAsString(); break; + case "friendlyName": + this.FriendlyName = reader.ReadElementContentAsString(); + break; + case "description": + this.Description = reader.ReadElementContentAsString(); + break; case "foldername": this.FolderName = reader.ReadElementContentAsString(); break; diff --git a/DNN Platform/Library/Services/Installer/Installers/ModuleInstaller.cs b/DNN Platform/Library/Services/Installer/Installers/ModuleInstaller.cs index f5186859c6a..44b81ea8ea0 100644 --- a/DNN Platform/Library/Services/Installer/Installers/ModuleInstaller.cs +++ b/DNN Platform/Library/Services/Installer/Installers/ModuleInstaller.cs @@ -3,19 +3,19 @@ // See the LICENSE file in the project root for more information namespace DotNetNuke.Services.Installer.Installers { - using System; - using System.IO; - using System.Xml.XPath; - - using DotNetNuke.Common; - using DotNetNuke.Common.Utilities; - using DotNetNuke.Entities.Modules; - using DotNetNuke.Entities.Modules.Definitions; - using DotNetNuke.Entities.Portals; - using DotNetNuke.Entities.Tabs; - using DotNetNuke.Entities.Tabs.TabVersions; - using DotNetNuke.Security.Permissions; - using DotNetNuke.Services.EventQueue; +using System; +using System.IO; +using System.Xml.XPath; + +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Modules.Definitions; +using DotNetNuke.Entities.Portals; +using DotNetNuke.Entities.Tabs; +using DotNetNuke.Entities.Tabs.TabVersions; +using DotNetNuke.Security.Permissions; +using DotNetNuke.Services.EventQueue; /// ----------------------------------------------------------------------------- /// @@ -27,8 +27,8 @@ namespace DotNetNuke.Services.Installer.Installers public class ModuleInstaller : ComponentInstallerBase { private DesktopModuleInfo _desktopModule; - private EventMessage _eventMessage; - private DesktopModuleInfo _installedDesktopModule; + private EventMessage _eventMessage; + private DesktopModuleInfo _installedDesktopModule; /// ----------------------------------------------------------------------------- /// @@ -169,53 +169,64 @@ public override void Install() this.Log.AddFailure(ex); } } - - /// ----------------------------------------------------------------------------- - /// - /// The ReadManifest method reads the manifest file for the Module compoent. - /// - /// ----------------------------------------------------------------------------- - public override void ReadManifest(XPathNavigator manifestNav) - { + + /// ----------------------------------------------------------------------------- + /// + /// The ReadManifest method reads the manifest file for the Module compoent. + /// + /// ----------------------------------------------------------------------------- + public override void ReadManifest(XPathNavigator manifestNav) + { // Load the Desktop Module from the manifest this._desktopModule = CBO.DeserializeObject(new StringReader(manifestNav.InnerXml)); - - this._desktopModule.FriendlyName = this.Package.FriendlyName; - this._desktopModule.Description = this.Package.Description; - this._desktopModule.Version = Globals.FormatVersion(this.Package.Version, "00", 4, "."); - this._desktopModule.CompatibleVersions = Null.NullString; - this._desktopModule.Dependencies = Null.NullString; - this._desktopModule.Permissions = Null.NullString; - if (string.IsNullOrEmpty(this._desktopModule.BusinessControllerClass)) - { - this._desktopModule.SupportedFeatures = 0; + + // Allow a (i.e. a DesktopModule) to have its own friendlyname / description. + // This allows multiple DesktopModules in one Package, allowing large MVC packages which share one assembly + // but have many functions. + if (this._desktopModule.FriendlyName == null || this._desktopModule.FriendlyName.Trim().Length == 0) + { + this._desktopModule.FriendlyName = this.Package.FriendlyName; + } + + if (this._desktopModule.Description == null || this._desktopModule.Description.Trim().Length == 0) + { + this._desktopModule.Description = this.Package.Description; } - + + this._desktopModule.Version = Globals.FormatVersion(this.Package.Version, "00", 4, "."); + this._desktopModule.CompatibleVersions = Null.NullString; + this._desktopModule.Dependencies = Null.NullString; + this._desktopModule.Permissions = Null.NullString; + if (string.IsNullOrEmpty(this._desktopModule.BusinessControllerClass)) + { + this._desktopModule.SupportedFeatures = 0; + } + this._eventMessage = this.ReadEventMessageNode(manifestNav); - + // Load permissions (to add) - foreach (XPathNavigator moduleDefinitionNav in manifestNav.Select("desktopModule/moduleDefinitions/moduleDefinition")) - { - string friendlyName = Util.ReadElement(moduleDefinitionNav, "friendlyName"); - foreach (XPathNavigator permissionNav in moduleDefinitionNav.Select("permissions/permission")) - { - var permission = new PermissionInfo(); - permission.PermissionCode = Util.ReadAttribute(permissionNav, "code"); - permission.PermissionKey = Util.ReadAttribute(permissionNav, "key"); - permission.PermissionName = Util.ReadAttribute(permissionNav, "name"); + foreach (XPathNavigator moduleDefinitionNav in manifestNav.Select("desktopModule/moduleDefinitions/moduleDefinition")) + { + string friendlyName = Util.ReadElement(moduleDefinitionNav, "friendlyName"); + foreach (XPathNavigator permissionNav in moduleDefinitionNav.Select("permissions/permission")) + { + var permission = new PermissionInfo(); + permission.PermissionCode = Util.ReadAttribute(permissionNav, "code"); + permission.PermissionKey = Util.ReadAttribute(permissionNav, "key"); + permission.PermissionName = Util.ReadAttribute(permissionNav, "name"); ModuleDefinitionInfo moduleDefinition = this._desktopModule.ModuleDefinitions[friendlyName]; - if (moduleDefinition != null) - { - moduleDefinition.Permissions.Add(permission.PermissionKey, permission); - } - } - } + if (moduleDefinition != null) + { + moduleDefinition.Permissions.Add(permission.PermissionKey, permission); + } + } + } if (this.Log.Valid) - { + { this.Log.AddInfo(Util.MODULE_ReadSuccess); - } - } + } + } /// ----------------------------------------------------------------------------- ///