How to Allow 'Editor' role to access Oform messages?

Topics: Customizing Orchard
Mar 23, 2012 at 8:34 AM

Hey guys, I’m using Oforms which appears to only allow the ‘admin’ to access it on the back end. Simply, how can I change it so ‘editors’ can access it and view the messages? I went through the roles options and couldnt find oForms anywhere to enable; so it appears I might have to modify code, anyone have any ideas? Thanks pg

Mar 23, 2012 at 10:50 PM

Ok, so i've amended the oforms adminmenu,cs to:

using Orchard.Localization;
using Orchard.Security;
using Orchard.UI.Navigation;

namespace oforms
{
    public class AdminMenu : INavigationProvider
    {
        public Localizer T { get; set; }
        public string MenuName { get { return "admin"; } }

        public void GetNavigation(NavigationBuilder builder)
        {
            builder.AddImageSet("users")
                .Add(T("OForms"), "1",
                    menu => menu.Action("Index", "Admin", new { area = "oforms" })
                        .Permission(Permissions.ManageOforms)
                        .Add(T("OForms"), "1.0", item => item.Action("Index", "Admin", new { area = "oforms" })
                            .LocalNav().Permission(StandardPermissions.AccessAdminPanel)));//StandardPermissions.SiteOwner)));
        }
    }
}

and created the following permission.cs file

using System.Collections.Generic;
using Orchard.Environment.Extensions.Models;
using Orchard.Security.Permissions;

namespace oforms {
    public class Permissions : IPermissionProvider {
        public static readonly Permission ManageOforms = new Permission { Description = "Manage Oforms", Name = "ManageOforms" };

        public virtual Feature Feature { get; set; }

        public IEnumerable<Permission> GetPermissions() {
            return new[] {
                ManageOforms,
            };
        }

        public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
            return new[] {
                new PermissionStereotype {
                    Name = "Administrator",
                    Permissions = new[] {ManageOforms}
                },
                new PermissionStereotype {
                    Name = "Editor",
                    Permissions = new[] {ManageOforms}
                },
                new PermissionStereotype {
                    Name = "Moderator",
                    Permissions = new[] {ManageOforms}
                },
                new PermissionStereotype {
                    Name = "Author",
                },
                new PermissionStereotype {
                    Name = "Contributor",
                },
            };
        }

    }
}

then allowed the above through roles for editors.
what else do i have to do to get editors to use oForms in the back end, it always says they need to have site owner permission? Any help appreicated guys, cheers pg

Mar 24, 2012 at 12:32 AM
Edited Mar 24, 2012 at 12:33 AM

so i've re-enabled theme machine, and now i can see more error detail:

Not authorized to list users. Current user, Test, does not have SiteOwner permission.

is this inferring Test user needs an elevated privilege within the user module, slightly confused? Cheers pg

Mar 24, 2012 at 11:28 PM

this has answered my concerns:

http://orchard.codeplex.com/discussions/252669

is this still the case?