Ensures the min umbraco version is checked when installing packages that have the strict flag set.

This commit is contained in:
Shannon
2016-06-13 23:35:09 +02:00
parent 67d71908bf
commit a8c71e52ec
14 changed files with 286 additions and 305 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Xml;
@@ -21,6 +22,12 @@ using umbraco.interfaces;
namespace umbraco.cms.businesslogic.packager
{
public enum RequirementsType
{
Strict,
Legacy
}
/// <summary>
/// The packager is a component which enables sharing of both data and functionality components between different umbraco installations.
///
@@ -88,6 +95,10 @@ namespace umbraco.cms.businesslogic.packager
public int RequirementsMinor { get; private set; }
public int RequirementsPatch { get; private set; }
public RequirementsType RequirementsType { get; private set; }
public string IconUrl { get; private set; }
/// <summary>
/// The xmldocument, describing the contents of a package.
/// </summary>
@@ -98,16 +109,16 @@ namespace umbraco.cms.businesslogic.packager
/// </summary>
public Installer()
{
initialize();
Initialize();
}
public Installer(int currentUserId)
{
initialize();
Initialize();
_currentUserId = currentUserId;
}
private void initialize()
private void Initialize()
{
ContainsBinaryFileErrors = false;
ContainsTemplateConflicts = false;
@@ -116,40 +127,50 @@ namespace umbraco.cms.businesslogic.packager
ContainsStyleSheeConflicts = false;
}
[Obsolete("Use the ctor with all parameters")]
[EditorBrowsable(EditorBrowsableState.Never)]
public Installer(string name, string version, string url, string license, string licenseUrl, string author, string authorUrl, int requirementsMajor, int requirementsMinor, int requirementsPatch, string readme, string control)
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="Name">The name of the package</param>
/// <param name="Version">The version of the package</param>
/// <param name="Url">The url to a descriptionpage</param>
/// <param name="License">The license under which the package is released (preferably GPL ;))</param>
/// <param name="LicenseUrl">The url to a licensedescription</param>
/// <param name="Author">The original author of the package</param>
/// <param name="AuthorUrl">The url to the Authors website</param>
/// <param name="RequirementsMajor">Umbraco version major</param>
/// <param name="RequirementsMinor">Umbraco version minor</param>
/// <param name="RequirementsPatch">Umbraco version patch</param>
/// <param name="Readme">The readme text</param>
/// <param name="Control">The name of the usercontrol used to configure the package after install</param>
public Installer(string Name, string Version, string Url, string License, string LicenseUrl, string Author, string AuthorUrl, int RequirementsMajor, int RequirementsMinor, int RequirementsPatch, string Readme, string Control)
/// <param name="name">The name of the package</param>
/// <param name="version">The version of the package</param>
/// <param name="url">The url to a descriptionpage</param>
/// <param name="license">The license under which the package is released (preferably GPL ;))</param>
/// <param name="licenseUrl">The url to a licensedescription</param>
/// <param name="author">The original author of the package</param>
/// <param name="authorUrl">The url to the Authors website</param>
/// <param name="requirementsMajor">Umbraco version major</param>
/// <param name="requirementsMinor">Umbraco version minor</param>
/// <param name="requirementsPatch">Umbraco version patch</param>
/// <param name="readme">The readme text</param>
/// <param name="control">The name of the usercontrol used to configure the package after install</param>
/// <param name="requirementsType"></param>
/// <param name="iconUrl"></param>
public Installer(string name, string version, string url, string license, string licenseUrl, string author, string authorUrl, int requirementsMajor, int requirementsMinor, int requirementsPatch, string readme, string control, RequirementsType requirementsType, string iconUrl)
{
ContainsBinaryFileErrors = false;
ContainsTemplateConflicts = false;
ContainsUnsecureFiles = false;
ContainsMacroConflict = false;
ContainsStyleSheeConflicts = false;
this.Name = Name;
this.Version = Version;
this.Url = Url;
this.License = License;
this.LicenseUrl = LicenseUrl;
this.RequirementsMajor = RequirementsMajor;
this.RequirementsMinor = RequirementsMinor;
this.RequirementsPatch = RequirementsPatch;
this.Author = Author;
this.AuthorUrl = AuthorUrl;
ReadMe = Readme;
this.Control = Control;
this.Name = name;
this.Version = version;
this.Url = url;
this.License = license;
this.LicenseUrl = licenseUrl;
this.RequirementsMajor = requirementsMajor;
this.RequirementsMinor = requirementsMinor;
this.RequirementsPatch = requirementsPatch;
this.RequirementsType = requirementsType;
this.Author = author;
this.AuthorUrl = authorUrl;
this.IconUrl = iconUrl;
ReadMe = readme;
this.Control = control;
}
#region Public Methods
@@ -485,9 +506,21 @@ namespace umbraco.cms.businesslogic.packager
Url = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/url").FirstChild.Value;
License = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/license").FirstChild.Value;
LicenseUrl = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/license").Attributes.GetNamedItem("url").Value;
RequirementsMajor = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/major").FirstChild.Value);
RequirementsMinor = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/minor").FirstChild.Value);
RequirementsPatch = int.Parse(Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements/patch").FirstChild.Value);
var reqNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/package/requirements");
RequirementsType = reqNode != null && reqNode.Attributes != null && reqNode.Attributes["type"] != null
? Enum<RequirementsType>.Parse(reqNode.Attributes["type"].Value, true)
: RequirementsType.Legacy;
var iconNode = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/iconUrl");
if (iconNode != null)
{
IconUrl = iconNode.FirstChild.Value;
}
Author = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/name").FirstChild.Value;
AuthorUrl = Config.DocumentElement.SelectSingleNode("/umbPackage/info/author/website").FirstChild.Value;
@@ -605,7 +638,7 @@ namespace umbraco.cms.businesslogic.packager
}
catch { }
}
/// <summary>
/// This uses the old method of fetching and only supports the packages.umbraco.org repository.
/// </summary>

View File

@@ -8,269 +8,89 @@ namespace umbraco.cms.businesslogic.packager
{
public class PackageInstance
{
private int _id;
public int Id { get; set; }
private string _name = "";
private string _url = "";
private string _folder = "";
private string _packagePath = "";
private string _version = "";
public string RepositoryGuid { get; set; }
private string _author = "";
private string _authorUrl = "";
public string PackageGuid { get; set; }
private string _license = "";
private string _licenseUrl = "";
public bool HasUpdate { get; set; }
private string _readMe = "";
private bool _contentLoadChildNodes = false;
private string _contentNodeId = "";
public bool EnableSkins { get; set; }
private List<string> _macros = new List<string>();
private List<string> _templates = new List<string>();
private List<string> _documentTypes = new List<string>();
private List<string> _stylesheets = new List<string>();
private List<string> _files = new List<string>();
private List<string> _languages = new List<string>();
private List<string> _dictionaryItems = new List<string>();
private List<string> _dataTypes = new List<string>();
public Guid SkinRepoGuid { get; set; }
private string _loadControl = "";
private string _repoGuid;
private string _packageGuid;
private bool _hasUpdate;
private bool _enableSkins = false;
private Guid _skinRepoGuid = Guid.Empty;
private string _actions;
public string Name { get; set; }
public int Id
public string Url { get; set; }
public string Folder { get; set; }
public string PackagePath { get; set; }
public string Version { get; set; }
public string Author { get; set; }
public string AuthorUrl { get; set; }
public string License { get; set; }
public string LicenseUrl { get; set; }
public string Readme { get; set; }
public bool ContentLoadChildNodes { get; set; }
public string ContentNodeId { get; set; }
public List<string> Macros { get; set; }
public List<string> Languages { get; set; }
public List<string> DictionaryItems { get; set; }
public List<string> Templates { get; set; }
public List<string> Documenttypes { get; set; }
public List<string> Stylesheets { get; set; }
public List<string> Files { get; set; }
public string LoadControl { get; set; }
public string Actions { get; set; }
public List<string> DataTypes { get; set; }
public PackageInstance()
{
get { return _id; }
set {_id = value; }
SkinRepoGuid = Guid.Empty;
Name = "";
Url = "";
Folder = "";
PackagePath = "";
Version = "";
Author = "";
AuthorUrl = "";
License = "";
LicenseUrl = "";
Readme = "";
ContentNodeId = "";
Macros = new List<string>();
Languages = new List<string>();
DictionaryItems = new List<string>();
Templates = new List<string>();
Documenttypes = new List<string>();
Stylesheets = new List<string>();
Files = new List<string>();
LoadControl = "";
DataTypes = new List<string>();
EnableSkins = false;
ContentLoadChildNodes = false;
}
public String RepositoryGuid {
get { return _repoGuid; }
set { _repoGuid = value; }
}
public String PackageGuid {
get { return _packageGuid; }
set { _packageGuid = value; }
}
public bool HasUpdate {
get { return _hasUpdate; }
set { _hasUpdate = value; }
}
public bool EnableSkins
{
get { return _enableSkins; }
set { _enableSkins = value; }
}
public Guid SkinRepoGuid
{
get { return _skinRepoGuid; }
set { _skinRepoGuid = value; }
}
public String Name
{
get { return _name; }
set
{
_name = value;
}
}
public String Url
{
get { return _url; }
set
{
_url = value;
}
}
public String Folder
{
get { return _folder; }
set
{
_folder = value;
}
}
public String PackagePath
{
get { return _packagePath; }
set
{
_packagePath = value;
}
}
public String Version
{
get { return _version; }
set
{
_version = value;
}
}
public String Author
{
get { return _author; }
set
{
_author = value;
}
}
public String AuthorUrl
{
get { return _authorUrl; }
set
{
_authorUrl = value;
}
}
public String License
{
get { return _license; }
set
{
_license = value;
}
}
public String LicenseUrl
{
get { return _licenseUrl; }
set
{
_licenseUrl = value;
}
}
public String Readme
{
get { return _readMe ; }
set
{
_readMe = value;
}
}
public bool ContentLoadChildNodes
{
get { return _contentLoadChildNodes; }
set
{
_contentLoadChildNodes = value;
}
}
public string ContentNodeId
{
get { return _contentNodeId; }
set
{
_contentNodeId = value;
}
}
public List<string> Macros
{
get { return _macros; }
set
{
_macros = value;
}
}
public List<string> Languages {
get { return _languages; }
set {
_languages = value;
}
}
public List<string> DictionaryItems {
get { return _dictionaryItems; }
set {
_dictionaryItems = value;
}
}
public List<string> Templates
{
get { return _templates; }
set
{
_templates = value;
}
}
public List<string> Documenttypes
{
get { return _documentTypes; }
set
{
_documentTypes = value;
}
}
public List<string> Stylesheets
{
get { return _stylesheets; }
set
{
_stylesheets = value;
}
}
public List<string> Files
{
get { return _files; }
set
{
_files = value;
}
}
public String LoadControl
{
get { return _loadControl; }
set
{
_loadControl = value;
}
}
public String Actions
{
get { return _actions; }
set
{
_actions = value;
}
}
public List<string> DataTypes {
get { return _dataTypes; }
set {
_dataTypes = value;
}
}
public PackageInstance() {}
}
}