I am currently having a problem where tabs are being displayed for displays that the current user does not have access to. When the user clicks the tab, the view is not loaded, as they do not have access. Ideally, the tab simply shouldn't display at all.
I'm a little confused by this behaviour as I was sure it was behaving correctly in the past, so perhaps someone can tell me what I am doing wrong? It is possible that I have done something elsewhere that has conflicted with viewsdisplaytabs. I've looked at the code, but couldn't see how tabs were being hidden from users who don't have access to them, so if the mistake is mine, some advice on how this is being done at present would be great.
I have currently implemented a workaround (which I have attached as a patch). The workaround just adds an access check inside viewsdisplaytabs_preprocess_views_view(). I couldn't work out the "drupal way" of adding an access check so I wrote my own method to perform the access check. This is not ideal as it means that displays using access "types" that have been added to Views via a module (e.g. Spaces) will effectively be ignored by viewsdisplaytabs.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | viewsdisplaytabs2.patch | 1.95 KB | nicks |
| viewsdisplaytabs_access.patch | 4.31 KB | nicks |
Comments
Comment #1
1timer commentedsub
Comment #2
swentel commentedChecking on access is good, but you should rather use the views way to check on the access, a simple $view->access($display_id) should do the trick fine.
Comment #3
nicks commentedThanks for the tip.
Here is an updated patch just using the $view->access($display_id) approach as suggested by swentel. I have put this condition as a separate statement as otherwise the previous one becomes too long to fit on one line.
Comment #4
andrii_svirin commentedI changed only one string 78 in module file to:
if ((!$selected_displays || !count($selected_displays) || in_array($display_name, $selected_displays)) &&
($view->access($display_data->id))) {
And access work
Comment #5
goatsee commentedParashutiki!
I think I just spent 15 hours trying to figure out how to do this. Thank you!!
-Dylan
Comment #6
druvision commented+1 for including #4 on the dev version. Works for me. Except that if there's only one tab, the tab should be hidden.
Comment #7
solipsist commentedGood catch. Will be committed.