To avoid having to try and write an access plugin for every use-case you might imagine (I need one to show/hide panes based on arguments passed to the panel page), perhaps it would be easier to have a PHP access plugin. You would be able to enter php which return TRUE (for access granted) or FALSE (for access denied).

Thoughts on the matter?

CommentFileSizeAuthor
#2 ctools_access_plugin_php.patch2.46 KBmoonray

Comments

merlinofchaos’s picture

I have to agree with this. The list of possible use-cases is mighty. Though it is not difficult to write access plugins, either. We have to weigh the difficulty in writing them (after all you still have to have a module and the framework) vs the general distaste of embedding too much CSS into objects like this.

It probably is valuable, nonetheless.

moonray’s picture

Assigned: Unassigned » moonray
Status: Active » Needs review
StatusFileSize
new2.46 KB

Attached is a patch for a PHP access plugin.
There a few things that I'd like to improve on, but don't see a way to do with the provided arguments.

* Need a way to provide all available contexts to the eval-ed PHP. Currently the $context argument is available to the PHP, but we have no way to send all available contexts to this function without explicitly listing them all (which means we can only list the ones included with ctools, which is limiting).

merlinofchaos’s picture

content types have a mechanism to get all contexts instead of using configuration, which Views use to be able to be a little smarter about context. This mechanism probably needs to be added to the access plugin code as well.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed with some fixes and permission checking and 'all contexts'.

friolator’s picture

Thanks for implementing this - sounds like it's going to save us a ton of time!

Sorry for being completely daft here, but is there any documentation on how $context is structured? is it an array? a string?

If we're passing a panel an optional argument "!filter" -- and we want to display different panels based on that argument (ie: is it a Username or a Manufacturer, or a Product?), how do we test $context in the PHP Code Selection Rule?

Thanks!

markus_petrux’s picture

It's a class defined in ctools/includes/context.inc. The different context implementations can be found in ctools/plugins/contexts.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.