WORK IN PROGRESS, GET THE STABLE SOURCE FROM THE DOWNLOADS TAB
Automated the creation of packages folders/files when they are needed. Removed package folder from proj file, updated default project folder to be a sub folder of the default data folder in the IO SystemDirectories. [TFS Changeset #63883]
This commit is contained in:
@@ -128,7 +128,8 @@ namespace umbraco.IO
|
||||
{
|
||||
get
|
||||
{
|
||||
return IOHelper.returnPath("umbracoPackagesPath", "~/data/packages");
|
||||
//by default the packages folder should exist in the data folder
|
||||
return IOHelper.returnPath("umbracoPackagesPath", Data + IOHelper.DirSepChar + "packages");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
73
umbraco/cms/businesslogic/Packager/FileResources/PackageFiles.Designer.cs
generated
Normal file
73
umbraco/cms/businesslogic/Packager/FileResources/PackageFiles.Designer.cs
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4200
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace umbraco.cms.businesslogic.Packager.FileResources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class PackageFiles {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal PackageFiles() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("umbraco.cms.businesslogic.Packager.FileResources.PackageFiles", typeof(PackageFiles).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
|
||||
///<packages></packages>.
|
||||
/// </summary>
|
||||
internal static string Packages {
|
||||
get {
|
||||
return ResourceManager.GetString("Packages", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<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>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Packages" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>packages.config;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages></packages>
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace umbraco.cms.businesslogic.packager
|
||||
{
|
||||
@@ -19,23 +20,33 @@ namespace umbraco.cms.businesslogic.packager
|
||||
|
||||
public static void Reload(string dataSource)
|
||||
{
|
||||
if (_source == null)
|
||||
_source = new XmlDocument();
|
||||
try {
|
||||
|
||||
_source.Load(dataSource);
|
||||
|
||||
} catch {
|
||||
|
||||
if (!System.IO.File.Exists(dataSource)) {
|
||||
System.IO.StreamWriter sw = System.IO.File.CreateText(dataSource);
|
||||
sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
sw.WriteLine("<packages></packages>");
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
//do some error checking and create the folders/files if they don't exist
|
||||
if (!File.Exists(dataSource))
|
||||
{
|
||||
if (!Directory.Exists(IO.IOHelper.MapPath(Settings.PackagerRoot)))
|
||||
{
|
||||
Directory.CreateDirectory(IO.IOHelper.MapPath(Settings.PackagerRoot));
|
||||
}
|
||||
_source.Load(dataSource);
|
||||
if (!Directory.Exists(IO.IOHelper.MapPath(Settings.PackagesStorage)))
|
||||
{
|
||||
Directory.CreateDirectory(IO.IOHelper.MapPath(Settings.PackagesStorage));
|
||||
}
|
||||
if (!Directory.Exists(IO.IOHelper.MapPath(Settings.InstalledPackagesStorage)))
|
||||
{
|
||||
Directory.CreateDirectory(IO.IOHelper.MapPath(Settings.InstalledPackagesStorage));
|
||||
}
|
||||
|
||||
StreamWriter sw = File.CreateText(dataSource);
|
||||
sw.Write(umbraco.cms.businesslogic.Packager.FileResources.PackageFiles.Packages);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
if (_source == null)
|
||||
{
|
||||
_source = new XmlDocument();
|
||||
}
|
||||
_source.Load(dataSource);
|
||||
}
|
||||
|
||||
public static XmlNode GetFromId(int Id, string dataSource, bool reload)
|
||||
|
||||
@@ -174,6 +174,11 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Actions\IActionHandler.cs" />
|
||||
<Compile Include="businesslogic\Packager\FileResources\PackageFiles.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>PackageFiles.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="helpers\Casing.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
@@ -325,8 +330,15 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="businesslogic\Packager\FileResources\Packages.config" />
|
||||
<None Include="ClassDiagram1.cd" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="businesslogic\Packager\FileResources\PackageFiles.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>PackageFiles.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="businesslogic\translate\" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,285 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Reflection;
|
||||
using System.Collections.Specialized;
|
||||
using System.Xml;
|
||||
using umbraco;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
|
||||
namespace presentation.umbracoBase
|
||||
{
|
||||
public class requestModule : IHttpModule
|
||||
{
|
||||
#region IHttpModule Members
|
||||
public void Dispose()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void Init(HttpApplication httpApp)
|
||||
{
|
||||
httpApp.BeginRequest += new EventHandler(OnBeginRequest);
|
||||
}
|
||||
|
||||
|
||||
public void OnBeginRequest(Object sender, EventArgs e)
|
||||
{
|
||||
HttpApplication httpApp = (HttpApplication)sender;
|
||||
|
||||
//remove extension and split the url
|
||||
object[] urlArray = httpApp.Context.Request.RawUrl.Replace(".aspx", "").Split('/');
|
||||
|
||||
if (urlArray[1].ToString() == "base")
|
||||
{
|
||||
//There has to be minimum 4 parts in the url for this to work... /base/library/method/[parameter].aspx
|
||||
if (urlArray.Length >= 4)
|
||||
{
|
||||
string extensionAlias = urlArray[2].ToString();
|
||||
string methodName = urlArray[3].ToString();
|
||||
|
||||
httpApp.Response.ContentType = "text/xml";
|
||||
MyMethodStruct myMMS = getMethod(extensionAlias, methodName);
|
||||
|
||||
if (myMMS.isAllowed)
|
||||
{
|
||||
httpApp.Response.Output.Write(invokeMethod(myMMS, urlArray));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Very static error msg...
|
||||
httpApp.Response.Output.Write("<error>Extension not found or permission denied</error>");
|
||||
}
|
||||
//end the resposne
|
||||
httpApp.Response.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private string invokeMethod(MyMethodStruct myMethod, object[] paras)
|
||||
{
|
||||
try
|
||||
{
|
||||
//So method is either not found or not valid... this should probably be moved...
|
||||
if (!myMethod.method.IsPublic || !myMethod.method.IsStatic)
|
||||
return "<error>Method has to be public and static</error>";
|
||||
else //And if it is lets continue trying to invoke it...
|
||||
{
|
||||
//lets check if we have parameters enough in the url..
|
||||
if (myMethod.method.GetParameters().Length > (paras.Length - 4)) //Too few
|
||||
return "<error>Not Enough parameters in url</error>";
|
||||
else
|
||||
{
|
||||
|
||||
//We have enough parameters... lets invoke..
|
||||
//Create an instance of the type we need to invoke the method from.
|
||||
Object obj = Activator.CreateInstance(myMethod.type);
|
||||
Object response;
|
||||
|
||||
//umbracoBase.baseBinder bBinder = new baseBinder();
|
||||
|
||||
if (myMethod.method.GetParameters().Length == 0)
|
||||
{
|
||||
//response = myMethod.method.Invoke(obj, BindingFlags.Public | BindingFlags.Instance, bBinder, null, System.Globalization.CultureInfo.CurrentCulture);
|
||||
response = myMethod.method.Invoke(obj, null); //Invoke with null as parameters as there are none
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//We only need the parts of the url above the number 4 so we'll
|
||||
//recast those to objects and add them to the object[]
|
||||
|
||||
//Getting the right lenght.. 4 is the magic number dum di dum..
|
||||
object[] methodParams = new object[(paras.Length - 4)];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (ParameterInfo pInfo in myMethod.method.GetParameters())
|
||||
{
|
||||
Type myType = Type.GetType(pInfo.ParameterType.ToString());
|
||||
methodParams[(i)] = Convert.ChangeType(paras[i + 4], myType);
|
||||
i++;
|
||||
}
|
||||
|
||||
//Invoke with methodParams
|
||||
//response = myMethod.method.Invoke(obj, BindingFlags.Public | BindingFlags.Instance, bBinder, methodParams, System.Globalization.CultureInfo.CurrentCulture);
|
||||
response = myMethod.method.Invoke(obj, methodParams);
|
||||
}
|
||||
|
||||
/*TODO - SOMETHING ALITTLE BETTER THEN ONLY CHECK FOR XPATHNODEITERATOR OR ELSE do ToString() */
|
||||
if (response != null)
|
||||
{
|
||||
if (myMethod.method.ReturnType.ToString() == "System.Xml.XPath.XPathNodeIterator")
|
||||
return ((System.Xml.XPath.XPathNodeIterator)response).Current.OuterXml;
|
||||
else
|
||||
{
|
||||
string strResponse = ((string)response.ToString());
|
||||
|
||||
//do a quick "is this html?" check... if it is add CDATA...
|
||||
if (strResponse.Contains("<") || strResponse.Contains(">"))
|
||||
strResponse = "<![CDATA[" + strResponse + "]]>";
|
||||
return "<value>" + strResponse + "</value>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Error msg...
|
||||
return "<error>Null value returned</error>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Overall exception handling...
|
||||
return "<error><![CDATA[MESSAGE:" + ex.Message + " STACKTRACE: " + ex.StackTrace + " ]]></error>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private struct MyMethodStruct
|
||||
{
|
||||
public Type type;
|
||||
public MethodInfo method;
|
||||
public Assembly assembly;
|
||||
public string alias;
|
||||
public bool isAllowed;
|
||||
}
|
||||
|
||||
|
||||
private static MyMethodStruct getMethod(string extensionAlias, string methodName)
|
||||
{
|
||||
|
||||
bool allowed = false;
|
||||
|
||||
XmlDocument baseDoc = new XmlDocument(); //RESTExtension document...
|
||||
baseDoc.Load(System.Web.HttpContext.Current.Server.MapPath(GlobalSettings.Path + "/../config/restExtensions.xml"));
|
||||
|
||||
XmlNode baseExt = baseDoc.SelectSingleNode("/RestExtensions/ext [@alias='" + extensionAlias + "']/permission [@method='" + methodName + "']");
|
||||
|
||||
//basicly - if not there.. it's not allowed...
|
||||
if (baseExt != null)
|
||||
{
|
||||
//Access for all ?
|
||||
if (baseExt.Attributes["allowAll"] != null)
|
||||
{
|
||||
if (baseExt.Attributes["allowAll"].Value.ToString().ToLower() == "true")
|
||||
allowed = true;
|
||||
}
|
||||
|
||||
if (!allowed)
|
||||
{
|
||||
//Member Based permissions.. check for group, type and ID...
|
||||
Member currentMem = library.library.GetCurrentMember(); // <-- /TODO/ uses bases own member class as umbracos doesn't work yet...
|
||||
|
||||
//not basic.. and not logged in? - out..
|
||||
if (currentMem == null)
|
||||
{
|
||||
allowed = false;
|
||||
}
|
||||
else //do member authentication stuff...
|
||||
allowed = memberAuthentication(baseExt, currentMem);
|
||||
}
|
||||
}
|
||||
|
||||
if (allowed)
|
||||
{
|
||||
XmlNode extNode = baseDoc.SelectSingleNode("/RestExtensions/ext [@alias='" + extensionAlias + "']");
|
||||
string asml = extNode.Attributes["assembly"].Value;
|
||||
string assemblyPath = System.Web.HttpContext.Current.Server.MapPath(GlobalSettings.Path + "/.." + asml + ".dll");
|
||||
Assembly returnAssembly = System.Reflection.Assembly.LoadFrom(assemblyPath);
|
||||
|
||||
string returnTypeName = extNode.Attributes["type"].Value;
|
||||
Type returnType = returnAssembly.GetType(returnTypeName);
|
||||
|
||||
|
||||
MyMethodStruct mms = new MyMethodStruct();
|
||||
mms.alias = extensionAlias;
|
||||
mms.assembly = returnAssembly;
|
||||
mms.method = returnType.GetMethod(methodName);
|
||||
mms.type = returnType;
|
||||
mms.isAllowed = true;
|
||||
return mms;
|
||||
}
|
||||
else
|
||||
{
|
||||
MyMethodStruct noMms = new MyMethodStruct();
|
||||
noMms.isAllowed = false;
|
||||
return noMms;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static bool memberAuthentication(XmlNode baseExt, Member currentMem)
|
||||
{
|
||||
//Check group, type and ID
|
||||
bool memberAccess = false;
|
||||
|
||||
if (baseExt.Attributes["allowGroup"] != null)
|
||||
{
|
||||
if (baseExt.Attributes["allowGroup"].Value != "")
|
||||
{
|
||||
//Groups array
|
||||
string[] groupArray = baseExt.Attributes["allowGroup"].Value.Split(',');
|
||||
|
||||
foreach (MemberGroup mg in currentMem.Groups.Values)
|
||||
{
|
||||
foreach (string group in groupArray)
|
||||
{
|
||||
if (group == mg.Text)
|
||||
memberAccess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Membertype allowed?
|
||||
if (baseExt.Attributes["allowType"] != null && !memberAccess)
|
||||
{
|
||||
if (baseExt.Attributes["allowType"].Value != "")
|
||||
{
|
||||
//Types array
|
||||
string[] typeArray = baseExt.Attributes["allowType"].Value.Split(',');
|
||||
|
||||
foreach (string type in typeArray)
|
||||
{
|
||||
if (type == currentMem.ContentType.Alias)
|
||||
memberAccess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Member ID allowed? should this work with loginName instead?
|
||||
if (baseExt.Attributes["allowMember"] != null && !memberAccess)
|
||||
{
|
||||
if (baseExt.Attributes["allowMember"].Value != "")
|
||||
{
|
||||
if (int.Parse((string)baseExt.Attributes["allowMember"].Value.Trim()) == currentMem.Id)
|
||||
memberAccess = true;
|
||||
}
|
||||
}
|
||||
return memberAccess;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using System.Xml.XPath;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Text.RegularExpressions;
|
||||
using umbraco.cms.businesslogic;
|
||||
using umbraco.cms.businesslogic.member;
|
||||
using umbraco.cms.businesslogic.property;
|
||||
|
||||
namespace presentation.umbracoBase.library
|
||||
{
|
||||
//This should be replaced with umbracos own methods...
|
||||
public class library
|
||||
{
|
||||
public static Member GetCurrentMember()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CurrentMemberId() != 0)
|
||||
{
|
||||
// return member from cache
|
||||
Member m = Member.GetMemberFromCache(CurrentMemberId());
|
||||
if (m == null)
|
||||
m = new Member(CurrentMemberId());
|
||||
|
||||
if (m != null)
|
||||
if (m.UniqueId == new Guid(getCookieValue("umbracoMemberGuid")) && m.LoginName == getCookieValue("umbracoMemberLogin"))
|
||||
return m;
|
||||
|
||||
return null;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int CurrentMemberId()
|
||||
{
|
||||
int _currentMemberId = 0;
|
||||
|
||||
if (getCookieValue("umbracoMemberId") != "" && getCookieValue("umbracoMemberGuid") != "" && getCookieValue("umbracoMemberLogin") != "")
|
||||
_currentMemberId = int.Parse(getCookieValue("umbracoMemberId"));
|
||||
|
||||
return _currentMemberId;
|
||||
}
|
||||
|
||||
private static string getCookieValue(string Name)
|
||||
{
|
||||
string tempValue = "";
|
||||
if (System.Web.HttpContext.Current.Request.Cookies[Name] != null)
|
||||
if (System.Web.HttpContext.Current.Request.Cookies[Name].Value != "")
|
||||
{
|
||||
tempValue = System.Web.HttpContext.Current.Request.Cookies[Name].Value;
|
||||
}
|
||||
|
||||
return tempValue;
|
||||
}
|
||||
}
|
||||
|
||||
public class member
|
||||
{
|
||||
public static int login(string loginname, string password)
|
||||
{
|
||||
Member m = Member.GetMemberFromLoginNameAndPassword(loginname, password);
|
||||
|
||||
if (library.CurrentMemberId() == 0)
|
||||
{
|
||||
// If null, login not correct...
|
||||
if (m != null)
|
||||
{
|
||||
Member.AddMemberToCache(m);
|
||||
return m.Id;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return library.CurrentMemberId();
|
||||
}
|
||||
|
||||
public static int logout()
|
||||
{
|
||||
Member m = library.GetCurrentMember();
|
||||
if (m != null)
|
||||
{
|
||||
Member.RemoveMemberFromCache(m);
|
||||
Member.ClearMemberFromClient(m);
|
||||
return m.Id;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static XPathNodeIterator data()
|
||||
{
|
||||
if (library.GetCurrentMember() != null)
|
||||
{
|
||||
XmlDocument mXml = new XmlDocument();
|
||||
mXml.LoadXml(library.GetCurrentMember().ToXml(mXml, false).OuterXml);
|
||||
XPathNavigator xp = mXml.CreateNavigator();
|
||||
return xp.Select("/node");
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int id()
|
||||
{
|
||||
return library.CurrentMemberId();
|
||||
}
|
||||
|
||||
public static string setProperty(string alias, object value)
|
||||
{
|
||||
string retVal = "False";
|
||||
try
|
||||
{
|
||||
Member myMember = library.GetCurrentMember();
|
||||
|
||||
if (myMember != null)
|
||||
{
|
||||
Property myProperty = myMember.getProperty(alias);
|
||||
|
||||
if (MemberType.GetByAlias(myMember.ContentType.Alias).MemberCanEdit(myProperty.PropertyType))
|
||||
{
|
||||
|
||||
if (myProperty.PropertyType.ValidationRegExp.Trim() != "")
|
||||
{
|
||||
Regex regexPattern = new Regex(myMember.getProperty(alias).PropertyType.ValidationRegExp);
|
||||
|
||||
if (regexPattern.IsMatch(value.ToString()))
|
||||
{
|
||||
myProperty.Value = value;
|
||||
retVal = "True";
|
||||
myMember.XmlGenerate(new XmlDocument());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myProperty.Value = value;
|
||||
retVal = "True";
|
||||
myMember.XmlGenerate(new XmlDocument());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception x)
|
||||
{ retVal = x.Message; }
|
||||
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace umbraco.presentation.install.steps
|
||||
public partial class validatePermissions : UserControl
|
||||
{
|
||||
private string[] permissionDirs = {SystemDirectories.Css, SystemDirectories.Config, SystemDirectories.Data, SystemDirectories.Media, SystemDirectories.Masterpages, SystemDirectories.Xslt, SystemDirectories.Usercontrols};
|
||||
private string[] permissionFiles = { SystemDirectories.Packages + "/installed/installedPackages.config" , SystemDirectories.Packages + "/created/createdPackages.config" };
|
||||
private string[] permissionFiles = { };
|
||||
private string[] packagesPermissionsDirs = {SystemDirectories.Bin, SystemDirectories.Umbraco, SystemDirectories.Usercontrols, SystemDirectories.Packages};
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
|
||||
@@ -2758,8 +2758,6 @@
|
||||
<Content Include="config\tinyMceConfig.config" />
|
||||
<Content Include="config\umbracoSettings.config" />
|
||||
<Content Include="config\xsltExtensions.config" />
|
||||
<Content Include="data\packages\created\createdPackages.config" />
|
||||
<Content Include="data\packages\installed\installedPackages.config" />
|
||||
<None Include="umbraco\schemas\package.xsd">
|
||||
<SubType>
|
||||
</SubType>
|
||||
@@ -2796,7 +2794,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="css\" />
|
||||
<Folder Include="data\_systemUmbracoIndexDontDelete\" />
|
||||
<Folder Include="data\" />
|
||||
<Folder Include="masterpages\" />
|
||||
<Folder Include="media\" />
|
||||
<Folder Include="python\" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
<%@ WebService Language="C#" CodeBehind="MediaPickerService.asmx.cs" Class="umbraco.presentation.webservices.MediaPickerService" %>
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.Script.Services;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
|
||||
namespace umbraco.presentation.webservices
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Media
|
||||
/// </summary>
|
||||
[WebService(Namespace = "http://umbraco.org/webservices")]
|
||||
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||
[System.ComponentModel.ToolboxItem(false)]
|
||||
[ScriptService]
|
||||
|
||||
public class MediaPickerService : System.Web.Services.WebService
|
||||
{
|
||||
|
||||
[WebMethod]
|
||||
[ScriptMethod]
|
||||
public string GetThumbNail(int mediaId)
|
||||
{
|
||||
return MediaPickerServiceHelpers.GetThumbNail(mediaId);
|
||||
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
[ScriptMethod]
|
||||
public string GetFile(int mediaId)
|
||||
{
|
||||
return MediaPickerServiceHelpers.GetFile(mediaId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
|
||||
namespace umbraco.presentation.webservices
|
||||
{
|
||||
public class MediaPickerServiceHelpers
|
||||
{
|
||||
|
||||
public static string GetThumbNail(int mediaId)
|
||||
{
|
||||
|
||||
|
||||
string fileName;
|
||||
string thumbnail = string.Empty;
|
||||
try
|
||||
{
|
||||
|
||||
Media m = new Media(mediaId);
|
||||
|
||||
fileName = m.getProperty("umbracoFile").Value.ToString();
|
||||
string ext = fileName.Substring(fileName.LastIndexOf('.') + 1, fileName.Length - (fileName.LastIndexOf('.') + 1));
|
||||
|
||||
|
||||
if (",jpeg,jpg,gif,bmp,png,tiff,tif,".IndexOf("," + ext.ToLower() + ",") > -1)
|
||||
{
|
||||
thumbnail = fileName.Substring(0, fileName.LastIndexOf('.')) + "_thumb.jpg";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
//switch (ext.ToLower())
|
||||
//{
|
||||
// case "pdf":
|
||||
// thumbnail = "";
|
||||
// break;
|
||||
// case "doc":
|
||||
// thumbnail = "";
|
||||
// break;
|
||||
// default:
|
||||
// thumbnail = "";
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public static string GetFile(int mediaId)
|
||||
{
|
||||
string fileName = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
Media m = new Media(mediaId);
|
||||
|
||||
fileName = m.getProperty("umbracoFile").Value.ToString();
|
||||
|
||||
|
||||
}
|
||||
catch { }
|
||||
|
||||
return fileName;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<!-- Set up a local connection string -->
|
||||
<xsl:template match="/configuration/appSettings/add[@key='umbracoDbDSN']/@value">
|
||||
<xsl:attribute name="value">server=.\sqlexpress;database=UmbracoTest;user id=sa;password=test</xsl:attribute>
|
||||
<xsl:attribute name="value">server=.\sqlexpress;database=UmbracoTest2;user id=sa;password=test</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="/configuration/appSettings/add[@key='umbracoConfigurationStatus']/@value">
|
||||
|
||||
Reference in New Issue
Block a user