Skip to content

Instantly share code, notes, and snippets.

@m7v
Created March 28, 2014 00:58
Show Gist options
  • Save m7v/9822733 to your computer and use it in GitHub Desktop.
Save m7v/9822733 to your computer and use it in GitHub Desktop.
Create access plugin
/**
* Implements hook_ctools_plugin_directory().
*/
function spaint_iframe_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools' || $module == 'panels' || $module == 'page_manager') {
return 'plugins/' . $plugin;
}
// Safety: go away if CTools is not at an appropriate version.
if (!module_invoke('ctools', 'api_version', VUD_REQUIRED_CTOOLS_API)) {
return;
}
if (in_array($module, array('ctools', 'panels', 'entityreference'))) {
return "plugins/$module/$plugin";
}
}
/**
* Implements hook_ctools_plugin_api().
*/
function spaint_iframe_ctools_plugin_api($owner, $api) {
if ($owner == 'panels') {
return array('version' => 2.0);
}
if ($owner == 'metatag' && $api == 'metatag') {
return array('version' => 1);
}
}
/**
* In plugin directory.
*/
$plugin = array(
'title' => t('iframe vk app'),
'description' => t('Is page opened in iframe'),
'callback' => 'spaint_iframe_app_callback',
'summary' => 'spaint_iframe_app_access_summary',
);
/**
* Callback.
*/
function spaint_iframe_app_callback($conf, $context) {
return spaint_site_is_app();
}
/**
* Describe an instance of this plugin.
*/
function spaint_iframe_app_access_summary($conf, $context) {
return t('Grant access only if user is customer or seller.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment