<?php
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t('Webform machine name'),
'description' => t('Controls access depends on webform machine name'),
'required context' => array(new ctools_context_required(t('Node'), 'node')),
'callback' => 'bmi_access_webform_machine_name',
'settings form' => 'bmi_access_webform_machine_name_access_settings_form',
'summary' => 'bmi_access_webform_machine_name_access_summary',
);
/**
* Settings form for our access plugin.
*/
function bmi_access_webform_machine_name_access_settings_form(&$form, &$form_state, $conf) {
$form['settings']['webform_machine_name'] = array(
'#type' => 'textfield',
'#title' => t('Webform machine name'),
'#description' => t('Will provide access, if loaded webform machine name is matched'),
'#default_value' => !empty($conf['webform_machine_name']) ? $conf['webform_machine_name'] : '',
'#required' => TRUE,
);
return $form;
}
/**
* Provide a summary description based on selected settings.
*/
function bmi_access_webform_machine_name_access_summary($conf, $context) {
if (!empty($conf['webform_machine_name']))
return t('Will provide access, if loaded webform machine name is matched: ') . $conf['webform_machine_name'];
}
/**
* Check for access.
*/
function bmi_access_webform_machine_name($conf, $context) {
return $context[0]->data->webform['machine_name'] == $conf['webform_machine_name'] ? TRUE : FALSE;
}