function ctools_term_has_parent_ctools_access_settings in Chaos Tool Suite (ctools) 7
Settings form for the 'by parent term' access plugin.
1 string reference to 'ctools_term_has_parent_ctools_access_settings'
- term_has_parent.inc in plugins/
access/ term_has_parent.inc - Plugin to provide access control based upon a parent term.
File
- plugins/
access/ term_has_parent.inc, line 26 - Plugin to provide access control based upon a parent term.
Code
function ctools_term_has_parent_ctools_access_settings($form, &$form_state, $conf) {
// If no configuration was saved before, set some defaults.
if (empty($conf)) {
$conf = array(
'vid' => 0,
);
}
if (!isset($conf['vid'])) {
$conf['vid'] = 0;
}
$form['settings']['vid'] = array(
'#title' => t('Vocabulary'),
'#type' => 'select',
'#options' => array(),
'#description' => t('Select the vocabulary your parent term belongs to.'),
'#id' => 'ctools-select-vid',
'#default_value' => $conf['vid'],
'#required' => TRUE,
);
ctools_include('dependent');
$options = array();
// A note: Dependency works strangely on these forms as they have never been
// updated to a more modern system so they are not individual forms of their
// own like the content types.
$form['settings']['#tree'] = TRUE;
// Loop over each of the configured vocabularies.
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
$options[$vid] = $vocabulary->name;
$form['settings']['vid_' . $vid] = array(
'#title' => t('Terms'),
'#description' => t('Select a parent term (or terms) from the @vocabulary vocabulary.', array(
'@vocabulary' => $vocabulary->name,
)),
'#dependency' => array(
'ctools-select-vid' => array(
$vocabulary->vid,
),
),
'#default_value' => !empty($conf['vid_' . $vid]) ? $conf['vid_' . $vid] : '',
'#size' => 10,
'#multiple' => TRUE,
// @todo: Remove the following workaround when the following patch is in core. {@see:http://drupal.org/node/1117526}
'#name' => sprintf("settings[%u][]", $vid),
'#attributes' => array(
'multiple' => 'multiple',
),
);
$terms = array();
foreach (taxonomy_get_tree($vocabulary->vid) as $term) {
$terms[$term->tid] = str_repeat('-', $term->depth) . ($term->depth ? ' ' : '') . $term->name;
}
$form['settings']['vid_' . $vid]['#type'] = 'checkboxes';
$form['settings']['vid_' . $vid]['#options'] = $terms;
unset($terms);
}
$form['settings']['vid']['#options'] = $options;
$form['settings']['include_self'] = array(
'#title' => t('Include these parent term(s)?'),
'#description' => t('Should the term(s) you selected above be included in addition to their children?'),
'#default_value' => !empty($conf['include_self']) ? $conf['include_self'] : FALSE,
'#type' => 'checkbox',
);
return $form;
}