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