mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 17:51:45 +08:00
Adds the Unpublished Event and the Unpublish Task to workflows (#7929)
Fixes #7902
This commit is contained in:
committed by
Sébastien Ros
parent
b21c1edabb
commit
5dc0003f25
@@ -89,6 +89,16 @@ namespace Orchard.Workflows.Activities {
|
||||
}
|
||||
}
|
||||
|
||||
public class ContentUnpublishedActivity : ContentActivity {
|
||||
public override string Name {
|
||||
get { return "ContentUnpublished"; }
|
||||
}
|
||||
|
||||
|
||||
public override LocalizedString Description {
|
||||
get { return T("Content is unpublished."); }
|
||||
}
|
||||
}
|
||||
public class ContentVersionedActivity : ContentActivity {
|
||||
public override string Name {
|
||||
get { return "ContentVersioned"; }
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Workflows.Models;
|
||||
using Orchard.Workflows.Services;
|
||||
|
||||
namespace Orchard.Workflows.Activities {
|
||||
public class UnpublishActivity : Task {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public UnpublishActivity(IContentManager contentManager) {
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
|
||||
return new[] { T("Unpublished") };
|
||||
}
|
||||
|
||||
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
|
||||
_contentManager.Unpublish(workflowContext.Content.ContentItem);
|
||||
yield return T("Unpublished");
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
get { return "Unpublish"; }
|
||||
}
|
||||
|
||||
public override LocalizedString Category {
|
||||
get { return T("Content Items"); }
|
||||
}
|
||||
|
||||
public override LocalizedString Description {
|
||||
get { return T("Unpublish the content item."); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,12 @@ namespace Orchard.Workflows.Handlers {
|
||||
context.ContentItem,
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
OnUnpublished<ContentPart>(
|
||||
(context, part) =>
|
||||
workflowManager.TriggerEvent("ContentUnpublished",
|
||||
context.ContentItem,
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
OnRemoving<ContentPart>(
|
||||
(context, part) =>
|
||||
workflowManager.TriggerEvent("ContentRemoved",
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Compile Include="Activities\LoggingActivity.cs" />
|
||||
<Compile Include="Activities\UnpublishActivity.cs" />
|
||||
<Compile Include="Forms\LoggingActivityForms.cs" />
|
||||
<Compile Include="Helpers\OutcomeSerializerExtensions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
Reference in New Issue
Block a user