Merge
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
using System.Collections;
|
||||
@@ -85,8 +86,8 @@ namespace umbraco.cms.businesslogic.media
|
||||
}
|
||||
|
||||
var media = ApplicationContext.Current.Services.MediaService.CreateMedia(Name, ParentId, dct.Alias, u.Id);
|
||||
//The media object will only be null if the 'Creating' event has been cancelled
|
||||
if (media == null)
|
||||
//The media object will only have the 'WasCancelled' flag set to 'True' if the 'Creating' event has been cancelled
|
||||
if (((Entity)media).WasCancelled)
|
||||
return null;
|
||||
|
||||
ApplicationContext.Current.Services.MediaService.Save(media);
|
||||
|
||||
@@ -85,15 +85,20 @@ namespace umbraco.cms.businesslogic.media
|
||||
if (childMedia.ContentType.Alias == MediaTypeAlias)
|
||||
{
|
||||
var prop = childMedia.getProperty("umbracoFile");
|
||||
if (prop != null)
|
||||
if (prop != null && prop.Value != null)
|
||||
{
|
||||
var destFilePath = FileSystem.GetRelativePath(prop.Id, fileName);
|
||||
var destFileUrl = FileSystem.GetUrl(destFilePath);
|
||||
|
||||
if (prop.Value.ToString() == destFileUrl)
|
||||
int subfolderId;
|
||||
var subfolder = prop.Value.ToString().Replace(FileSystem.GetUrl("/"), "").Split('/')[0];
|
||||
if (int.TryParse(subfolder, out subfolderId))
|
||||
{
|
||||
existingMedia = childMedia;
|
||||
return true;
|
||||
var destFilePath = FileSystem.GetRelativePath(subfolderId, fileName);
|
||||
var destFileUrl = FileSystem.GetUrl(destFilePath);
|
||||
|
||||
if (prop.Value.ToString() == destFileUrl)
|
||||
{
|
||||
existingMedia = childMedia;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.BusinessLogic;
|
||||
@@ -288,8 +289,8 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
//Create a new IContent object based on the passed in DocumentType's alias, set the name and save it
|
||||
IContent content = ApplicationContext.Current.Services.ContentService.CreateContent(Name, ParentId, dct.Alias, u.Id);
|
||||
//The content object will only be null if the 'Creating' event has been cancelled, so we return null.
|
||||
if (content == null)
|
||||
//The content object will only have the 'WasCancelled' flag set to 'True' if the 'Creating' event has been cancelled, so we return null.
|
||||
if (((Entity)content).WasCancelled)
|
||||
return null;
|
||||
|
||||
//don't raise events here (false), they will get raised with the d.Save() call.
|
||||
|
||||
Reference in New Issue
Block a user