joer80 Posted February 25, 2016 Share Posted February 25, 2016 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 More sharing options...
joer80 Posted February 25, 2016 Author Share Posted February 25, 2016 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 More sharing options...
adrian Posted February 25, 2016 Share Posted February 25, 2016 Take a look at what I did in AdminRestrictBranch: https://github.com/adrianbj/AdminRestrictBranch/blob/master/AdminRestrictBranch.module#L220 You can hook into Page::editable and set up your own logic to return true/false as needed. 1 Link to comment Share on other sites More sharing options...
Robin S Posted February 26, 2016 Share Posted February 26, 2016 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). 1 Link to comment Share on other sites More sharing options...
joer80 Posted February 26, 2016 Author Share Posted February 26, 2016 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 More sharing options...
adrian Posted February 26, 2016 Share Posted February 26, 2016 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! Take a look at this Issues list for that module: https://github.com/ryancramerdesign/DynamicRoles/issues Link to comment Share on other sites More sharing options...
joer80 Posted February 26, 2016 Author Share Posted February 26, 2016 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now