function workbench_access_section_form in Workbench Access 7
Administer section definitions.
1 string reference to 'workbench_access_section_form'
- workbench_access_menu in ./
workbench_access.module - Implements hook_menu().
File
- ./
workbench_access.admin.inc, line 265 - Workbench Access admin file.
Code
function workbench_access_section_form($form, &$form_state) {
$active = workbench_access_get_active_tree();
// Ensure that we have configured access controls.
if (!($active = workbench_access_get_active_tree())) {
$form['help']['#markup'] = workbench_access_configuration_needed_message();
return $form;
}
$form = array();
$form['access_scheme'] = array(
'#type' => 'value',
'#value' => $active['access_scheme'],
);
$form['access_tree'] = array(
'#type' => 'value',
'#value' => $active['tree'],
);
$form['help'] = array(
'#markup' => '<h2>' . t('Active editorial sections') . '</h2><p>' . t('Below is a list of the editorial sections defined for your site.') . '</p>',
);
if (variable_get('workbench_access_auto_assign', 1)) {
$form['help']['#markup'] .= '<p>' . t('All sections are set to be active automatically. <a href="!url">Disable the <em>Automated section assignment</em> option</a> to make changes.', array(
'!url' => url('admin/config/workbench/access/settings'),
)) . '</p>';
}
$form['sections']['#tree'] = TRUE;
$active_items = array_keys($active['active']);
$parent = 0;
$used = array();
foreach ($active['tree'] as $section) {
if (in_array($section['access_id'], $used)) {
continue;
}
if ($section['depth'] == 0) {
$parent = $section['access_id'];
$collapsed = TRUE;
if (isset($active['active'][$parent])) {
$collapsed = FALSE;
}
elseif (!empty($section['children'])) {
$check = array_intersect($active_items, $section['children']);
if (!empty($check)) {
$collapsed = FALSE;
}
}
$form['sections'][$parent] = array(
'#type' => 'fieldset',
'#title' => check_plain($section['name']),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#tree' => TRUE,
);
}
$string = str_repeat('-', $section['depth']) . ' ' . check_plain($section['name']);
$form['sections'][$parent][$section['access_id']] = array(
'#type' => 'checkbox',
'#title' => $section['depth'] == 0 ? t('All of @string', array(
'@string' => $string,
)) : t('@string', array(
'@string' => $string,
)),
'#default_value' => isset($active['active'][$section['access_id']]),
'#disabled' => variable_get('workbench_access_auto_assign', 1),
);
$used[] = $section['access_id'];
}
if (!variable_get('workbench_access_auto_assign', 1)) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save sections'),
);
}
return $form;
}