More unit tests.
ClientDependency update (Fixes: 27155 medium trust issue) Fixes: 27156 - DLLs locked when building solution Fixes: 27154 - Examine requirePermission attributes for medium trust Fixes: 27152 - TypeFinder never creating seperate AppDomain for finding types in full trust [TFS Changeset #66282]
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -31,22 +31,11 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\..\..\umbraco\presentation\bin\umbraco.Linq.Core.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug - Fixed Version|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>..\..\..\..\umbraco\presentation\bin\Umbraco.Linq.Core.XML</DocumentationFile>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<DocumentationFile>bin\Release\umbraco.Linq.Core.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
@@ -72,14 +72,14 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile>..\..\umbraco\presentation\bin\umbraco.editorControls.XML</DocumentationFile>
|
||||
<DocumentationFile>bin\Release\umbraco.editorControls.XML</DocumentationFile>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
@@ -57,14 +57,14 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile>..\..\umbraco\presentation\bin\umbraco.macroRenderings.XML</DocumentationFile>
|
||||
<DocumentationFile>bin\Release\umbraco.macroRenderings.XML</DocumentationFile>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<NoStdLib>false</NoStdLib>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -34,11 +34,11 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\umbraco\presentation\bin\controls.XML</DocumentationFile>
|
||||
<DocumentationFile>bin\Release\controls.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ClientDependency.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
@@ -29,11 +29,11 @@
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\umbraco\presentation\bin\</OutputPath>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\umbraco\presentation\bin\umbraco.webservices.XML</DocumentationFile>
|
||||
<DocumentationFile>bin\Release\umbraco.webservices.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
||||
Binary file not shown.
@@ -34,8 +34,6 @@ namespace umbraco.Test
|
||||
public class DocumentTest
|
||||
{
|
||||
|
||||
#region Unit Tests
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bunch of nodes in a heirarchy, then deletes the top most node (moves to the recycle bin
|
||||
/// and completely deletes from system.) This should completely delete all of these nodes from the database.
|
||||
@@ -460,7 +458,6 @@ namespace umbraco.Test
|
||||
Assert.AreEqual(0, RecycleBin.Count(RecycleBin.RecycleBinType.Content));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TEST TO BE WRITTEN
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using umbraco.cms.businesslogic.template;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
using System.Data.SqlClient;
|
||||
using umbraco.cms.businesslogic;
|
||||
|
||||
namespace umbraco.Test
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace umbraco.Test
|
||||
public class DocumentTypeTest
|
||||
{
|
||||
[TestMethod()]
|
||||
public void DocumentType_DeleteDocTypeWithContennt()
|
||||
public void DocumentType_DeleteDocTypeWithContent()
|
||||
{
|
||||
var dt = CreateNewDocType();
|
||||
var doc = Document.MakeNew("TEST" + Guid.NewGuid().ToString("N"), dt, m_User, -1);
|
||||
|
||||
468
umbraco.Test/MediaTest.cs
Normal file
468
umbraco.Test/MediaTest.cs
Normal file
@@ -0,0 +1,468 @@
|
||||
using umbraco.cms.businesslogic.media;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Linq;
|
||||
using umbraco.editorControls.textfield;
|
||||
using umbraco.editorControls.label;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
using umbraco.cms.businesslogic;
|
||||
|
||||
namespace umbraco.Test
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///This is a test class for MediaTest and is intended
|
||||
///to contain all MediaTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class MediaTest
|
||||
{
|
||||
/// <summary>
|
||||
///A test for making a new media and deleting it which actuall first moves it to the recycle bin
|
||||
///and then deletes it.
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
public void Media_MakeNewTest()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
Assert.IsInstanceOfType(m_NewRootMedia, typeof(Media));
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void Media_DeleteHeirarchyPermanentlyTest()
|
||||
{
|
||||
var mediaList = new List<Media>();
|
||||
var total = 20;
|
||||
var mt = new MediaType(GetExistingMediaTypeId());
|
||||
//allow the doc type to be created underneath itself
|
||||
mt.AllowedChildContentTypeIDs = new int[] { mt.Id };
|
||||
mt.Save();
|
||||
|
||||
//create 20 content nodes underneath each other, this will test deleting with heirarchy as well
|
||||
var lastParentId = -1;
|
||||
for (var i = 0; i < total; i++)
|
||||
{
|
||||
var newDoc = Media.MakeNew(i.ToString() + Guid.NewGuid().ToString("N"), mt, m_User, lastParentId);
|
||||
mediaList.Add(newDoc);
|
||||
Assert.IsTrue(mediaList[mediaList.Count - 1].Id > 0);
|
||||
lastParentId = newDoc.Id;
|
||||
}
|
||||
|
||||
//now delete all of them permanently, since they are nested, we only need to delete one
|
||||
mediaList.First().delete(true);
|
||||
|
||||
//make sure they are all gone
|
||||
foreach (var d in mediaList)
|
||||
{
|
||||
Assert.IsFalse(Media.IsNode(d.Id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Media_MoveTest()
|
||||
{
|
||||
//first need to document type that allows other types of document types to exist underneath it
|
||||
MediaType parent = null;
|
||||
MediaType child = null;
|
||||
var ids = MediaType.getAllUniqueNodeIdsFromObjectType(MediaType._objectType);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
var dt = new MediaType(id);
|
||||
var allowed = dt.AllowedChildContentTypeIDs.ToList();
|
||||
if (allowed.Count() > 0)
|
||||
{
|
||||
parent = dt;
|
||||
child = new MediaType(allowed[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (parent == null || child == null)
|
||||
{
|
||||
throw new NotImplementedException("The umbraco install doesn't have document types that support a heirarchy");
|
||||
}
|
||||
|
||||
//now that we have a parent and a child, we need to create some documents
|
||||
var node1 = Media.MakeNew("FromCopy" + Guid.NewGuid().ToString("N"), parent, m_User, -1);
|
||||
Assert.IsTrue(node1.Id > 0);
|
||||
|
||||
var node2 = Media.MakeNew("ToCopy" + Guid.NewGuid().ToString("N"), parent, m_User, -1);
|
||||
Assert.IsTrue(node2.Id > 0);
|
||||
|
||||
//we now have 2 nodes in the root of the same type, we'll create a child node under node1 and move it to node2
|
||||
var childNode = Media.MakeNew("ChildCopy" + Guid.NewGuid().ToString("N"), child, m_User, node2.Id);
|
||||
Assert.IsTrue(childNode.Id > 0);
|
||||
|
||||
childNode.Move(node2.Id);
|
||||
Assert.AreEqual(node2.Id, childNode.Parent.Id);
|
||||
|
||||
RecycleAndDelete(childNode);
|
||||
RecycleAndDelete(node2);
|
||||
RecycleAndDelete(node1);
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
public void Media_DeleteAllDocsByDocumentTypeTest()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
|
||||
//create a new media type
|
||||
string name = "TEST-" + Guid.NewGuid().ToString("N");
|
||||
var mt = MediaType.MakeNew(m_User, name);
|
||||
|
||||
//test the media type
|
||||
Assert.AreEqual(DateTime.Now.Date, mt.CreateDateTime.Date);
|
||||
Assert.IsTrue(mt.Id > 0);
|
||||
|
||||
//allow itself to be created under itself
|
||||
mt.AllowedChildContentTypeIDs = new int[] { mt.Id };
|
||||
//create a tab
|
||||
mt.AddVirtualTab("TEST");
|
||||
|
||||
//test the tab
|
||||
var tabs = mt.getVirtualTabs.ToList();
|
||||
Assert.AreEqual(1, tabs.Count);
|
||||
|
||||
//create a property
|
||||
var allDataTypes = DataTypeDefinition.GetAll().ToList(); //get all definitions
|
||||
mt.AddPropertyType(allDataTypes[0], "testProperty", "Test Property"); //add a property type of the first type found in the list
|
||||
|
||||
//test the prop
|
||||
var prop = mt.getPropertyType("testProperty");
|
||||
Assert.AreEqual("Test Property", prop.Name);
|
||||
|
||||
//create 1st node
|
||||
var node1 = Media.MakeNew("TEST-" + Guid.NewGuid().ToString("N"), mt, m_User, -1);
|
||||
Assert.IsTrue(node1.Id > 0);
|
||||
|
||||
//create 2nd node underneath node 1
|
||||
var node2 = Media.MakeNew("TEST-" + Guid.NewGuid().ToString("N"), mt, m_User, node1.Id);
|
||||
Assert.IsTrue(node2.Id > 0);
|
||||
Assert.AreEqual(node1.Id, node2.Parent.Id);
|
||||
|
||||
//create 3rd node underneath node 2
|
||||
var node3 = Media.MakeNew("TEST-" + Guid.NewGuid().ToString("N"), mt, m_User, node2.Id);
|
||||
Assert.IsTrue(node3.Id > 0);
|
||||
Assert.AreEqual(node2.Id, node3.Parent.Id);
|
||||
|
||||
Media.DeleteFromType(mt);
|
||||
|
||||
Assert.IsFalse(Media.IsNode(node1.Id));
|
||||
Assert.IsFalse(Media.IsNode(node2.Id));
|
||||
Assert.IsFalse(Media.IsNode(node3.Id));
|
||||
|
||||
//now remove the document type created
|
||||
mt.delete();
|
||||
|
||||
Assert.IsFalse(MediaType.IsNode(mt.Id));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Media_EmptyRecycleBinTest()
|
||||
{
|
||||
//System.Diagnostics.Debugger.Break();
|
||||
|
||||
var mediaList = new List<Media>();
|
||||
var total = 20;
|
||||
var mt = m_ExistingMediaType;
|
||||
//allow the doc type to be created underneath itself
|
||||
mt.AllowedChildContentTypeIDs = new int[] { mt.Id };
|
||||
mt.Save();
|
||||
|
||||
//create 20 media nodes underneath each other, this will test deleting with heirarchy as well
|
||||
var lastParentId = -1;
|
||||
for (var i = 0; i < total; i++)
|
||||
{
|
||||
var newMedia = Media.MakeNew("R-" + i.ToString() + Guid.NewGuid().ToString("N"), mt, m_User, lastParentId);
|
||||
mediaList.Add(newMedia);
|
||||
Assert.IsTrue(mediaList[mediaList.Count - 1].Id > 0);
|
||||
Assert.AreEqual(lastParentId, newMedia.ParentId);
|
||||
lastParentId = newMedia.Id;
|
||||
}
|
||||
|
||||
//now delete all of them, since they are nested, we only need to delete one
|
||||
mediaList.First().delete();
|
||||
|
||||
//a callback action for each item removed from the recycle bin
|
||||
var totalDeleted = 0;
|
||||
|
||||
var bin = new RecycleBin(RecycleBin.RecycleBinType.Media);
|
||||
var totalTrashedItems = bin.GetDescendants().Cast<object>().Count();
|
||||
bin.CallTheGarbageMan(x =>
|
||||
{
|
||||
Assert.AreEqual(totalTrashedItems - (++totalDeleted), x);
|
||||
});
|
||||
|
||||
Assert.AreEqual(0, RecycleBin.Count(RecycleBin.RecycleBinType.Media));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Media_UndeleteTest()
|
||||
{
|
||||
//find existing content
|
||||
var media = new Media(GetExistingNodeId());
|
||||
//create new content based on the existing content in the same heirarchy
|
||||
var mt = new MediaType(media.ContentType.Id);
|
||||
var parentId = media.ParentId;
|
||||
var newMedia = Media.MakeNew("NewMedia" + Guid.NewGuid().ToString("N"), mt, m_User, parentId);
|
||||
Assert.IsTrue(newMedia.Id > 0);
|
||||
|
||||
//this will recycle the node
|
||||
newMedia.delete();
|
||||
Assert.IsTrue(newMedia.IsTrashed);
|
||||
Assert.IsTrue(newMedia.Path.Contains("," + (int)RecycleBin.RecycleBinType.Media + ","));
|
||||
|
||||
//undelete the node (move it)
|
||||
newMedia.Move(parentId);
|
||||
Assert.IsFalse(newMedia.IsTrashed);
|
||||
Assert.IsFalse(newMedia.Path.Contains("," + (int)RecycleBin.RecycleBinType.Media + ","));
|
||||
|
||||
//remove it completely
|
||||
RecycleAndDelete(newMedia);
|
||||
}
|
||||
|
||||
#region Tests to write
|
||||
|
||||
///// <summary>
|
||||
/////A test for Children
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void ChildrenTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Media target = new Media(id); // TODO: Initialize to an appropriate value
|
||||
// Media[] actual;
|
||||
// actual = target.Children;
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for Save
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void SaveTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Media target = new Media(id); // TODO: Initialize to an appropriate value
|
||||
// target.Save();
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetRootMedias
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetRootMediasTest()
|
||||
//{
|
||||
// Media[] expected = null; // TODO: Initialize to an appropriate value
|
||||
// Media[] actual;
|
||||
// actual = Media.GetRootMedias();
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for GetChildrenForTree
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void GetChildrenForTreeTest()
|
||||
//{
|
||||
// int nodeId = 0; // TODO: Initialize to an appropriate value
|
||||
// List<Media> expected = null; // TODO: Initialize to an appropriate value
|
||||
// List<Media> actual;
|
||||
// actual = Media.GetChildrenForTree(nodeId);
|
||||
// Assert.AreEqual(expected, actual);
|
||||
// Assert.Inconclusive("Verify the correctness of this test method.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for DeleteFromType
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void DeleteFromTypeTest()
|
||||
//{
|
||||
// MediaType dt = null; // TODO: Initialize to an appropriate value
|
||||
// Media.DeleteFromType(dt);
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
/////A test for delete
|
||||
/////</summary>
|
||||
//[TestMethod()]
|
||||
//public void deleteTest()
|
||||
//{
|
||||
// Guid id = new Guid(); // TODO: Initialize to an appropriate value
|
||||
// Media target = new Media(id); // TODO: Initialize to an appropriate value
|
||||
// target.delete();
|
||||
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region Private properties and methods
|
||||
|
||||
/// <summary>
|
||||
/// The user to be used to create stuff
|
||||
/// </summary>
|
||||
private User m_User = new User(0);
|
||||
|
||||
/// <summary>
|
||||
/// Used for each test initialization. Before each test is run a new root media is created.
|
||||
/// </summary>
|
||||
private Media m_NewRootMedia;
|
||||
|
||||
/// <summary>
|
||||
/// Gets initialized for each test and is set to an existing document type
|
||||
/// </summary>
|
||||
private MediaType m_ExistingMediaType;
|
||||
|
||||
private void RecycleAndDelete(Media m)
|
||||
{
|
||||
if (m == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var id = m.Id;
|
||||
|
||||
//check if it is already trashed
|
||||
var alreadyTrashed = m.IsTrashed;
|
||||
|
||||
if (!alreadyTrashed)
|
||||
{
|
||||
//now recycle it
|
||||
m.delete();
|
||||
|
||||
Assert.IsTrue(m.IsTrashed);
|
||||
}
|
||||
|
||||
//now permanently delete
|
||||
m.delete(true);
|
||||
Assert.IsFalse(Media.IsNode(id));
|
||||
|
||||
//check with sql that it is gone
|
||||
var count = Application.SqlHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM umbracoNode WHERE id=@id",
|
||||
Application.SqlHelper.CreateParameter("@id", id));
|
||||
|
||||
Assert.AreEqual(0, count);
|
||||
}
|
||||
|
||||
private int GetExistingNodeId()
|
||||
{
|
||||
var ids = Media.getAllUniqueNodeIdsFromObjectType(Media._objectType).ToList();
|
||||
var r = new Random();
|
||||
var index = r.Next(0, ids.Count() - 1);
|
||||
return ids[index];
|
||||
}
|
||||
|
||||
private Media CreateNewUnderRoot(MediaType mt)
|
||||
{
|
||||
string Name = "TEST-" + Guid.NewGuid().ToString("N");
|
||||
int ParentId = -1;
|
||||
Media actual = Media.MakeNew(Name, mt, m_User, ParentId);
|
||||
var id = actual.Id;
|
||||
Assert.IsTrue(actual.Id > 0);
|
||||
return actual;
|
||||
}
|
||||
|
||||
private MediaType GetExistingDocType()
|
||||
{
|
||||
MediaType dct = new MediaType(GetExistingMediaTypeId());
|
||||
Assert.IsTrue(dct.Id > 0);
|
||||
return dct;
|
||||
}
|
||||
|
||||
private MediaType GetExistingMediaType()
|
||||
{
|
||||
MediaType dct = new MediaType(GetExistingMediaTypeId());
|
||||
Assert.IsTrue(dct.Id > 0);
|
||||
return dct;
|
||||
}
|
||||
|
||||
private int GetExistingMediaTypeId()
|
||||
{
|
||||
var types = MediaType.GetAll.ToList();
|
||||
MediaType found = null;
|
||||
DataTypeNoEdit lblField = new DataTypeNoEdit();
|
||||
foreach (var d in types)
|
||||
{
|
||||
var prop = d.PropertyTypes
|
||||
.Where(x => x.DataTypeDefinition.DataType.Id == lblField.Id).FirstOrDefault();
|
||||
if (prop != null)
|
||||
{
|
||||
found = d;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == null)
|
||||
{
|
||||
throw new MissingMemberException("No media type was found that contains a label property");
|
||||
}
|
||||
return found.Id;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Test Context
|
||||
private TestContext testContextInstance;
|
||||
|
||||
/// <summary>
|
||||
///Gets or sets the test context which provides
|
||||
///information about and functionality for the current test run.
|
||||
///</summary>
|
||||
public TestContext TestContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return testContextInstance;
|
||||
}
|
||||
set
|
||||
{
|
||||
testContextInstance = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Initialize and cleanup
|
||||
//
|
||||
//You can use the following additional attributes as you write your tests:
|
||||
//
|
||||
//Use ClassInitialize to run code before running the first test in the class
|
||||
//[ClassInitialize()]
|
||||
//public static void MyClassInitialize(TestContext testContext)
|
||||
//{
|
||||
//}
|
||||
//
|
||||
//Use ClassCleanup to run code after all tests in a class have run
|
||||
//[ClassCleanup()]
|
||||
//public static void MyClassCleanup()
|
||||
//{
|
||||
//}
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new root document to use for each test if required
|
||||
/// </summary>
|
||||
[TestInitialize()]
|
||||
public void MyTestInitialize()
|
||||
{
|
||||
m_ExistingMediaType = GetExistingMediaType();
|
||||
m_NewRootMedia = CreateNewUnderRoot(m_ExistingMediaType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes sure the root doc is deleted
|
||||
/// </summary>
|
||||
[TestCleanup()]
|
||||
public void MyTestCleanup()
|
||||
{
|
||||
RecycleAndDelete(m_NewRootMedia);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DocumentTest.cs" />
|
||||
<Compile Include="DocumentTypeTest.cs" />
|
||||
<Compile Include="MediaTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
26
umbraco.sln
26
umbraco.sln
@@ -152,82 +152,56 @@ Global
|
||||
CategoryFile = umbraco.vsmdi
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug - Fixed Version|Any CPU = Debug - Fixed Version|Any CPU
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{651E1350-91B6-44B7-BD60-7207006D7003}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{651E1350-91B6-44B7-BD60-7207006D7003}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{651E1350-91B6-44B7-BD60-7207006D7003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{651E1350-91B6-44B7-BD60-7207006D7003}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{651E1350-91B6-44B7-BD60-7207006D7003}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{651E1350-91B6-44B7-BD60-7207006D7003}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E469A9CE-1BEC-423F-AC44-713CD72457EA}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E469A9CE-1BEC-423F-AC44-713CD72457EA}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E469A9CE-1BEC-423F-AC44-713CD72457EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E469A9CE-1BEC-423F-AC44-713CD72457EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E469A9CE-1BEC-423F-AC44-713CD72457EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E469A9CE-1BEC-423F-AC44-713CD72457EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CCD75EC3-63DB-4184-B49D-51C1DD337230}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CCD75EC3-63DB-4184-B49D-51C1DD337230}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CCD75EC3-63DB-4184-B49D-51C1DD337230}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CCD75EC3-63DB-4184-B49D-51C1DD337230}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CCD75EC3-63DB-4184-B49D-51C1DD337230}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CCD75EC3-63DB-4184-B49D-51C1DD337230}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{511F6D8D-7717-440A-9A57-A507E9A8B27F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{255F5DF1-4E43-4758-AC05-7A0B68EB021B}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{255F5DF1-4E43-4758-AC05-7A0B68EB021B}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{255F5DF1-4E43-4758-AC05-7A0B68EB021B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{255F5DF1-4E43-4758-AC05-7A0B68EB021B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{255F5DF1-4E43-4758-AC05-7A0B68EB021B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{255F5DF1-4E43-4758-AC05-7A0B68EB021B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{52AB8F1F-FB76-4E8C-885F-0747B6CE71EC}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{52AB8F1F-FB76-4E8C-885F-0747B6CE71EC}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{52AB8F1F-FB76-4E8C-885F-0747B6CE71EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{52AB8F1F-FB76-4E8C-885F-0747B6CE71EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{52AB8F1F-FB76-4E8C-885F-0747B6CE71EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{52AB8F1F-FB76-4E8C-885F-0747B6CE71EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D7636876-0756-43CB-A192-138C6F0D5E42}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6EDD2061-82F2-461B-BB6E-879245A832DE}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6EDD2061-82F2-461B-BB6E-879245A832DE}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6EDD2061-82F2-461B-BB6E-879245A832DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6EDD2061-82F2-461B-BB6E-879245A832DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6EDD2061-82F2-461B-BB6E-879245A832DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6EDD2061-82F2-461B-BB6E-879245A832DE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{31CAEC36-0C3D-4D69-B092-84866811EA07}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug - Fixed Version|Any CPU
|
||||
{31CAEC36-0C3D-4D69-B092-84866811EA07}.Debug - Fixed Version|Any CPU.Build.0 = Debug - Fixed Version|Any CPU
|
||||
{31CAEC36-0C3D-4D69-B092-84866811EA07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{31CAEC36-0C3D-4D69-B092-84866811EA07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{31CAEC36-0C3D-4D69-B092-84866811EA07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{31CAEC36-0C3D-4D69-B092-84866811EA07}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{27A2590E-1313-4A33-89FD-92811540B69C}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27A2590E-1313-4A33-89FD-92811540B69C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27A2590E-1313-4A33-89FD-92811540B69C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Debug - Fixed Version|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Debug - Fixed Version|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6277C9FB-3A9A-4537-AA86-82DA9B2527FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace umbraco
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
return ConfigurationManager.AppSettings["umbracoPath"];
|
||||
@@ -117,19 +117,19 @@ namespace umbraco
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to umbraco's client directory (/umbraco_client by default).
|
||||
/// This is a relative path to the Umbraco Path as it always must exist beside the 'umbraco'
|
||||
/// folder since the CSS paths to images depend on it.
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public static string ClientPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path + "/../umbraco_client";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the path to umbraco's client directory (/umbraco_client by default).
|
||||
/// This is a relative path to the Umbraco Path as it always must exist beside the 'umbraco'
|
||||
/// folder since the CSS paths to images depend on it.
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public static string ClientPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path + "/../umbraco_client";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the database connection string
|
||||
@@ -150,7 +150,7 @@ namespace umbraco
|
||||
}
|
||||
set
|
||||
{
|
||||
if(DbDSN!=value)
|
||||
if (DbDSN != value)
|
||||
SaveSetting("umbracoDbDSN", value);
|
||||
}
|
||||
}
|
||||
@@ -178,32 +178,39 @@ namespace umbraco
|
||||
}
|
||||
}
|
||||
|
||||
private static AspNetHostingPermissionLevel m_ApplicationTrustLevel;
|
||||
public static AspNetHostingPermissionLevel ApplicationTrustLevel {
|
||||
get{
|
||||
if (m_ApplicationTrustLevel != AspNetHostingPermissionLevel.None) {
|
||||
private static AspNetHostingPermissionLevel? m_ApplicationTrustLevel = null;
|
||||
public static AspNetHostingPermissionLevel ApplicationTrustLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!m_ApplicationTrustLevel.HasValue)
|
||||
{
|
||||
//set minimum
|
||||
m_ApplicationTrustLevel = AspNetHostingPermissionLevel.None;
|
||||
|
||||
foreach (AspNetHostingPermissionLevel trustLevel in
|
||||
new AspNetHostingPermissionLevel[] {
|
||||
AspNetHostingPermissionLevel.Unrestricted,
|
||||
AspNetHostingPermissionLevel.High,
|
||||
AspNetHostingPermissionLevel.Medium,
|
||||
AspNetHostingPermissionLevel.Low,
|
||||
AspNetHostingPermissionLevel.Minimal
|
||||
}) {
|
||||
try {
|
||||
new AspNetHostingPermission(trustLevel).Demand();
|
||||
} catch (System.Security.SecurityException) {
|
||||
continue;
|
||||
//determine maximum
|
||||
foreach (AspNetHostingPermissionLevel trustLevel in
|
||||
new AspNetHostingPermissionLevel[] {
|
||||
AspNetHostingPermissionLevel.Unrestricted,
|
||||
AspNetHostingPermissionLevel.High,
|
||||
AspNetHostingPermissionLevel.Medium,
|
||||
AspNetHostingPermissionLevel.Low,
|
||||
AspNetHostingPermissionLevel.Minimal
|
||||
})
|
||||
{
|
||||
try
|
||||
{
|
||||
new AspNetHostingPermission(trustLevel).Demand();
|
||||
m_ApplicationTrustLevel = trustLevel;
|
||||
break; //we've set the highest permission we can
|
||||
}
|
||||
catch (System.Security.SecurityException)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m_ApplicationTrustLevel = trustLevel;
|
||||
}
|
||||
|
||||
m_ApplicationTrustLevel = AspNetHostingPermissionLevel.None;
|
||||
}
|
||||
|
||||
return m_ApplicationTrustLevel;
|
||||
return m_ApplicationTrustLevel.Value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,14 +219,19 @@ namespace umbraco
|
||||
/// Forces umbraco to be medium trust compatible
|
||||
/// </summary>
|
||||
/// <value>If true, umbraco will be medium-trust compatible, no matter what Permission level the server is on.</value>
|
||||
public static bool UseMediumTrust {
|
||||
get {
|
||||
try {
|
||||
public static bool UseMediumTrust
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ApplicationTrustLevel == AspNetHostingPermissionLevel.High || ApplicationTrustLevel == AspNetHostingPermissionLevel.Unrestricted)
|
||||
return false;
|
||||
else
|
||||
else
|
||||
return bool.Parse(ConfigurationManager.AppSettings["umbracoUseMediumTrust"]);
|
||||
}catch {
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -233,8 +245,10 @@ namespace umbraco
|
||||
protected static void SaveSetting(string key, string value)
|
||||
{
|
||||
WebConfigurationFileMap webConfig = new WebConfigurationFileMap();
|
||||
foreach (VirtualDirectoryMapping v in webConfig.VirtualDirectories) {
|
||||
if (v.IsAppRoot) {
|
||||
foreach (VirtualDirectoryMapping v in webConfig.VirtualDirectories)
|
||||
{
|
||||
if (v.IsAppRoot)
|
||||
{
|
||||
Configuration config = WebConfigurationManager.OpenWebConfiguration(v.VirtualDirectory);
|
||||
config.AppSettings.Settings[key].Value = value;
|
||||
config.Save();
|
||||
@@ -250,7 +264,7 @@ namespace umbraco
|
||||
/* Configuration config =
|
||||
ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -309,12 +323,12 @@ namespace umbraco
|
||||
string configStatus = ConfigurationStatus;
|
||||
string currentVersion = CurrentVersion;
|
||||
|
||||
|
||||
|
||||
if (currentVersion != configStatus)
|
||||
Log.Add(LogTypes.Debug, User.GetUser(0), -1,
|
||||
"CurrentVersion different from configStatus: '" + currentVersion + "','" + configStatus +
|
||||
"'");
|
||||
|
||||
|
||||
return (configStatus == currentVersion);
|
||||
}
|
||||
catch
|
||||
@@ -420,7 +434,7 @@ namespace umbraco
|
||||
try
|
||||
{
|
||||
System.Net.Configuration.MailSettingsSectionGroup mailSettings = ConfigurationManager.GetSection("system.net/mailSettings") as System.Net.Configuration.MailSettingsSectionGroup;
|
||||
|
||||
|
||||
if (mailSettings != null)
|
||||
return mailSettings.Smtp.Network.Host;
|
||||
else
|
||||
@@ -525,8 +539,10 @@ namespace umbraco
|
||||
/// Gets a value indicating whether statistic logging happens async.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if async stats logging is enabled; otherwise, <c>false</c>.</value>
|
||||
public static bool EnableAsyncStatLogging {
|
||||
get {
|
||||
public static bool EnableAsyncStatLogging
|
||||
{
|
||||
get
|
||||
{
|
||||
string value = ConfigurationManager.AppSettings["umbracoAsyncStatLogging"];
|
||||
bool result;
|
||||
if (!string.IsNullOrEmpty(value) && bool.TryParse(value, out result))
|
||||
@@ -611,7 +627,7 @@ namespace umbraco
|
||||
/// <returns></returns>
|
||||
public static bool RequestIsInUmbracoApplication(HttpContext context)
|
||||
{
|
||||
return context.Request.Path.ToLower().IndexOf( IOHelper.ResolveUrl( SystemDirectories.Umbraco ) .ToLower()) > -1;
|
||||
return context.Request.Path.ToLower().IndexOf(IOHelper.ResolveUrl(SystemDirectories.Umbraco).ToLower()) > -1;
|
||||
}
|
||||
|
||||
public static bool RequestIsLiveEditRedirector(HttpContext context)
|
||||
@@ -623,7 +639,7 @@ namespace umbraco
|
||||
/// Gets a value indicating whether umbraco should force a secure (https) connection to the backoffice.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [use SSL]; otherwise, <c>false</c>.</value>
|
||||
public static bool UseSSL
|
||||
public static bool UseSSL
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -715,8 +731,8 @@ namespace umbraco
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified URL is reserved or is inside a reserved path.
|
||||
@@ -772,7 +788,7 @@ namespace umbraco
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Structure that checks in logarithmic time
|
||||
@@ -845,7 +861,7 @@ namespace umbraco
|
||||
// let the default string comparer deal with null or when part is not smaller then whole
|
||||
if (part == null || whole == null || part.Length >= whole.Length)
|
||||
return _stringComparer.Compare(part, whole);
|
||||
|
||||
|
||||
// loop through all characters that part and whole have in common
|
||||
int pos = 0;
|
||||
bool match;
|
||||
|
||||
@@ -58,23 +58,25 @@ namespace umbraco.BusinessLogic.Utils
|
||||
sandbox = AppDomain.CreateDomain("Sandbox", AppDomain.CurrentDomain.Evidence, domainSetup);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
TypeResolver typeResolver = (TypeResolver)sandbox.CreateInstanceAndUnwrap(
|
||||
typeof(TypeResolver).Assembly.GetName().Name,
|
||||
typeof(TypeResolver).FullName);
|
||||
try
|
||||
{
|
||||
TypeResolver typeResolver = (TypeResolver)sandbox.CreateInstanceAndUnwrap(
|
||||
typeof(TypeResolver).Assembly.GetName().Name,
|
||||
typeof(TypeResolver).FullName);
|
||||
|
||||
return typeResolver.GetTypes(typeof(T), files);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
if ((!GlobalSettings.UseMediumTrust) && (GlobalSettings.ApplicationTrustLevel > AspNetHostingPermissionLevel.Medium)) {
|
||||
AppDomain.Unload(sandbox);
|
||||
return typeResolver.GetTypes(typeof(T), files);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ((!GlobalSettings.UseMediumTrust) && (GlobalSettings.ApplicationTrustLevel > AspNetHostingPermissionLevel.Medium))
|
||||
{
|
||||
AppDomain.Unload(sandbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
@@ -370,7 +370,6 @@ namespace umbraco.cms.businesslogic
|
||||
|
||||
if (Deep)
|
||||
{
|
||||
//store children array here because iterating over an Array object is very inneficient.
|
||||
var childs = this.Children;
|
||||
foreach (BusinessLogic.console.IconI c in childs)
|
||||
{
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace umbraco.cms.businesslogic
|
||||
itemDeletedCallback(RecycleBin.Count(m_BinType));
|
||||
break;
|
||||
case RecycleBinType.Media:
|
||||
new Media(c.Id).delete();
|
||||
new Media(c.Id).delete(true);
|
||||
itemDeletedCallback(RecycleBin.Count(m_BinType));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using umbraco.IO;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
|
||||
namespace umbraco.cms.businesslogic.media
|
||||
{
|
||||
@@ -16,7 +17,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// </summary>
|
||||
public class Media : Content
|
||||
{
|
||||
private const string m_SQLOptimizedChildren = @"
|
||||
#region Constants and static members
|
||||
private const string m_SQLOptimizedMany = @"
|
||||
select
|
||||
count(children.id) as children, umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text,
|
||||
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId
|
||||
@@ -27,23 +29,163 @@ namespace umbraco.cms.businesslogic.media
|
||||
where {0}
|
||||
group by umbracoNode.id, umbracoNode.uniqueId, umbracoNode.level, umbracoNode.parentId, umbracoNode.path, umbracoNode.sortOrder, umbracoNode.createDate, umbracoNode.nodeUser, umbracoNode.text,
|
||||
cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId
|
||||
order by {1}";
|
||||
order by {1}";
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Contructs a media object given the Id
|
||||
/// </summary>
|
||||
/// <param name="id">Identifier</param>
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Contructs a media object given the Id
|
||||
/// </summary>
|
||||
/// <param name="id">Identifier</param>
|
||||
public Media(int id) : base(id) { }
|
||||
|
||||
/// <summary>
|
||||
/// Contructs a media object given the Id
|
||||
/// </summary>
|
||||
/// <param name="id">Identifier</param>
|
||||
/// <summary>
|
||||
/// Contructs a media object given the Id
|
||||
/// </summary>
|
||||
/// <param name="id">Identifier</param>
|
||||
public Media(Guid id) : base(id) { }
|
||||
|
||||
public Media(int id, bool noSetup) : base(id, noSetup) { }
|
||||
|
||||
public Media(bool optimizedMode, int id) : base(id, optimizedMode) { }
|
||||
public Media(bool optimizedMode, int id) : base(id, optimizedMode) { }
|
||||
#endregion
|
||||
|
||||
#region Static Methods
|
||||
/// <summary>
|
||||
/// -
|
||||
/// </summary>
|
||||
public static Guid _objectType = new Guid("b796f64c-1f99-4ffb-b886-4bf4bc011a9c");
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Media
|
||||
/// </summary>
|
||||
/// <param name="Name">The name of the media</param>
|
||||
/// <param name="dct">The type of the media</param>
|
||||
/// <param name="u">The user creating the media</param>
|
||||
/// <param name="ParentId">The id of the folder under which the media is created</param>
|
||||
/// <returns></returns>
|
||||
public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
|
||||
{
|
||||
Guid newId = Guid.NewGuid();
|
||||
// Updated to match level from base node
|
||||
CMSNode n = new CMSNode(ParentId);
|
||||
int newLevel = n.Level;
|
||||
newLevel++;
|
||||
CMSNode.MakeNew(ParentId, _objectType, u.Id, newLevel, Name, newId);
|
||||
Media tmp = new Media(newId);
|
||||
tmp.CreateContent(dct);
|
||||
|
||||
NewEventArgs e = new NewEventArgs();
|
||||
tmp.OnNew(e);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a list of all toplevel medias and folders
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Media[] GetRootMedias()
|
||||
{
|
||||
Guid[] topNodeIds = CMSNode.TopMostNodeIds(_objectType);
|
||||
|
||||
Media[] retval = new Media[topNodeIds.Length];
|
||||
for (int i = 0; i < topNodeIds.Length; i++)
|
||||
{
|
||||
Media d = new Media(topNodeIds[i]);
|
||||
retval[i] = d;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static List<Media> GetChildrenForTree(int nodeId)
|
||||
{
|
||||
|
||||
List<Media> tmp = new List<Media>();
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader(
|
||||
string.Format(m_SQLOptimizedMany
|
||||
, "umbracoNode.parentID = @parentId And umbracoNode.nodeObjectType = @type"
|
||||
, "umbracoNode.sortOrder")
|
||||
, SqlHelper.CreateParameter("@type", _objectType)
|
||||
, SqlHelper.CreateParameter("@parentId", nodeId)))
|
||||
{
|
||||
|
||||
while (dr.Read())
|
||||
{
|
||||
Media d = new Media(dr.GetInt("id"), true);
|
||||
d.PopulateMediaFromReader(dr);
|
||||
tmp.Add(d);
|
||||
}
|
||||
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public static IEnumerable<Media> GetMediaOfMediaType(int mediaTypeId)
|
||||
{
|
||||
var tmp = new List<Media>();
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader(
|
||||
string.Format(m_SQLOptimizedMany, "cmsContent.contentType = @contentTypeId", "umbracoNode.sortOrder"),
|
||||
SqlHelper.CreateParameter("@contentTypeId", mediaTypeId)))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
Media d = new Media(dr.GetInt("id"), true);
|
||||
d.PopulateMediaFromReader(dr);
|
||||
tmp.Add(d);
|
||||
}
|
||||
}
|
||||
|
||||
return tmp.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all medias of the given type, used when deleting a mediatype
|
||||
///
|
||||
/// Use with care.
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
public static void DeleteFromType(MediaType dt)
|
||||
{
|
||||
//get all document for the document type and order by level (top level first)
|
||||
var medias = Media.GetMediaOfMediaType(dt.Id)
|
||||
.OrderByDescending(x => x.Level);
|
||||
|
||||
foreach (Media media in medias)
|
||||
{
|
||||
//before we delete this document, we need to make sure we don't end up deleting other documents that
|
||||
//are not of this document type that are children. So we'll move all of it's children to the trash first.
|
||||
foreach (Media m in media.GetDescendants())
|
||||
{
|
||||
if (m.ContentType.Id != dt.Id)
|
||||
{
|
||||
m.MoveToTrash();
|
||||
}
|
||||
}
|
||||
|
||||
media.DeletePermanently();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Retrieve a list of all medias underneath the current
|
||||
/// </summary>
|
||||
public new Media[] Children
|
||||
{
|
||||
get
|
||||
{
|
||||
//return refactored optimized method
|
||||
return Media.GetChildrenForTree(this.Id).ToArray();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility
|
||||
@@ -53,7 +195,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
SaveEventArgs e = new SaveEventArgs();
|
||||
FireBeforeSave(e);
|
||||
|
||||
if (!e.Cancel) {
|
||||
if (!e.Cancel)
|
||||
{
|
||||
|
||||
base.Save();
|
||||
|
||||
@@ -71,227 +214,178 @@ namespace umbraco.cms.businesslogic.media
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// -
|
||||
/// </summary>
|
||||
public static Guid _objectType = new Guid("b796f64c-1f99-4ffb-b886-4bf4bc011a9c");
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Media
|
||||
/// </summary>
|
||||
/// <param name="Name">The name of the media</param>
|
||||
/// <param name="dct">The type of the media</param>
|
||||
/// <param name="u">The user creating the media</param>
|
||||
/// <param name="ParentId">The id of the folder under which the media is created</param>
|
||||
/// <returns></returns>
|
||||
public static Media MakeNew(string Name, MediaType dct, BusinessLogic.User u, int ParentId)
|
||||
{
|
||||
Guid newId = Guid.NewGuid();
|
||||
// Updated to match level from base node
|
||||
CMSNode n = new CMSNode(ParentId);
|
||||
int newLevel = n.Level;
|
||||
newLevel++;
|
||||
CMSNode.MakeNew(ParentId,_objectType, u.Id, newLevel, Name, newId);
|
||||
Media tmp = new Media(newId);
|
||||
tmp.CreateContent(dct);
|
||||
|
||||
NewEventArgs e = new NewEventArgs();
|
||||
tmp.OnNew(e);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a list of all toplevel medias and folders
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Media[] GetRootMedias()
|
||||
{
|
||||
Guid[] topNodeIds = CMSNode.TopMostNodeIds(_objectType);
|
||||
|
||||
Media[] retval = new Media[topNodeIds.Length];
|
||||
for (int i = 0;i < topNodeIds.Length;i++)
|
||||
{
|
||||
Media d = new Media(topNodeIds[i]);
|
||||
retval[i] = d;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a list of all medias underneath the current
|
||||
/// </summary>
|
||||
new public Media[] Children
|
||||
{
|
||||
get
|
||||
{
|
||||
//return refactored optimized method
|
||||
return Media.GetChildrenForTree(this.Id).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Media> GetChildrenForTree(int nodeId)
|
||||
{
|
||||
|
||||
List<Media> tmp = new List<Media>();
|
||||
using (IRecordsReader dr =
|
||||
SqlHelper.ExecuteReader(
|
||||
string.Format(m_SQLOptimizedChildren
|
||||
, "umbracoNode.parentID = @parentId And umbracoNode.nodeObjectType = @type"
|
||||
, "umbracoNode.sortOrder")
|
||||
, SqlHelper.CreateParameter("@type", _objectType)
|
||||
, SqlHelper.CreateParameter("@parentId", nodeId)))
|
||||
{
|
||||
|
||||
while (dr.Read())
|
||||
{
|
||||
Media d = new Media(dr.GetInt("id"), true);
|
||||
bool _hc = false;
|
||||
if (dr.GetInt("children") > 0)
|
||||
_hc = true;
|
||||
int? masterContentType = null;
|
||||
if (!dr.IsNull("masterContentType"))
|
||||
masterContentType = dr.GetInt("masterContentType");
|
||||
d.SetupMediaForTree(dr.GetGuid("uniqueId")
|
||||
, dr.GetShort("level")
|
||||
, dr.GetInt("parentId")
|
||||
, dr.GetInt("nodeUser")
|
||||
, dr.GetString("path")
|
||||
, dr.GetString("text")
|
||||
, dr.GetDateTime("createDate")
|
||||
, dr.GetString("icon")
|
||||
, _hc
|
||||
, dr.GetString("alias")
|
||||
, dr.GetString("thumbnail")
|
||||
, dr.GetString("description")
|
||||
, masterContentType
|
||||
, dr.GetInt("contentTypeId"));
|
||||
tmp.Add(d);
|
||||
}
|
||||
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private void SetupMediaForTree(Guid uniqueId, int level, int parentId, int user, string path,
|
||||
string text, DateTime createDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb,
|
||||
string contentTypeDesc, int? masterContentType, int contentTypeId)
|
||||
{
|
||||
SetupNodeForTree(uniqueId, _objectType, level, parentId, user, path, text, createDate, hasChildren);
|
||||
ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType);
|
||||
ContentTypeIcon = icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all medias of the given type, used when deleting a mediatype
|
||||
///
|
||||
/// Use with care.
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
public static void DeleteFromType(MediaType dt)
|
||||
{
|
||||
var objs = Media.getContentOfContentType(dt);
|
||||
foreach (Content c in objs)
|
||||
{
|
||||
// due to recursive structure document might already been deleted..
|
||||
if (CMSNode.IsNode(c.UniqueId))
|
||||
{
|
||||
Media tmp = new Media(c.UniqueId);
|
||||
tmp.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the current media and all children.
|
||||
/// </summary>
|
||||
public override void delete()
|
||||
{
|
||||
// Check for recyle bin
|
||||
if (!Path.Contains("," + ((int)RecycleBin.RecycleBinType.Media).ToString() + ","))
|
||||
{
|
||||
MoveToTrashEventArgs e = new MoveToTrashEventArgs();
|
||||
FireBeforeMoveToTrash(e);
|
||||
/// Moves the media to the trash
|
||||
/// </summary>
|
||||
public override void delete()
|
||||
{
|
||||
MoveToTrash();
|
||||
}
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
Move((int)RecycleBin.RecycleBinType.Media);
|
||||
/// <summary>
|
||||
/// With either move the media to the trash or permanently remove it from the database.
|
||||
/// </summary>
|
||||
/// <param name="deletePermanently">flag to set whether or not to completely remove it from the database or just send to trash</param>
|
||||
public void delete(bool deletePermanently)
|
||||
{
|
||||
if (!deletePermanently)
|
||||
{
|
||||
MoveToTrash();
|
||||
}
|
||||
else
|
||||
{
|
||||
DeletePermanently();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Now that we've moved it to trash, we need to move the actual files so they are no longer accessible
|
||||
//from the original URL.
|
||||
public override IEnumerable GetDescendants()
|
||||
{
|
||||
var tmp = new List<Media>();
|
||||
using (IRecordsReader dr = SqlHelper.ExecuteReader(
|
||||
string.Format(m_SQLOptimizedMany, "umbracoNode.path LIKE '%," + this.Id + ",%'", "umbracoNode.level")))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
Media d = new Media(dr.GetInt("id"), true);
|
||||
d.PopulateMediaFromReader(dr);
|
||||
tmp.Add(d);
|
||||
}
|
||||
}
|
||||
|
||||
FireAfterMoveToTrash(e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DeleteEventArgs e = new DeleteEventArgs();
|
||||
return tmp.ToArray();
|
||||
}
|
||||
|
||||
FireBeforeDelete(e);
|
||||
#endregion
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
var children = this.Children;
|
||||
foreach (Media d in children)
|
||||
{
|
||||
d.delete();
|
||||
}
|
||||
#region Protected methods
|
||||
protected void PopulateMediaFromReader(IRecordsReader dr)
|
||||
{
|
||||
bool _hc = false;
|
||||
if (dr.GetInt("children") > 0)
|
||||
_hc = true;
|
||||
int? masterContentType = null;
|
||||
if (!dr.IsNull("masterContentType"))
|
||||
masterContentType = dr.GetInt("masterContentType");
|
||||
SetupMediaForTree(dr.GetGuid("uniqueId")
|
||||
, dr.GetShort("level")
|
||||
, dr.GetInt("parentId")
|
||||
, dr.GetInt("nodeUser")
|
||||
, dr.GetString("path")
|
||||
, dr.GetString("text")
|
||||
, dr.GetDateTime("createDate")
|
||||
, dr.GetString("icon")
|
||||
, _hc
|
||||
, dr.GetString("alias")
|
||||
, dr.GetString("thumbnail")
|
||||
, dr.GetString("description")
|
||||
, masterContentType
|
||||
, dr.GetInt("contentTypeId"));
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Remove all files
|
||||
interfaces.IDataType uploadField = new cms.businesslogic.datatype.controls.Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"));
|
||||
var props = this.getProperties;
|
||||
foreach (cms.businesslogic.property.Property p in props)
|
||||
{
|
||||
FileInfo mediaFile = new FileInfo(IOHelper.MapPath(p.Value.ToString()));
|
||||
#region Private methods
|
||||
private void SetupMediaForTree(Guid uniqueId, int level, int parentId, int user, string path,
|
||||
string text, DateTime createDate, string icon, bool hasChildren, string contentTypeAlias, string contentTypeThumb,
|
||||
string contentTypeDesc, int? masterContentType, int contentTypeId)
|
||||
{
|
||||
SetupNodeForTree(uniqueId, _objectType, level, parentId, user, path, text, createDate, hasChildren);
|
||||
ContentType = new ContentType(contentTypeId, contentTypeAlias, icon, contentTypeThumb, masterContentType);
|
||||
ContentTypeIcon = icon;
|
||||
}
|
||||
|
||||
if (p.PropertyType.DataTypeDefinition.DataType.Id == uploadField.Id
|
||||
&& p.Value.ToString() != ""
|
||||
&& mediaFile.Exists)
|
||||
{
|
||||
/// <summary>
|
||||
/// Used internally to permanently delete the data from the database
|
||||
/// </summary>
|
||||
/// <returns>returns true if deletion isn't cancelled</returns>
|
||||
private bool DeletePermanently()
|
||||
{
|
||||
DeleteEventArgs e = new DeleteEventArgs();
|
||||
|
||||
mediaFile.Delete();
|
||||
FireBeforeDelete(e);
|
||||
|
||||
string file = p.Value.ToString();
|
||||
string extension = ((string)file.Substring(file.LastIndexOf(".") + 1, file.Length - file.LastIndexOf(".") - 1)).ToLower();
|
||||
if (!e.Cancel)
|
||||
{
|
||||
foreach (Media m in Children.ToList())
|
||||
{
|
||||
m.DeletePermanently();
|
||||
}
|
||||
|
||||
//check for thumbnail
|
||||
if (",jpeg,jpg,gif,bmp,png,tiff,tif,".IndexOf("," + extension + ",") > -1)
|
||||
{
|
||||
string thumbnailfile = file.Replace("." + extension, "_thumb");
|
||||
// Remove all files
|
||||
interfaces.IDataType uploadField = new cms.businesslogic.datatype.controls.Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"));
|
||||
foreach (cms.businesslogic.property.Property p in this.getProperties.ToList())
|
||||
{
|
||||
FileInfo mediaFile = new FileInfo(IOHelper.MapPath(p.Value.ToString()));
|
||||
|
||||
if (System.IO.File.Exists(IOHelper.MapPath(thumbnailfile + ".jpg")))
|
||||
System.IO.File.Delete(IOHelper.MapPath(thumbnailfile + ".jpg"));
|
||||
if (p.PropertyType.DataTypeDefinition.DataType.Id == uploadField.Id
|
||||
&& p.Value.ToString() != ""
|
||||
&& mediaFile.Exists)
|
||||
{
|
||||
|
||||
//should also delete extra thumbnails
|
||||
}
|
||||
mediaFile.Delete();
|
||||
|
||||
}
|
||||
string file = p.Value.ToString();
|
||||
string extension = ((string)file.Substring(file.LastIndexOf(".") + 1, file.Length - file.LastIndexOf(".") - 1)).ToLower();
|
||||
|
||||
}
|
||||
//check for thumbnail
|
||||
if (",jpeg,jpg,gif,bmp,png,tiff,tif,".IndexOf("," + extension + ",") > -1)
|
||||
{
|
||||
string thumbnailfile = file.Replace("." + extension, "_thumb");
|
||||
|
||||
base.delete();
|
||||
if (System.IO.File.Exists(IOHelper.MapPath(thumbnailfile + ".jpg")))
|
||||
System.IO.File.Delete(IOHelper.MapPath(thumbnailfile + ".jpg"));
|
||||
|
||||
FireAfterDelete(e);
|
||||
}
|
||||
}
|
||||
//should also delete extra thumbnails
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
base.delete();
|
||||
|
||||
FireAfterDelete(e);
|
||||
}
|
||||
return !e.Cancel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used internally to move the node to the recyle bin
|
||||
/// </summary>
|
||||
/// <returns>Returns true if the move was not cancelled</returns>
|
||||
private bool MoveToTrash()
|
||||
{
|
||||
MoveToTrashEventArgs e = new MoveToTrashEventArgs();
|
||||
FireBeforeMoveToTrash(e);
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
Move((int)RecycleBin.RecycleBinType.Media);
|
||||
|
||||
//TODO: Now that we've moved it to trash, we need to move the actual files so they are no longer accessible
|
||||
//from the original URL.
|
||||
|
||||
FireAfterMoveToTrash(e);
|
||||
}
|
||||
return !e.Cancel;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
//EVENTS
|
||||
/// <summary>
|
||||
/// The save event handler
|
||||
/// </summary>
|
||||
public new delegate void SaveEventHandler(Media sender, SaveEventArgs e);
|
||||
public delegate void SaveEventHandler(Media sender, SaveEventArgs e);
|
||||
/// <summary>
|
||||
/// The new event handler
|
||||
/// </summary>
|
||||
public new delegate void NewEventHandler(Media sender, NewEventArgs e);
|
||||
public delegate void NewEventHandler(Media sender, NewEventArgs e);
|
||||
/// <summary>
|
||||
/// The delete event handler
|
||||
/// </summary>
|
||||
public new delegate void DeleteEventHandler(Media sender, DeleteEventArgs e);
|
||||
public delegate void DeleteEventHandler(Media sender, DeleteEventArgs e);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -302,7 +396,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// Raises the <see cref="E:BeforeSave"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected new virtual void FireBeforeSave(SaveEventArgs e) {
|
||||
protected new virtual void FireBeforeSave(SaveEventArgs e)
|
||||
{
|
||||
if (BeforeSave != null)
|
||||
BeforeSave(this, e);
|
||||
}
|
||||
@@ -315,7 +410,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// Raises the <see cref="E:AfterSave"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected new virtual void FireAfterSave(SaveEventArgs e) {
|
||||
protected new virtual void FireAfterSave(SaveEventArgs e)
|
||||
{
|
||||
if (AfterSave != null)
|
||||
AfterSave(this, e);
|
||||
}
|
||||
@@ -323,12 +419,13 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// <summary>
|
||||
/// Occurs when [new].
|
||||
/// </summary>
|
||||
public new static event NewEventHandler New;
|
||||
public static event NewEventHandler New;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:New"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected new virtual void OnNew(NewEventArgs e) {
|
||||
protected virtual void OnNew(NewEventArgs e)
|
||||
{
|
||||
if (New != null)
|
||||
New(this, e);
|
||||
}
|
||||
@@ -341,7 +438,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// Raises the <see cref="E:BeforeDelete"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected new virtual void FireBeforeDelete(DeleteEventArgs e) {
|
||||
protected new virtual void FireBeforeDelete(DeleteEventArgs e)
|
||||
{
|
||||
if (BeforeDelete != null)
|
||||
BeforeDelete(this, e);
|
||||
}
|
||||
@@ -354,42 +452,44 @@ namespace umbraco.cms.businesslogic.media
|
||||
/// Raises the <see cref="E:AfterDelete"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected new virtual void FireAfterDelete(DeleteEventArgs e) {
|
||||
protected new virtual void FireAfterDelete(DeleteEventArgs e)
|
||||
{
|
||||
if (AfterDelete != null)
|
||||
AfterDelete(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Move to trash event handler
|
||||
/// </summary>
|
||||
public delegate void MoveToTrashEventHandler(Media sender, MoveToTrashEventArgs e);
|
||||
/// <summary>
|
||||
/// Occurs when [before delete].
|
||||
/// </summary>
|
||||
public static event MoveToTrashEventHandler BeforeMoveToTrash;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:BeforeDelete"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void FireBeforeMoveToTrash(MoveToTrashEventArgs e)
|
||||
{
|
||||
if (BeforeMoveToTrash != null)
|
||||
BeforeMoveToTrash(this, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// The Move to trash event handler
|
||||
/// </summary>
|
||||
public delegate void MoveToTrashEventHandler(Media sender, MoveToTrashEventArgs e);
|
||||
/// <summary>
|
||||
/// Occurs when [before delete].
|
||||
/// </summary>
|
||||
public static event MoveToTrashEventHandler BeforeMoveToTrash;
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:BeforeDelete"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void FireBeforeMoveToTrash(MoveToTrashEventArgs e)
|
||||
{
|
||||
if (BeforeMoveToTrash != null)
|
||||
BeforeMoveToTrash(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [after move to trash].
|
||||
/// </summary>
|
||||
public static event MoveToTrashEventHandler AfterMoveToTrash;
|
||||
/// <summary>
|
||||
/// Fires the after move to trash.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="umbraco.cms.businesslogic.MoveToTrashEventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void FireAfterMoveToTrash(MoveToTrashEventArgs e)
|
||||
{
|
||||
if (AfterMoveToTrash != null)
|
||||
AfterMoveToTrash(this, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when [after move to trash].
|
||||
/// </summary>
|
||||
public static event MoveToTrashEventHandler AfterMoveToTrash;
|
||||
/// <summary>
|
||||
/// Fires the after move to trash.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="umbraco.cms.businesslogic.MoveToTrashEventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void FireAfterMoveToTrash(MoveToTrashEventArgs e)
|
||||
{
|
||||
if (AfterMoveToTrash != null)
|
||||
AfterMoveToTrash(this, e);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,13 +55,10 @@ namespace umbraco.cms.businesslogic.media
|
||||
SqlHelper.CreateParameter("@alias",Alias)));
|
||||
}
|
||||
|
||||
|
||||
private static Guid _objectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e");
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all MediaTypes in the umbraco installation
|
||||
/// </summary>
|
||||
new public static MediaType[] GetAll
|
||||
public new static MediaType[] GetAll
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -95,11 +92,12 @@ namespace umbraco.cms.businesslogic.media
|
||||
return mt;
|
||||
}
|
||||
|
||||
public static Guid _objectType = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e");
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the current MediaType and all created Medias of the type.
|
||||
/// </summary>
|
||||
new public void delete()
|
||||
public override void delete()
|
||||
{
|
||||
DeleteEventArgs e = new DeleteEventArgs();
|
||||
FireBeforeDelete(e);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace umbraco
|
||||
/// </summary>
|
||||
new public delegate void NewUIMemberEventHandler(Member sender, string unencryptedPassword, NewMemberUIEventArgs e);
|
||||
|
||||
new public static event NewUIMemberEventHandler NewMember;
|
||||
public static event NewUIMemberEventHandler NewMember;
|
||||
new protected virtual void OnNewMember(NewMemberUIEventArgs e, string unencryptedPassword, Member m)
|
||||
{
|
||||
if (NewMember != null)
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace umbraco.presentation.masterpages {
|
||||
public partial class umbracoDialog : System.Web.UI.MasterPage {
|
||||
|
||||
public bool reportModalSize { get; set; }
|
||||
public static event MasterPageLoadHandler Load;
|
||||
public static new event MasterPageLoadHandler Load;
|
||||
public static event MasterPageLoadHandler Init;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
<section name="umbraco.presentation.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<section name="clientDependency" type="ClientDependency.Core.Config.ClientDependencySection, ClientDependency.Core" requirePermission="false"/>
|
||||
<section name="Examine" type="Examine.Config.ExamineSettings, Examine"/>
|
||||
<section name="ExamineLuceneIndexSets" type="UmbracoExamine.Config.ExamineLuceneIndexes, UmbracoExamine"/>
|
||||
<section name="Examine" type="Examine.Config.ExamineSettings, Examine" requirePermission="false"/>
|
||||
<section name="ExamineLuceneIndexSets" type="UmbracoExamine.Config.ExamineLuceneIndexes, UmbracoExamine" requirePermission="false"/>
|
||||
</configSections>
|
||||
<urlrewritingnet configSource="config\UrlRewriting.config" />
|
||||
<microsoft.scripting configSource="config\scripting.config" />
|
||||
|
||||
Reference in New Issue
Block a user