mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing custom forms event
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Workflows.Models;
|
using Orchard.Workflows.Models;
|
||||||
using Orchard.Workflows.Services;
|
using Orchard.Workflows.Services;
|
||||||
@@ -19,22 +20,25 @@ namespace Orchard.CustomForms.Activities {
|
|||||||
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
|
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var contentTypesState = activityContext.GetState<string>("ContentTypes");
|
var state = activityContext.GetState<string>("CustomForms");
|
||||||
|
|
||||||
// "" means 'any'
|
// "" means 'any'
|
||||||
if (String.IsNullOrEmpty(contentTypesState)) {
|
if (String.IsNullOrEmpty(state)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] contentTypes = contentTypesState.Split(',');
|
|
||||||
|
|
||||||
var content = workflowContext.Content;
|
var content = workflowContext.Content;
|
||||||
|
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return contentTypes.Any(contentType => content.ContentItem.TypeDefinition.Name == contentType);
|
var contentManager = content.ContentItem.ContentManager;
|
||||||
|
var identities = state.Split(',').Select(x => new ContentIdentity(x));
|
||||||
|
var customForms = identities.Select(contentManager.ResolveIdentity);
|
||||||
|
|
||||||
|
return customForms.Any(x => x == content);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -26,8 +26,8 @@ namespace Orchard.CustomForms.Activities {
|
|||||||
Id: "AnyOfCustomForms",
|
Id: "AnyOfCustomForms",
|
||||||
_Parts: Shape.SelectList(
|
_Parts: Shape.SelectList(
|
||||||
Id: "customforms", Name: "CustomForms",
|
Id: "customforms", Name: "CustomForms",
|
||||||
Title: T("Content types"),
|
Title: T("Custom Forms"),
|
||||||
Description: T("Select some content types."),
|
Description: T("Select some custom forms."),
|
||||||
Size: 10,
|
Size: 10,
|
||||||
Multiple: true
|
Multiple: true
|
||||||
)
|
)
|
||||||
|
@@ -157,7 +157,7 @@ namespace Orchard.CustomForms.Controllers {
|
|||||||
() => new Dictionary<string, object> { { "Content", contentItem } });
|
() => new Dictionary<string, object> { { "Content", contentItem } });
|
||||||
|
|
||||||
// trigger any workflow
|
// trigger any workflow
|
||||||
_workflowManager.TriggerEvent(FormSubmittedActivity.EventName, contentItem,
|
_workflowManager.TriggerEvent(FormSubmittedActivity.EventName, customForm.ContentItem,
|
||||||
() => new Dictionary<string, object> { { "Content", contentItem } });
|
() => new Dictionary<string, object> { { "Content", contentItem } });
|
||||||
|
|
||||||
if (customForm.Redirect) {
|
if (customForm.Redirect) {
|
||||||
|
Reference in New Issue
Block a user