I have a requirement to show an anonymous version of a block Flag Page provides without the use of Session API. Flag Page currently has check to $flag->user_access before continuing on. This checks to see which roles have access to a flag and can't be overridden from my module.
From what I can see this check can be removed or replaced by $flag->user_access, which can be overridden as needed using hook_flag_access(). Both flag_create_lazy_page_link and flag_create_link each run through flag's API and perform all access checks that should be required. For example, flag_create_lazy_page_link calls flag_get_flags, which filters out flags that a user doesn't have access to by calling flag_access, which in turn calls $flag->user_access.
With this patch the result of access is is $content = "", which allows my module's preprocess functions to run. If $content = "" after all processing the block simply will not print as per before this patch. There may be better ways to accomplish the same - suggestions welcome.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 1033886_flag_access_change.patch | 876 bytes | alexpott |
| flag_page_remove_unneeded_access_check.patch | 779 bytes | rickvug |
Comments
Comment #1
alexpottHi Rick,
Finally got round to looking at this. My first thought is my not just create a block that only displays for user's with the opposite permissions of those that have access to the flag. BUT I understand that in a way that'd be kind of annoying as you have to remember to change the this extra block if you adjust the flag's permissions.
I've made a slight change to your patch which keeps the access check in so any unnecessary work is not done but still generates a content key in the block array so you can do your preprocess functions.
Nice meeting you in Brussels.
Cheers,
Alex