function ctools_access_new_test in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/context.inc \ctools_access_new_test()
Create default settings for a new access plugin.
Parameters
$plugin: The access plugin being used.
Return value
A default configured test that should be placed in $access['plugins'];
1 call to ctools_access_new_test()
- ctools_access_ajax_add in includes/
context-access-admin.inc - AJAX callback to add a new access test to the list.
File
- includes/
context.inc, line 1464 - Contains code related to the ctools system of 'context'.
Code
function ctools_access_new_test($plugin) {
$test = array(
'name' => $plugin['name'],
'settings' => array(),
);
// Set up required context defaults.
if (isset($plugin['required context'])) {
if (is_object($plugin['required context'])) {
$test['context'] = '';
}
else {
$test['context'] = array();
foreach ($plugin['required context'] as $required) {
$test['context'][] = '';
}
}
}
$default = NULL;
if (isset($plugin['default'])) {
$default = $plugin['default'];
}
elseif (isset($plugin['defaults'])) {
$default = $plugin['defaults'];
}
// Setup plugin defaults.
if (isset($default)) {
if (is_array($default)) {
$test['settings'] = $default;
}
else {
if (function_exists($default)) {
$test['settings'] = $default();
}
else {
$test['settings'] = array();
}
}
}
return $test;
}