From fe112a7a68a9d62bf4dc85bfa53c93f9da2bdd88 Mon Sep 17 00:00:00 2001
From: Will Strohl
Date: Sat, 12 Feb 2022 16:29:51 -0800
Subject: [PATCH] Version 01.01.00
---
Build/ModulePackage.targets | 1 +
.../App_LocalResources/Global.resx | 21 ++-
Modules/UpendoPrompt/Commands/DebugMode.cs | 173 ++++++++++++++++++
Modules/UpendoPrompt/Commands/PopupMode.cs | 6 +-
Modules/UpendoPrompt/Components/Constants.cs | 15 +-
.../Config/log4net-DebugOff.xml.resources | 6 +
.../Config/log4net-DebugOn.xml.resources | 6 +
.../Config/webConfig-DebugOff.xml.resources | 6 +
.../Config/webConfig-DebugOn.xml.resources | 6 +
Modules/UpendoPrompt/Module.build | 4 +-
.../UpendoPrompt/Properties/AssemblyInfo.cs | 4 +-
.../Upendo.Modules.UpendoPrompt.csproj | 11 +-
Modules/UpendoPrompt/UpendoPrompt.dnn | 6 +-
Modules/UpendoPrompt/UpendoPrompt_Symbols.dnn | 6 +-
Modules/UpendoPrompt/releasenotes.txt | 10 +-
15 files changed, 255 insertions(+), 26 deletions(-)
create mode 100644 Modules/UpendoPrompt/Commands/DebugMode.cs
create mode 100644 Modules/UpendoPrompt/Config/log4net-DebugOff.xml.resources
create mode 100644 Modules/UpendoPrompt/Config/log4net-DebugOn.xml.resources
create mode 100644 Modules/UpendoPrompt/Config/webConfig-DebugOff.xml.resources
create mode 100644 Modules/UpendoPrompt/Config/webConfig-DebugOn.xml.resources
diff --git a/Build/ModulePackage.targets b/Build/ModulePackage.targets
index bae5d90..b81e3b4 100644
--- a/Build/ModulePackage.targets
+++ b/Build/ModulePackage.targets
@@ -58,6 +58,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/Modules/UpendoPrompt/App_LocalResources/Global.resx b/Modules/UpendoPrompt/App_LocalResources/Global.resx
index 7d19b39..5db391b 100644
--- a/Modules/UpendoPrompt/App_LocalResources/Global.resx
+++ b/Modules/UpendoPrompt/App_LocalResources/Global.resx
@@ -117,31 +117,40 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Debugging has been turned off in all areas of the site.
+
+
+ Debugging has been enabled throughout the site. All visitors will experience slow page loads for the next few moments.
+
An error occurred. Please check the log files to find and resolve the issue.
<p>No information at this time.</p>
-
+
Popups have been disabled for {0}.
-
+
Popups have been enabled for {0}.
-
+
+ Allows you to turn on debugging in your site. This method enables debugging in the web.config, site settings, and the Log4Net configuration file.
+
+
Allows you to enable/disable the popup editing feature on the current website or all sites in this installation.
The mode can only be 'enable' or 'disable'. The default is 'disable'.
-
+
Specify whether you want to enable or disable the popups on the specified site(s). Acceptable values include 'enable' and 'disable'.
-
+
Specify whether you want to apply this to only the current site, or all sites. The accepted values include 'current' and 'all'.
-
+
<div>
<h4>Enable or disable popups on the current or all sites</h4>
diff --git a/Modules/UpendoPrompt/Commands/DebugMode.cs b/Modules/UpendoPrompt/Commands/DebugMode.cs
new file mode 100644
index 0000000..7c0b8b5
--- /dev/null
+++ b/Modules/UpendoPrompt/Commands/DebugMode.cs
@@ -0,0 +1,173 @@
+#region License
+
+// Distributed under the MIT License
+// ============================================================
+// Copyright (c) Upendo Ventures, LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+// and associated documentation files (the "Software"), to deal in the Software without restriction,
+// including without limitation the rights to use, copy, modify, merge, publish, distribute,
+// sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all copies or
+// substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+#endregion
+
+using System;
+using System.IO;
+using System.Xml;
+using Dnn.PersonaBar.Library.Helper;
+using Dnn.PersonaBar.Library.Prompt;
+using Dnn.PersonaBar.Library.Prompt.Attributes;
+using Dnn.PersonaBar.Library.Prompt.Models;
+using DotNetNuke.Application;
+using DotNetNuke.Common;
+using DotNetNuke.Common.Utilities;
+using DotNetNuke.Entities.Controllers;
+using DotNetNuke.Entities.Host;
+using DotNetNuke.Entities.Portals;
+using DotNetNuke.Entities.Profile;
+using DotNetNuke.Entities.Users;
+using DotNetNuke.Instrumentation;
+using Upendo.Modules.UpendoPrompt.Components;
+using Constants = Upendo.Modules.UpendoPrompt.Components.Constants;
+
+namespace Upendo.Modules.UpendoPrompt.Commands
+{
+ [ConsoleCommand("debug-mode", Constants.PromptCategory, "PromptDebugMode")]
+ public class DebugMode : PromptBase, IConsoleCommand
+ {
+ private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(DebugMode));
+
+ #region Constants
+
+ private const string WEBCONFIG_DEBUG_ON = "~/DesktopModules/UpendoPrompt/Config/webConfig-DebugOn.xml.resources";
+ private const string WEBCONFIG_DEBUG_OFF = "~/DesktopModules/UpendoPrompt/Config/webConfig-DebugOff.xml.resources";
+
+ private const string LOG4NET_DEBUG_ON = "~/DesktopModules/UpendoPrompt/Config/log4net-DebugOn.xml.resources";
+ private const string LOG4NET_DEBUG_OFF = "~/DesktopModules/UpendoPrompt/Config/log4net-DebugOff.xml.resources";
+
+ private const string CONFIG_EXT = ".config";
+
+ #endregion
+
+ #region Implementation
+
+ public override void Init(string[] args, PortalSettings portalSettings, UserInfo userInfo, int activeTabId)
+ {
+ // do nothing
+ }
+
+ public override ConsoleResultModel Run()
+ {
+ try
+ {
+ var currentState = Host.DebugMode;
+ var newState = !currentState;
+
+ // site debug mode
+ HostController.Instance.Update(Constants.SettingKeys.HostSetting_DebugMode, newState.ToString());
+
+ // web.config debug mode
+ MergeWebConfig(newState);
+
+ // log4net debug mode
+ MergeLog4net(newState);
+
+ var output = string.Empty;
+
+ if (newState)
+ {
+ output = this.LocalizeString(Constants.LocalizationKeys.DebugOn);
+ }
+ else
+ {
+ output = this.LocalizeString(Constants.LocalizationKeys.DebugOff);
+ }
+
+ return new ConsoleResultModel
+ {
+ Output = output
+ };
+ }
+ catch (Exception e)
+ {
+ LogError(e);
+ return new ConsoleErrorResultModel(string.Concat(Constants.OutputPrefix, this.LocalizeString(Constants.LocalizationKeys.ErrorOccurred)));
+ }
+ }
+
+ #endregion
+
+ #region Helpers
+
+ private void MergeWebConfig(bool newState)
+ {
+ var filePath = System.Web.HttpContext.Current.Server.MapPath(newState ? WEBCONFIG_DEBUG_ON : WEBCONFIG_DEBUG_OFF);
+
+ ExecuteMerge(filePath);
+ }
+
+ private void MergeLog4net(bool newState)
+ {
+ var filePath = System.Web.HttpContext.Current.Server.MapPath(newState ? LOG4NET_DEBUG_ON : LOG4NET_DEBUG_OFF);
+
+ ExecuteMerge(filePath);
+ }
+
+ public string GetConfigFile(string configFile)
+ {
+ if (configFile.EndsWith(CONFIG_EXT, StringComparison.InvariantCultureIgnoreCase))
+ {
+ var configDoc = Config.Load(configFile);
+ using (var txtWriter = new StringWriter())
+ {
+ using (var writer = new XmlTextWriter(txtWriter))
+ {
+ writer.Formatting = Formatting.Indented;
+ configDoc.WriteTo(writer);
+ }
+
+ return txtWriter.ToString();
+ }
+ }
+ else
+ {
+ var doc = File.ReadAllText(Path.Combine(Globals.ApplicationMapPath, configFile));
+ return doc;
+ }
+ }
+
+ private void ExecuteMerge(string xmlDoc)
+ {
+ var app = DotNetNukeContext.Current.Application;
+ var merge = new DotNetNuke.Services.Installer.XmlMerge(xmlDoc, Globals.FormatVersion(app.Version), app.Description);
+ merge.UpdateConfigs();
+
+ merge.UpdateConfigs();
+ }
+
+ protected override void LogError(Exception ex)
+ {
+ if (ex != null)
+ {
+ Logger.Error(ex.Message, ex);
+ if (ex.InnerException != null)
+ {
+ Logger.Error(ex.InnerException.Message, ex.InnerException);
+ }
+ }
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Modules/UpendoPrompt/Commands/PopupMode.cs b/Modules/UpendoPrompt/Commands/PopupMode.cs
index df18afe..da589d1 100644
--- a/Modules/UpendoPrompt/Commands/PopupMode.cs
+++ b/Modules/UpendoPrompt/Commands/PopupMode.cs
@@ -100,7 +100,7 @@ public override ConsoleResultModel Run()
{
PortalController.Instance.UpdatePortalSetting(
PortalSettings.PortalId,
- Constants.PortalSettingKeys.PortalSetting_Popups,
+ Constants.SettingKeys.PortalSetting_Popup,
newMode.ToString(),
true,
PortalSettings.CultureCode,
@@ -112,7 +112,7 @@ public override ConsoleResultModel Run()
{
PortalController.Instance.UpdatePortalSetting(
portal.PortalID, // deprecated - REPLACE!!!
- Constants.PortalSettingKeys.PortalSetting_Popups,
+ Constants.SettingKeys.PortalSetting_Popup,
newMode.ToString(),
true,
portal.CultureCode,
@@ -133,7 +133,7 @@ public override ConsoleResultModel Run()
}
else
{
- output = string.Format(this.LocalizeString(Constants.LocalizationKeys.PopupsDisabled), outputScope);
+ output = string.Format(this.LocalizeString(Constants.LocalizationKeys.PopupDisabled), outputScope);
}
return new ConsoleResultModel
diff --git a/Modules/UpendoPrompt/Components/Constants.cs b/Modules/UpendoPrompt/Components/Constants.cs
index 2e2a36d..9b7695e 100644
--- a/Modules/UpendoPrompt/Components/Constants.cs
+++ b/Modules/UpendoPrompt/Components/Constants.cs
@@ -32,15 +32,19 @@ public static class Constants
public const string PromptCategory = "Upendo Ventures";
public const string OutputPrefix = "Upendo Prompt";
- public static class PortalSettingKeys
+ public const string STATE_TRUE = "true";
+ public const string STATE_FALSE = "false";
+
+ public static class SettingKeys
{
- public const string PortalSetting_Popups = "EnablePopUps";
+ public const string HostSetting_DebugMode = "DebugMode";
+ public const string PortalSetting_Popup = "EnablePopUps";
}
public static class LocalizationKeys
{
- public const string PopupsEnabled = "PopupsEnabled";
- public const string PopupsDisabled = "PopupsDisabled";
+ public const string PopupsEnabled = "PopupEnabled";
+ public const string PopupDisabled = "PopupDisabled";
public const string ErrorOccurred = "ErrorOccurred";
public const string FlagMode = "Prompt_PopupMode_FlagMode";
@@ -50,6 +54,9 @@ public static class LocalizationKeys
public const string PromptScopeInvalid = "Prompt_ScopeInvalid";
public const string ScopeCurrent = "ScopeCurrent";
public const string ScopeAll = "ScopeAll";
+
+ public const string DebugOn = "DebugOn";
+ public const string DebugOff = "DebugOff";
}
}
}
\ No newline at end of file
diff --git a/Modules/UpendoPrompt/Config/log4net-DebugOff.xml.resources b/Modules/UpendoPrompt/Config/log4net-DebugOff.xml.resources
new file mode 100644
index 0000000..e7a1d07
--- /dev/null
+++ b/Modules/UpendoPrompt/Config/log4net-DebugOff.xml.resources
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Modules/UpendoPrompt/Config/log4net-DebugOn.xml.resources b/Modules/UpendoPrompt/Config/log4net-DebugOn.xml.resources
new file mode 100644
index 0000000..0852baf
--- /dev/null
+++ b/Modules/UpendoPrompt/Config/log4net-DebugOn.xml.resources
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Modules/UpendoPrompt/Config/webConfig-DebugOff.xml.resources b/Modules/UpendoPrompt/Config/webConfig-DebugOff.xml.resources
new file mode 100644
index 0000000..035deab
--- /dev/null
+++ b/Modules/UpendoPrompt/Config/webConfig-DebugOff.xml.resources
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Modules/UpendoPrompt/Config/webConfig-DebugOn.xml.resources b/Modules/UpendoPrompt/Config/webConfig-DebugOn.xml.resources
new file mode 100644
index 0000000..e604322
--- /dev/null
+++ b/Modules/UpendoPrompt/Config/webConfig-DebugOn.xml.resources
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Modules/UpendoPrompt/Module.build b/Modules/UpendoPrompt/Module.build
index a7ee725..fd56d67 100644
--- a/Modules/UpendoPrompt/Module.build
+++ b/Modules/UpendoPrompt/Module.build
@@ -22,8 +22,9 @@
+
-
+
@@ -47,6 +48,7 @@
+
diff --git a/Modules/UpendoPrompt/Properties/AssemblyInfo.cs b/Modules/UpendoPrompt/Properties/AssemblyInfo.cs
index 4cf1776..75178f1 100644
--- a/Modules/UpendoPrompt/Properties/AssemblyInfo.cs
+++ b/Modules/UpendoPrompt/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("01.00.00")]
-[assembly: AssemblyFileVersion("01.00.00")]
+[assembly: AssemblyVersion("01.01.00")]
+[assembly: AssemblyFileVersion("01.01.00")]
diff --git a/Modules/UpendoPrompt/Upendo.Modules.UpendoPrompt.csproj b/Modules/UpendoPrompt/Upendo.Modules.UpendoPrompt.csproj
index 6694954..e579d23 100644
--- a/Modules/UpendoPrompt/Upendo.Modules.UpendoPrompt.csproj
+++ b/Modules/UpendoPrompt/Upendo.Modules.UpendoPrompt.csproj
@@ -45,9 +45,7 @@
-
- 9.10.0
-
+
@@ -79,6 +77,7 @@
+
@@ -145,6 +144,12 @@
Designer
+
+
+
+
+
+
10.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
diff --git a/Modules/UpendoPrompt/UpendoPrompt.dnn b/Modules/UpendoPrompt/UpendoPrompt.dnn
index e3a81ae..47994db 100644
--- a/Modules/UpendoPrompt/UpendoPrompt.dnn
+++ b/Modules/UpendoPrompt/UpendoPrompt.dnn
@@ -1,7 +1,7 @@
-
+
UpendoPrompt
This extension adds some prompt commands that might help your management of DNN be easier from time to time.
]]>
@@ -52,7 +52,7 @@
Upendo.Modules.UpendoPrompt.Components.FeatureController, Upendo.Modules.UpendoPrompt
[DESKTOPMODULEID]
- 01.00.00
+ 01.00.00,01.01.00
@@ -62,7 +62,7 @@
Upendo.Modules.UpendoPrompt.dll
bin
- 01.00.00
+ 01.01.00
diff --git a/Modules/UpendoPrompt/UpendoPrompt_Symbols.dnn b/Modules/UpendoPrompt/UpendoPrompt_Symbols.dnn
index 5cfc877..5edfd77 100644
--- a/Modules/UpendoPrompt/UpendoPrompt_Symbols.dnn
+++ b/Modules/UpendoPrompt/UpendoPrompt_Symbols.dnn
@@ -1,12 +1,12 @@
-
+
UpendoPrompt Module Symbols
Will Strohl
- Upendo
+ Upendo Ventures, LLC
https://upendoventures.com
solutions@upendoventures.com
@@ -14,7 +14,7 @@
True
- Upendo.Modules.UpendoPrompt
+ Upendo.Modules.UpendoPrompt
diff --git a/Modules/UpendoPrompt/releasenotes.txt b/Modules/UpendoPrompt/releasenotes.txt
index 9471714..be3e0b8 100644
--- a/Modules/UpendoPrompt/releasenotes.txt
+++ b/Modules/UpendoPrompt/releasenotes.txt
@@ -6,10 +6,18 @@
UpendoPrompt Modules Extension for DNN
+ Version 01.00.00
+
+ - Includes a prompt for: `debug-mode`
+ - Resolves localization fixes for the 'popup-mode' prompt.
+ - Cleaned up a minor typo in the solution project file.
+ - Updated build process to include .resource files when in a Config folder.
+
+
Version 01.00.00
- Initial release.
- - Includes a prompt for: popup-mode
+ - Includes a prompt for: `popup-mode`
\ No newline at end of file