It hurts having to do this, but Sebastiaan says I have to. So re-wiring the BulkPublishController to use the legacy Document class so legacy events are also fired.
This commit is contained in:
@@ -8,6 +8,7 @@ using Umbraco.Core.Publishing;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Mvc;
|
||||
using umbraco;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
|
||||
namespace Umbraco.Web.WebServices
|
||||
{
|
||||
@@ -26,11 +27,13 @@ namespace Umbraco.Web.WebServices
|
||||
[HttpPost]
|
||||
public JsonResult PublishDocument(int documentId, bool publishDescendants, bool includeUnpublished)
|
||||
{
|
||||
var doc = Services.ContentService.GetById(documentId);
|
||||
var contentService = (ContentService) Services.ContentService;
|
||||
if (!publishDescendants)
|
||||
var content = Services.ContentService.GetById(documentId);
|
||||
var doc = new Document(content);
|
||||
//var contentService = (ContentService) Services.ContentService;
|
||||
if (publishDescendants == false)
|
||||
{
|
||||
var result = contentService.SaveAndPublishInternal(doc);
|
||||
//var result = contentService.SaveAndPublishInternal(content);
|
||||
var result = doc.SaveAndPublish(UmbracoUser.Id);
|
||||
return Json(new
|
||||
{
|
||||
success = result.Success,
|
||||
@@ -39,13 +42,14 @@ namespace Umbraco.Web.WebServices
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = ((ContentService) Services.ContentService)
|
||||
.PublishWithChildrenInternal(doc, UmbracoUser.Id, includeUnpublished)
|
||||
.ToArray();
|
||||
/*var result = ((ContentService) Services.ContentService)
|
||||
.PublishWithChildrenInternal(content, UmbracoUser.Id, includeUnpublished)
|
||||
.ToArray();*/
|
||||
var result = doc.PublishWithSubs(UmbracoUser.Id, includeUnpublished);
|
||||
return Json(new
|
||||
{
|
||||
success = result.All(x => x.Success),
|
||||
message = GetMessageForStatuses(result.Select(x => x.Result), doc)
|
||||
message = GetMessageForStatuses(result.Select(x => x.Result), content)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -63,7 +67,7 @@ namespace Umbraco.Web.WebServices
|
||||
foreach (var msg in statuses
|
||||
.Where(x => ((int)x.StatusType) >= 10)
|
||||
.Select(GetMessageForStatus)
|
||||
.Where(msg => !msg.IsNullOrWhiteSpace()))
|
||||
.Where(msg => msg.IsNullOrWhiteSpace() == false))
|
||||
{
|
||||
sb.AppendLine(msg.Trim());
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Persistence.Caching;
|
||||
using Umbraco.Core.Publishing;
|
||||
using Umbraco.Core.Services;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.BusinessLogic.Actions;
|
||||
@@ -914,13 +915,76 @@ namespace umbraco.cms.businesslogic.web
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
var publishedResults = ((ContentService)ApplicationContext.Current.Services.ContentService)
|
||||
IEnumerable<Attempt<PublishStatus>> publishedResults = ((ContentService)ApplicationContext.Current.Services.ContentService)
|
||||
.PublishWithChildrenInternal(Content, u.Id);
|
||||
|
||||
FireAfterPublish(e);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Don't use! Only used internally to support the legacy events", false)]
|
||||
internal IEnumerable<Attempt<PublishStatus>> PublishWithSubs(int userId, bool includeUnpublished)
|
||||
{
|
||||
PublishEventArgs e = new PublishEventArgs();
|
||||
FireBeforePublish(e);
|
||||
|
||||
IEnumerable<Attempt<PublishStatus>> publishedResults = Enumerable.Empty<Attempt<PublishStatus>>();
|
||||
|
||||
if (!e.Cancel)
|
||||
{
|
||||
publishedResults = ((ContentService) ApplicationContext.Current.Services.ContentService)
|
||||
.PublishWithChildrenInternal(Content, userId, includeUnpublished);
|
||||
|
||||
FireAfterPublish(e);
|
||||
}
|
||||
|
||||
return publishedResults;
|
||||
}
|
||||
|
||||
[Obsolete("Don't use! Only used internally to support the legacy events", false)]
|
||||
internal Attempt<PublishStatus> SaveAndPublish(int userId)
|
||||
{
|
||||
var result = new Attempt<PublishStatus>(false,
|
||||
new PublishStatus(Content,
|
||||
PublishStatusType
|
||||
.FailedCancelledByEvent));
|
||||
foreach (var property in GenericProperties)
|
||||
{
|
||||
Content.SetValue(property.PropertyType.Alias, property.Value);
|
||||
}
|
||||
|
||||
var saveArgs = new SaveEventArgs();
|
||||
FireBeforeSave(saveArgs);
|
||||
|
||||
if (!saveArgs.Cancel)
|
||||
{
|
||||
var publishArgs = new PublishEventArgs();
|
||||
FireBeforePublish(publishArgs);
|
||||
|
||||
if (!publishArgs.Cancel)
|
||||
{
|
||||
//NOTE: The 'false' parameter will cause the PublishingStrategy events to fire which will ensure that the cache is refreshed.
|
||||
result = ((ContentService)ApplicationContext.Current.Services.ContentService)
|
||||
.SaveAndPublishInternal(Content, userId);
|
||||
base.VersionDate = Content.UpdateDate;
|
||||
this.UpdateDate = Content.UpdateDate;
|
||||
|
||||
//NOTE: This is just going to call the CMSNode Save which will launch into the CMSNode.BeforeSave and CMSNode.AfterSave evenths
|
||||
// which actually do dick all and there's no point in even having them there but just in case for some insane reason someone
|
||||
// has bound to those events, I suppose we'll need to keep this here.
|
||||
base.Save();
|
||||
|
||||
//Launch the After Save event since we're doing 2 things in one operation: Saving and publishing.
|
||||
FireAfterSave(saveArgs);
|
||||
|
||||
//Now we need to fire the After publish event
|
||||
FireAfterPublish(publishArgs);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.UnPublish()", false)]
|
||||
public void UnPublish()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user