Currently we can only check one subpermission per module It would be nice to check multiple Testing code suggests this was possible, however, it was flawed flagsrequired => { tools => 'batch_upload_patron_images', tools => 'upload_local_cover_images' } Above does not test for two permissions, it simply checks for the second
Created attachment 83414 [details] [review] Bug 22031: Unit tests To test: 1 - Apply this patch only 2 - prove -v t/db_dependent/Auth/haspermission.t 3 - It will fail
Created attachment 83415 [details] [review] Bug 22031: Adjust haspermission to take an array To test: 1 - Apply this patch on top of unit tests 2 - Unit tests now pass 3 - Ensure you can use Koha as before with no regressions
This works well enough... But.. what if we wanted to introduce the ability to compare logically with OR or AND in the future.. by adding arrayref as 'AND' here we'll be doing the exact opposite of what SQL::Abstract does... I'm going to try and come up with an alternative that more closely resembles SQL::Abstract so we're not dealing with two very similar but opposing constructs in Koha.
Created attachment 83474 [details] [review] Bug 22031: Add SQL::Abstract like syntax to haspermission This patch adds an SQL::Abstract inspired query syntax to the haspermission method in C4::Auth. One can now pass Arrayrefs to denote an OR list of flags, a Hashref to denote a AND list of flags. Structures can be nested at arbitrary depth.
My last attachment is an alternative implementation (and includes additional tests). Let me know what you think Nick.
I think this is fantastic, it will need documentation but should expand ability to use/combine permissions. Excellent work!
Created attachment 86197 [details] [review] Bug 22031: Add SQL::Abstract like syntax to haspermission This patch adds an SQL::Abstract inspired query syntax to the haspermission method in C4::Auth. One can now pass Arrayrefs to denote an OR list of flags, a Hashref to denote a AND list of flags. Structures can be nested at arbitrary depth. Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Created attachment 86204 [details] [review] Bug 22031: Add SQL::Abstract like syntax to haspermission This patch adds an SQL::Abstract inspired query syntax to the haspermission method in C4::Auth. One can now pass Arrayrefs to denote an OR list of flags, a Hashref to denote a AND list of flags. Structures can be nested at arbitrary depth. Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Awesome work all! Pushed to master for 19.05
Hi Nick, Wow, really pleased to see this one going through.. I thought it might come up against a bit more opposition :). So.. you mention additional documentation.. did you have any thoughts on what you might like.. some examples in the POD perhaps or were you thinking something on the wiki? I'm happy to oblige.
Enhancement, will not be backported to 18.11.x series.