Skip to content

Commit

Permalink
Merge pull request #4811 from bdukes/multiple-desktop-modules-per-pac…
Browse files Browse the repository at this point in the history
…kage

Allow multiple DesktopModules per PackageID
  • Loading branch information
valadas authored Sep 6, 2021
2 parents 81084a3 + 938446c commit 33a41a7
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 53 deletions.
6 changes: 6 additions & 0 deletions DNN Platform/Library/Entities/Modules/DesktopModuleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
117 changes: 64 additions & 53 deletions DNN Platform/Library/Services/Installer/Installers/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// -----------------------------------------------------------------------------
/// <summary>
Expand All @@ -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;

/// -----------------------------------------------------------------------------
/// <summary>
Expand Down Expand Up @@ -169,53 +169,64 @@ public override void Install()
this.Log.AddFailure(ex);
}
}

/// -----------------------------------------------------------------------------
/// <summary>
/// The ReadManifest method reads the manifest file for the Module compoent.
/// </summary>
/// -----------------------------------------------------------------------------
public override void ReadManifest(XPathNavigator manifestNav)
{

/// -----------------------------------------------------------------------------
/// <summary>
/// The ReadManifest method reads the manifest file for the Module compoent.
/// </summary>
/// -----------------------------------------------------------------------------
public override void ReadManifest(XPathNavigator manifestNav)
{
// Load the Desktop Module from the manifest
this._desktopModule = CBO.DeserializeObject<DesktopModuleInfo>(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 <component type="Module"> (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);
}
}
}
}

/// -----------------------------------------------------------------------------
/// <summary>
Expand Down

0 comments on commit 33a41a7

Please sign in to comment.