1 |
08475715
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Plugin for controlling access based on the existence of a query string.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
$plugin = array(
|
9 |
|
|
'title' => t('Query string exists'),
|
10 |
|
|
'description' => t('Control access by whether or not a query string exists.'),
|
11 |
|
|
'callback' => 'ctools_query_string_exists_ctools_access_check',
|
12 |
|
|
'settings form' => 'ctools_query_string_exists_ctools_access_settings',
|
13 |
|
|
'summary' => 'ctools_query_string_exists_ctools_access_summary',
|
14 |
|
|
'defaults' => array('key' => ''),
|
15 |
|
|
);
|
16 |
|
|
|
17 |
|
|
/**
|
18 |
|
|
* Settings form.
|
19 |
|
|
*/
|
20 |
|
|
function ctools_query_string_exists_ctools_access_settings($form, &$form_state, $config) {
|
21 |
|
|
$form['settings']['key'] = array(
|
22 |
|
|
'#title' => t('Query string key'),
|
23 |
|
|
'#description' => t('Enter the key of the query string.'),
|
24 |
|
|
'#type' => 'textfield',
|
25 |
|
|
'#required' => TRUE,
|
26 |
c304a780
|
Assos Assos
|
'#default_value' => $config['key'],
|
27 |
08475715
|
Assos Assos
|
);
|
28 |
|
|
|
29 |
|
|
return $form;
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
/**
|
33 |
|
|
* Check for access.
|
34 |
|
|
*/
|
35 |
|
|
function ctools_query_string_exists_ctools_access_check($config, $context) {
|
36 |
|
|
return isset($_GET[$config['key']]);
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
|
|
* Provide a summary description.
|
41 |
|
|
*/
|
42 |
|
|
function ctools_query_string_exists_ctools_access_summary($config, $context) {
|
43 |
|
|
return t('@identifier exists', array('@identifier' => $config['key']));
|
44 |
|
|
} |