function content_access_admin_settings_submit in Content Access 5
Same name and namespace in other branches
- 6 content_access.admin.inc \content_access_admin_settings_submit()
- 7 content_access.admin.inc \content_access_admin_settings_submit()
File
- ./
content_access.module, line 257
Code
function content_access_admin_settings_submit($form_id, $form_values) {
$per_node_old = content_access_get_settings('per_node', $form_values['type']);
$settings = content_access_get_settings();
foreach (content_access_available_settings() as $setting) {
if (is_array($form_values[$setting])) {
unset($form_values[$setting][0]);
$form_values[$setting] = array_filter($form_values[$setting]);
}
$settings[$setting][$form_values['type']] = $form_values[$setting];
}
content_access_set_settings($settings);
// Mass update all nodes that use default settings.
if (content_access_get_settings('per_node', $form_values['type']) && $per_node_old) {
$sql = "SELECT n.nid FROM {node} n LEFT JOIN {content_access} na ON na.nid = n.nid\n WHERE type = '%s' AND na.nid IS NULL";
}
else {
$sql = "SELECT n.nid FROM {node} n WHERE type = '%s'";
}
// If per node has been disabled and we use the ACL integration, we have to remove possible ACLs now.
$remove_acls = !content_access_get_settings('per_node', $form_values['type']) && $per_node_old && module_exists('acl');
$result = db_query($sql, $form_values['type']);
while ($node = db_fetch_object($result)) {
if ($remove_acls) {
acl_node_clear_acls($node->nid, 'content_access');
}
node_access_acquire_grants(node_load($node->nid));
}
cache_clear_all();
drupal_set_message('Your changes have been saved.');
}