Added: FileManager editable extensions from the WSP "System Settings" section

This commit is contained in:
Christopher York 2013-09-13 11:55:49 -05:00
parent 1b3aeb02fb
commit 030f4c7eb9
9 changed files with 199 additions and 38 deletions

View file

@ -42,6 +42,7 @@ namespace WebsitePanel.EnterpriseServer
public const string BACKUP_SETTINGS = "BackupSettings";
public const string SETUP_SETTINGS = "SetupSettings";
public const string WPI_SETTINGS = "WpiSettings";
public const string FILEMANAGER_SETTINGS = "FileManagerSettings";
// key to access to wpi main & custom feed in wpi settings
public const string WPI_MAIN_FEED_KEY = "WpiMainFeedUrl";

View file

@ -59,6 +59,8 @@ namespace WebsitePanel.EnterpriseServer {
[System.Xml.Serialization.XmlIncludeAttribute(typeof(ServiceProviderItem))]
public partial class esFiles : Microsoft.Web.Services3.WebServicesClientProtocol {
private System.Threading.SendOrPostCallback GetFileManagerSettingsOperationCompleted;
private System.Threading.SendOrPostCallback GetFilesOperationCompleted;
private System.Threading.SendOrPostCallback GetFilesByMaskOperationCompleted;
@ -110,6 +112,9 @@ namespace WebsitePanel.EnterpriseServer {
this.Url = "http://localhost/EnterpriseServer/esFiles.asmx";
}
/// <remarks/>
public event GetFileManagerSettingsCompletedEventHandler GetFileManagerSettingsCompleted;
/// <remarks/>
public event GetFilesCompletedEventHandler GetFilesCompleted;
@ -179,6 +184,52 @@ namespace WebsitePanel.EnterpriseServer {
/// <remarks/>
public event ExecuteSyncActionsCompletedEventHandler ExecuteSyncActionsCompleted;
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetFileManagerSettings", RequestNamespace = "http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace = "http://smbsaas/websitepanel/enterpriseserver", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public SystemSettings GetFileManagerSettings()
{
object[] results = this.Invoke("GetFileManagerSettings", new Object[] {});
return ((SystemSettings)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginGetFileManagerSettings(System.AsyncCallback callback, object asyncState)
{
return this.BeginInvoke("GetFileManagerSettings", new Object[] {}, callback, asyncState);
}
/// <remarks/>
public SystemSettings EndGetFileManagerSettings(System.IAsyncResult asyncResult)
{
object[] results = this.EndInvoke(asyncResult);
return ((SystemSettings)(results[0]));
}
/// <remarks/>
public void GetFileManagerSettingsAsync()
{
this.GetFileManagerSettingsAsync(null);
}
/// <remarks/>
public void GetFileManagerSettingsAsync(object userState)
{
if ((this.GetFileManagerSettingsOperationCompleted == null))
{
this.GetFileManagerSettingsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetFileManagerSettingsOperationCompleted);
}
this.InvokeAsync("GetFileManagerSettings", new Object[] {}, this.GetFileManagerSettingsOperationCompleted, userState);
}
private void OnGetFileManagerSettingsOperationCompleted(object arg)
{
if ((this.GetFileManagerSettingsCompleted != null))
{
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
this.GetFileManagerSettingsCompleted(this, new GetFileManagerSettingsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
}
}
/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://smbsaas/websitepanel/enterpriseserver/GetFiles", RequestNamespace="http://smbsaas/websitepanel/enterpriseserver", ResponseNamespace="http://smbsaas/websitepanel/enterpriseserver", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public SystemFile[] GetFiles(int packageId, string path, bool includeFiles) {
@ -1260,7 +1311,33 @@ namespace WebsitePanel.EnterpriseServer {
public delegate void GetFileManagerSettingsCompletedEventHandler(object sender, GetFileManagerSettingsCompletedEventArgs e);
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class GetFileManagerSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
{
private object[] results;
internal GetFileManagerSettingsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState)
{
this.results = results;
}
/// <remarks/>
public SystemSettings Result
{
get
{
this.RaiseExceptionIfNecessary();
return ((SystemSettings)(this.results[0]));
}
}
}
/// <remarks/>

View file

@ -45,6 +45,11 @@ namespace WebsitePanel.EnterpriseServer
{
public class FilesController
{
public static SystemSettings GetFileManagerSettings()
{
return SystemController.GetSystemSettingsInternal(SystemSettings.FILEMANAGER_SETTINGS, false);
}
public static OS.OperatingSystem GetOS(int packageId)
{
int sid = PackageController.GetPackageServiceId(packageId, ResourceGroups.Os);

View file

@ -50,6 +50,12 @@ namespace WebsitePanel.EnterpriseServer
[ToolboxItem(false)]
public class esFiles : System.Web.Services.WebService
{
[WebMethod]
public SystemSettings GetFileManagerSettings()
{
return FilesController.GetFileManagerSettings();
}
[WebMethod]
public static string GetHomeFolder(int packageId)
{

View file

@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="btnSaveSettings.Text" xml:space="preserve">
<value>Save Settings</value>
@ -153,4 +153,13 @@
<data name="lclWpiCustomFeeds.Text" xml:space="preserve">
<value>Custom feeds:</value>
</data>
<data name="HeaderFileManagerSettings.Text" xml:space="preserve">
<value>File Manager</value>
</data>
<data name="lblFileManagerEditableExtensions.Text" xml:space="preserve">
<value>Editable Extensions:</value>
</data>
<data name="litFileManagerEditableExtensions.Text" xml:space="preserve">
<value>(One (1) extension per line)</value>
</data>
</root>

View file

@ -33,12 +33,14 @@ using System.Text;
using System.Web;
using System.Web.UI.WebControls;
using WebsitePanel.Providers.OS;
using System.Linq;
using System.Text.RegularExpressions;
namespace WebsitePanel.Portal
{
public partial class FileManager : WebsitePanelModuleBase
{
string ALLOWED_EDIT_EXTENSIONS = ".txt.htm.html.php.pl.sql.cs.vb.ascx.aspx.inc.asp.config.xml.xsl.xslt.xsd.Master.htaccess.htpasswd.cshtml.vbhtml";
public static string ALLOWED_EDIT_EXTENSIONS = ".txt,.htm,.html,.php,.pl,.sql,.cs,.vb,.ascx,.aspx,.inc,.asp,.config,.xml,.xsl,.xslt,.xsd,.master,.htaccess,.htpasswd,.cshtml,.vbhtml,.ini,.config";
protected void Page_Load(object sender, EventArgs e)
{
@ -204,12 +206,16 @@ function SetCreateZipFocus()
if (file.IsDirectory)
return false;
// Get the Editable Extensions from the System Settings
// If it has not yet been set, we will use the original WebsitePanel allowed editable extensions
EnterpriseServer.SystemSettings settings = ES.Services.Files.GetFileManagerSettings();
if (!String.IsNullOrEmpty(settings["EditableExtensions"]))
{
ALLOWED_EDIT_EXTENSIONS = settings["EditableExtensions"];
}
string ext = Path.GetExtension(file.Name);
//allow to edit Master pages
if (ext == ".Master")
return true;
else
return ALLOWED_EDIT_EXTENSIONS.IndexOf(ext.ToLower()) != -1;
return ALLOWED_EDIT_EXTENSIONS.Split(',').ToArray().Contains(ext);
}
#region Path methods

View file

@ -58,6 +58,18 @@
</tr>
</table>
</asp:Panel>
<wsp:CollapsiblePanel id="HeaderFileManagerSettings" runat="server"
TargetControlID="PanelFileManagereSettings" meta:resourcekey="HeaderFileManagerSettings" Text="File Manager"/>
<asp:Panel ID="PanelFileManagereSettings" runat="server" Height="0" style="overflow:hidden;">
<table>
<tr>
<td class="SubHead" style="width:200px;"><asp:Localize ID="lblFileManagerEditableExtensions" runat="server" meta:resourcekey="lblFileManagerEditableExtensions" /></td>
<td><asp:TextBox TextMode="MultiLine" Rows="10" runat="server" ID="txtFileManagerEditableExtensions" Width="300px" /><asp:Literal ID="litFileManagerEditableExtensions" runat="Server" Text=" (One (1) extension per line)"></asp:Literal></td>
</tr>
</table>
</asp:Panel>
</div>
<div class="FormFooter">
<asp:Button runat="server" ID="btnSaveSettings" meta:resourcekey="btnSaveSettings"

View file

@ -38,6 +38,7 @@ using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebsitePanel.EnterpriseServer.Base.Common;
using WSP = WebsitePanel.EnterpriseServer;
using System.Text.RegularExpressions;
namespace WebsitePanel.Portal
{
@ -49,6 +50,7 @@ namespace WebsitePanel.Portal
public const string SMTP_PASSWORD = "SmtpPassword";
public const string SMTP_ENABLE_SSL = "SmtpEnableSsl";
public const string BACKUPS_PATH = "BackupsPath";
public const string FILE_MANAGER_EDITABLE_EXTENSIONS = "EditableExtensions";
/*
public const string FEED_ENABLE_MICROSOFT = "FeedEnableMicrosoft";
@ -122,7 +124,19 @@ namespace WebsitePanel.Portal
txtMainFeedUrl.Text = mainFeedUrl;
}
// FILE MANAGER
settings = ES.Services.System.GetSystemSettings(
WSP.SystemSettings.FILEMANAGER_SETTINGS);
if (settings != null)
{
txtFileManagerEditableExtensions.Text = settings[FILE_MANAGER_EDITABLE_EXTENSIONS].Replace(",", System.Environment.NewLine);
}
else
{
// Original WebsitePanel Extensions
txtFileManagerEditableExtensions.Text = FileManager.ALLOWED_EDIT_EXTENSIONS.Replace(",", System.Environment.NewLine);
}
}
private void SaveSettings()
@ -179,6 +193,20 @@ namespace WebsitePanel.Portal
result = ES.Services.System.SetSystemSettings(WSP.SystemSettings.WPI_SETTINGS, settings);
if (result < 0)
{
ShowResultMessage(result);
return;
}
// FILE MANAGER
settings = new WSP.SystemSettings();
settings[FILE_MANAGER_EDITABLE_EXTENSIONS] = Regex.Replace(txtFileManagerEditableExtensions.Text, @"[\r\n]+", ",");
result = ES.Services.System.SetSystemSettings(
WSP.SystemSettings.FILEMANAGER_SETTINGS, settings);
if (result < 0)
{
ShowResultMessage(result);

View file

@ -1,31 +1,3 @@
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// - Neither the name of the Outercurve Foundation nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@ -175,6 +147,51 @@ namespace WebsitePanel.Portal {
/// </remarks>
protected global::WebsitePanel.Portal.UserControls.EditFeedsList wpiEditFeedsList;
/// <summary>
/// HeaderFileManagerSettings control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::WebsitePanel.Portal.CollapsiblePanel HeaderFileManagerSettings;
/// <summary>
/// PanelFileManagereSettings control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel PanelFileManagereSettings;
/// <summary>
/// lblFileManagerEditableExtensions control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Localize lblFileManagerEditableExtensions;
/// <summary>
/// txtFileManagerEditableExtensions control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox txtFileManagerEditableExtensions;
/// <summary>
/// litFileManagerEditableExtensions control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litFileManagerEditableExtensions;
/// <summary>
/// btnSaveSettings control.
/// </summary>