function content_access_admin_settings_submit in Content Access 6
Same name and namespace in other branches
- 5 content_access.module \content_access_admin_settings_submit()
- 7 content_access.admin.inc \content_access_admin_settings_submit()
File
- ./
content_access.admin.inc, line 141 - Content access administration UI.
Code
function content_access_admin_settings_submit($form, &$form_state) {
// Where possible let the drupal permissions system handle access control.
$permissions = content_access_get_permissions_by_role();
foreach (array(
'update',
'update_own',
'delete',
'delete_own',
) as $op) {
foreach ($form_state['values'][$op] as $rid => $value) {
$permissions[$rid][content_access_get_permission_by_op($op, $form_state['type'])] = $value;
}
// Don't save the setting, so its default value (get permission) is applied always.
unset($form_state['values'][$op]);
}
content_access_save_permissions($permissions);
// Update content access settings
$settings = content_access_get_settings();
foreach (content_access_available_settings() as $setting) {
unset($settings[$setting][$form_state['type']]);
if (isset($form_state['values'][$setting])) {
$settings[$setting][$form_state['type']] = is_array($form_state['values'][$setting]) ? array_keys(array_filter($form_state['values'][$setting])) : $form_state['values'][$setting];
}
}
content_access_set_settings($settings);
$type = $form_state['type'];
// Mass update the nodes, but only if necessary.
if (content_access_get_settings('per_node', $type) || content_access_get_settings('view', $type) != $form['per_role']['view']['#default_value'] || content_access_get_settings('view_own', $type) != $form['per_role']['view_own']['#default_value'] || content_access_get_settings('priority', $type) != $form['advanced']['priority']['#default_value'] || content_access_get_settings('per_node', $type) != $form['node']['per_node']['#default_value']) {
// If per node has been disabled and we use the ACL integration, we have to remove possible ACLs now.
if (!content_access_get_settings('per_node', $type) && $form['node']['per_node']['#default_value'] && module_exists('acl')) {
_content_access_remove_acls($type);
}
if (content_access_mass_update(array(
$type,
))) {
drupal_set_message(t('Permissions have been successfully rebuilt for the content type @types.', array(
'@types' => node_get_types('name', $type),
)));
}
}
drupal_set_message(t('Your changes have been saved.'));
}