protected override DriverResult Editor(CustomFormPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var viewModel = new CustomFormPartEditViewModel {
                CustomFormPart = part
            };

            updater.TryUpdateModel(viewModel, Prefix, null, null);

            // Warn if the custom form is set to save a content item that is viewable by anonymous users (publicly accessible)
            if (viewModel.CustomFormPart.SaveContentItem)
            {
                // If it's draftable then don't display the warning because the generated content items won't be publicly accessible
                var typeDefinition = _contentDefinitionManager.ListTypeDefinitions().Where(x => String.Equals(x.Name, viewModel.CustomFormPart.ContentType, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (typeDefinition != null && !typeDefinition.Settings.GetModel <ContentTypeSettings>().Draftable)
                {
                    // Create a dummy content item of the specified type to check permissions against
                    if (_authService.TryCheckAccess(Orchard.Core.Contents.Permissions.ViewContent, null, _orchardServices.ContentManager.New(viewModel.CustomFormPart.ContentType)))
                    {
                        _orchardServices.Notifier.Add(UI.Notify.NotifyType.Warning, T("Your custom form will save data to content items that are publicly accessible."));
                    }
                }
            }

            return(Editor(part, shapeHelper));
        }
Exemplo n.º 2
0
        protected override DriverResult Editor(CustomFormPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            var viewModel = new CustomFormPartEditViewModel {
                CustomFormPart = part
            };

            updater.TryUpdateModel(viewModel, Prefix, null, null);
            return(Editor(part, shapeHelper));
        }
Exemplo n.º 3
0
        protected override DriverResult Editor(CustomFormPart part, dynamic shapeHelper)
        {
            return(ContentShape("Parts_CustomForm_Fields", () => {
                var contentTypes = _contentDefinitionManager.ListTypeDefinitions().Select(x => x.Name).OrderBy(x => x);
                var viewModel = new CustomFormPartEditViewModel {
                    ContentTypes = contentTypes,
                    CustomFormPart = part
                };

                return shapeHelper.EditorTemplate(TemplateName: "Parts.CustomForm.Fields", Model: viewModel, Prefix: Prefix);
            }));
        }