mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 18:57:56 +08:00
Getting content publishing/unpublishing hooked up (from the content item list)
- moved publishing control to the Contents module - included some prep for adding bulk actions and filtering to the content item list - publish, unpublish and remove actions need downlevel interstitial pages (functionality only workes w/ JS at the moment) --HG-- branch : dev
This commit is contained in:
@@ -5,9 +5,7 @@ using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Contents.ViewModels;
|
||||
using Orchard.Core.PublishLater.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
@@ -179,6 +177,38 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
return RedirectToAction("List");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Publish(int id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't publish content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentItem = _contentManager.GetLatest(id);
|
||||
if (contentItem == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
_contentManager.Publish(contentItem);
|
||||
Services.ContentManager.Flush();
|
||||
Services.Notifier.Information(T("{0} successfully published.", contentItem.TypeDefinition.DisplayName));
|
||||
|
||||
return RedirectToAction("List");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Unpublish(int id) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't unpublish content")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var contentItem = _contentManager.GetLatest(id);
|
||||
if (contentItem == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
_contentManager.Unpublish(contentItem);
|
||||
Services.ContentManager.Flush();
|
||||
Services.Notifier.Information(T("{0} successfully unpublished.", contentItem.TypeDefinition.DisplayName));
|
||||
|
||||
return RedirectToAction("List");
|
||||
}
|
||||
|
||||
private static void PrepareEditorViewModel(ContentItemViewModel itemViewModel) {
|
||||
if (string.IsNullOrEmpty(itemViewModel.TemplateName)) {
|
||||
itemViewModel.TemplateName = "Items/Contents.Item";
|
||||
|
Reference in New Issue
Block a user