mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding a way to prevent content items from being exported
--HG-- branch : 1.x extra : rebase_source : 259846d236189d44d09f91dce4e154f6b8e3993f
This commit is contained in:
@@ -343,6 +343,13 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
var importContentSession = new ImportContentSession(_contentManager);
|
||||
|
||||
var element = _contentManager.Export(contentItem);
|
||||
|
||||
// if a handler prevents this element from being exported, it can't be cloned
|
||||
if (element == null) {
|
||||
Services.Notifier.Warning(T("Could not clone the content item."));
|
||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("List"));
|
||||
}
|
||||
|
||||
var elementId = element.Attribute("Id");
|
||||
var copyId = elementId.Value + "-copy";
|
||||
elementId.SetValue(copyId);
|
||||
|
@@ -703,6 +703,10 @@ namespace Orchard.ContentManagement {
|
||||
contentHandler.Exported(context);
|
||||
}
|
||||
|
||||
if (context.Exclude) {
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Data.SetAttributeValue("Id", GetItemMetadata(contentItem).Identity.ToString());
|
||||
if (contentItem.IsPublished()) {
|
||||
context.Data.SetAttributeValue("Status", Published);
|
||||
|
@@ -4,6 +4,11 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
public class ExportContentContext : ContentContextBase {
|
||||
public XElement Data { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Wether the content item should be exclude from the export or not
|
||||
/// </summary>
|
||||
public bool Exclude { get; set; }
|
||||
|
||||
public ExportContentContext(ContentItem contentItem, XElement data)
|
||||
: base(contentItem) {
|
||||
Data = data;
|
||||
|
Reference in New Issue
Block a user