function workbench_access_settings_submit in Workbench Access 7
Set configuration.
1 string reference to 'workbench_access_settings_submit'
- workbench_access_settings_form in ./
workbench_access.admin.inc - Settings form for Workbench Access configuration.
File
- ./
workbench_access.admin.inc, line 202 - Workbench Access admin file.
Code
function workbench_access_settings_submit($form, &$form_state) {
// Reset the tree.
workbench_access_reset_tree();
// If auto-assign, then do so.
if (empty($form_state['values']['workbench_access_auto_assign'])) {
return;
}
// Get the new tree rules and check for changes.
$active = workbench_access_get_active_tree();
foreach ($active['tree'] as $key => $item) {
$data = array_merge($active['access_scheme'], $item);
if (!isset($active['active'][$key]) && !empty($form_state['values']['workbench_access_' . $active['access_scheme']['access_scheme']][$item['access_type_id']])) {
workbench_access_section_save($data);
}
elseif (empty($form_state['values']['workbench_access_' . $active['access_scheme']['access_scheme']][$item['access_type_id']])) {
workbench_access_section_delete($data);
}
}
// Make sure we cleaned out all the old sections.
$sections = db_query("SELECT * FROM {workbench_access} WHERE access_type = :access_type", array(
':access_type' => $active['access_scheme']['access_type'],
))
->fetchAll();
foreach ($sections as $section) {
if (empty($form_state['values']['workbench_access_' . $active['access_scheme']['access_scheme']][$section->access_type_id])) {
workbench_access_section_delete((array) $section);
}
}
// If field settings are present, save them.
if (isset($form_state['values']['field_elements'])) {
workbench_access_save_field_elements($form_state['values']['field_elements']);
}
}