Jump to content

Roles question. Should I hook something to do this?


joer80
 Share

Recommended Posts

So far it looks like most default roles situations revolve around the template level.  I think I need to do something that can not be handled that way.

I have pages that share the same template, but depending on the value of one of the fields in the template, I need to let certain roles have edit permission the pages.

Example situation:

Template is inventory and has a field that says City: "Austin"

User is bob with the role "Austin Inventory manager".    I need to let him edit inventory that has City = "Austin".

 

I am thinking this is not built into stock processwire and I will add an auto load module and hook something that lets me allow or block the page edit permission for the user depending on the users role compared to this one field.   I am just not sure where to hook.   

Any advice?

Link to comment
Share on other sites

Would I be better to just design the website around fake templates?

ie. create a "Dallas Inventory" with no file, and an "Austin Inventory" template with no file.  Then make their settings load Inventory.php so they can share code if I want, and tie the users role to the fake template?

I just would not be able to pull all the inventory at once by the template.  I could pull it by other fields or their parent though?

But then if I wanted to add a field to Inventory.php, and had 20 fake templates that implement it, I would need to add it to all 20 fake templates.  :\

Link to comment
Share on other sites

Perhaps try the Dynamic Roles module.

Traditional ProcessWire roles are limited to assignment of view/edit/add access on a per-template basis. Dynamic roles go outside those limitations and enable you to assign that access based on any factors present with a page (i.e. match any field values).

  • Like 1
Link to comment
Share on other sites

Adrian, thanks for the tip!   If I do my own, that will get me half way there!

Robin, Nice!  Why is that not in the modules directory? I looked through all of the roles modules.   I will give it a go and see if it will do the trick!

Thanks for all the help!  I will let you know what happens!

Link to comment
Share on other sites

Oh goodness. 

It doesn't look like it installs anymore either.  As soon as you hit install it says:

Recoverable Fatal Error: Argument 1 passed to ProcessWire\PagesType::__construct() must be an instance of ProcessWire\ProcessWire, instance of ProcessWire\Template given, called in /home/goac/public_html/inv/site/modules/DynamicRoles/DynamicRoleSupport.module on line 64 and defined (line 77 of /home/goac/public_html/inv/wire/core/PagesType.php) 

This error message was shown because: you are logged in as a Superuser. Error has been logged.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...