teppo Posted March 20, 2021 Share Posted March 20, 2021 Admin Restrict Branch Select is an add-on / companion module for Admin Restrict Branch. With this module enabled, you can manually select more than one branch parent per user via the branch_parent field, and users with more than one option selected will be able to switch between those while editing site content. Switching between branches is done via a select field injected at the top of the page tree. Note that users are still limited to one branch at a time: this module will not make it possible to view multiple branches at the same time. When the module is installed, it will automatically update the branch_parent field if deemed necessary, i.e. if it isn't yet configured to allow selecting multiple pages. You can make changes to the field later, if you want to restrict selectable options by template, use asmSelect instead of PageListSelectMultiple, etc. This is an early beta release, so be sure to test carefully before enabling this module in production! https://processwire.com/modules/admin-restrict-branch-select/ https://github.com/teppokoivula/AdminRestrictBranchSelect 10 Link to comment Share on other sites More sharing options...
adrian Posted March 20, 2021 Share Posted March 20, 2021 Just did a quick test and it looks great - thanks for sharing this - I think it will be a great solution for many folks. 4 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted March 21, 2021 Share Posted March 21, 2021 This module is exactly what I need on a current project. And did need on a number in the past, but had to cope without. Thanks, Teppo! 3 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted March 22, 2021 Share Posted March 22, 2021 Good day, @teppo! I am having trouble installing the module from the modules directory. I am getting this error: ProcessModuleInstall: File could not be downloaded (https://github.com/teppokoivula/AdminRestrictBranchSelect/archive/master.zip) 404 Not Found: (tried: curl) Could you please check, if the download URL is correct. Link to comment Share on other sites More sharing options...
teppo Posted March 22, 2021 Author Share Posted March 22, 2021 On 3/22/2021 at 12:29 PM, Ivan Gretsky said: Good day, @teppo! I am having trouble installing the module from the modules directory. I am getting this error: ProcessModuleInstall: File could not be downloaded (https://github.com/teppokoivula/AdminRestrictBranchSelect/archive/master.zip) 404 Not Found: (tried: curl) Could you please check, if the download URL is correct. Expand Thanks — looks like the modules directory defaults to master branch, while GitHub defaults to main instead. Fixed now. 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted March 22, 2021 Share Posted March 22, 2021 Thanks, the module now installs from the directory as it should. But I must be missing something while configuring it. I assign two branches to a user, then login and get this error: AdminRestrictBranch: You don't have permission to view this branch of the page tree. I was thinking that the module will redirect the user after login to a branch he has access to. But this doesn't happen. Could you please suggest am I missing or misconfiguring something? Link to comment Share on other sites More sharing options...
adrian Posted March 22, 2021 Share Posted March 22, 2021 @Ivan Gretsky - guest a guess - are you using the correct setting in the main ARB module? Or are you perhaps logging in via a URL to open a specific branch of the page tree? 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted March 23, 2021 Share Posted March 23, 2021 Thanks for the tips, @adrian! My setting is User Specified Branch Parent, as it is on your screenshot. I am visiting /admin/page/. Didn't know I could even link to a specific branch via URL. I did everything to clear the cache if that could affect it somehow, but with no luck. Still getting this error. Link to comment Share on other sites More sharing options...
adrian Posted March 23, 2021 Share Posted March 23, 2021 @Ivan Gretsky - sorry for the trouble - could you please debug which of these conditions (https://github.com/adrianbj/AdminRestrictBranch/blob/4964a3f5b83338f7313f7c6daeefe6c6793640b0/AdminRestrictBranch.module.php#L228) is resulting in the error message? And if it's the last one, then figure out where in this method: https://github.com/adrianbj/AdminRestrictBranch/blob/4964a3f5b83338f7313f7c6daeefe6c6793640b0/AdminRestrictBranch.module.php#L236 or in this hook (https://github.com/teppokoivula/AdminRestrictBranchSelect/blob/3ac88e7f4da482a5a16dad1abe3f221fdaeb2742/AdminRestrictBranchSelect.module.php#L54) in @teppo's module it's returning "1", rather than one of the allowed branch parents? BTW - are you having the same issue with ARB without this addon module? 2 Link to comment Share on other sites More sharing options...
teppo Posted March 23, 2021 Author Share Posted March 23, 2021 On 3/22/2021 at 5:32 PM, Ivan Gretsky said: But I must be missing something while configuring it. I assign two branches to a user, then login and get this error: AdminRestrictBranch: You don't have permission to view this branch of the page tree. I was thinking that the module will redirect the user after login to a branch he has access to. But this doesn't happen. Could you please suggest am I missing or misconfiguring something? Expand Doesn't sound like you're missing anything, and yes — the module should automatically redirect the user to the first branch configured for them. So far I've been unable to reproduce this issue. Just in case I installed a new ProcessWire site with only default site profile + AdminRestrictBranch + AdminRestrictBranchSelect, and everything worked as expected. Following the suggestions Adrian made above should give us a better idea of what's going on, but one more thing I'm wondering is that what version of ProcessWire you're running? The module should work on 3.0.123 and above, but I've only tested it on 3.0.165, so it could have something to do with that. It kind of sounds like AdminRestrictBranch::init() might run before AdminRestrictBranchSelect::init(), or the latter might not run at all; either would at least explain the error you're seeing. A simple way to test if this is happening would be adding some debug code (bd(), or just die() with some sensible message) in both methods and seeing which gets executed first (should be AdminRestrictBranchSelect::init()). 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted April 3, 2021 Share Posted April 3, 2021 @adrian, @teppo, thanks to both of you. I think I spotted the problem. There is the Page Edit Per User module installed on the same project that causes errors in some cases. I manages to get Admin Restrict Branch Select to work. But I now face another less mysterious problem with frontend editing. It is available only for the branch that is currently selected. So when I switch from Branch A to Branch B in admin, Branch A is no longer editable on the frontend. It must be the way the module is intended to work. But is there a way to make the Page List in admin show only the currently selected branch, but keep the edit permissions to all of the selected branches? I think that even seems to be more expected from the user point of view, so maybe a might be a good improvement for the module))) 1 Link to comment Share on other sites More sharing options...
adrian Posted April 3, 2021 Share Posted April 3, 2021 @Ivan Gretsky - glad you got the issue with the other module sorted out. Regarding the edit permissions for all allowed branches, I completely agree that this should be how it works. Even without Teppo's add-on module I think ARB should probably support this because there is the option to only restrict editing rights but still show all branches so this could be a nice enhancement. Can't promise a delivery timeframe for it but I'll do my best. 1 Link to comment Share on other sites More sharing options...
adrian Posted April 5, 2021 Share Posted April 5, 2021 @teppo - something I just discovered is that if you uninstall this module it can result in the issue that @Ivan Gretsky was seeing where you can no longer access the page tree, or you can actually see everything (depending on what you have set for the "If no match, give all access or no access?" setting) because the settings for the "branch_parent" field are not reverted on uninstall. I have a feeling this won't matter if/when I implement Ivan's request for support multiple branches for edit restrictions in the core ARB module, but in the meantime, this may bite someone if they're not careful. 1 Link to comment Share on other sites More sharing options...
teppo Posted April 5, 2021 Author Share Posted April 5, 2021 On 4/5/2021 at 2:57 AM, adrian said: @teppo - something I just discovered is that if you uninstall this module it can result in the issue that @Ivan Gretsky was seeing where you can no longer access the page tree, or you can actually see everything (depending on what you have set for the "If no match, give all access or no access?" setting) because the settings for the "branch_parent" field are not reverted on uninstall. I have a feeling this won't matter if/when I implement Ivan's request for support multiple branches for edit restrictions in the core ARB module, but in the meantime, this may bite someone if they're not careful. Expand That's a good point. Version 0.3.0 reverts field settings during uninstall. Seems that altering data is not necessary: even if the field contains multiple values (in database), only one is returned with the new settings. I'm not 100% certain that this won't cause any unexpected side effects, but for the time being it seems to work fine... ? 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted April 12, 2022 Share Posted April 12, 2022 Good day, friends! I am back to using the mighty ARB and this super useful addon to it. Thank you for your time and talent! The old issue On 4/5/2021 at 2:57 AM, adrian said: this won't matter if/when I implement Ivan's request for support multiple branches for edit restrictions in the core ARB module Expand @adrian, it seems like you didn't find time for it yet. Is there a chance you come back to this in the near future? The new issue I just found that the changes that ARBS adds to the Page List also apply to the children tab on the page edit screen. I see this is an unintended side effect that looks like a bug. @teppo, is there an easy way to change this behavior? P.S Created github issues (this one and this one) for your convenience. Link to comment Share on other sites More sharing options...
adrian Posted April 13, 2022 Share Posted April 13, 2022 Hi @Ivan Gretsky - I am heading on vacation for a couple of weeks as of tomorrow and then of course it will be crazy catching up when I'm back, but thanks for the GH issue. I will try to take a look as soon as I can. Sorry I never got back to it before. 1 Link to comment Share on other sites More sharing options...
DV-JF Posted February 14, 2023 Share Posted February 14, 2023 Hey @teppo perhaps you could give me hint, I'm facing an really annoying bug and don't know how to debug further: I've installed your module first on a dev-server then tried to migrate the settings to the live server. On the dev server everything is running as expected, and you're module is working fine, but on the live server i get the message: You don't have permission to view this branch of the page tree. When I disable your Module the (first and then only) selected branch is shown as it should be via module "Admin Restrict Branch" . Same settings on both websites: ProcessWire 3.0.210 © 2023 @ PHP 8.1.9 What I've noticed so far: When I do db($event); in .../AdminRestrictBranchSelect/AdminRestrictBranchSelect.module.php:114 the $event->return; is false on live website but true on dev server: Any ideas on how to debug further? 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