Fixing custom forms event

This commit is contained in:
Sebastien Ros
2013-08-20 17:08:02 -07:00
parent 2fc774e93b
commit 9ca4349218
3 changed files with 12 additions and 8 deletions

View File

@@ -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;

View File

@@ -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
)

View File

@@ -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) {