function content_access_page_form in Content Access 5
Builds per node setting page form without requiring a node. Used by content_access_action_set_node_permissions_form().
Parameters
$defaults: Array of defaults for view/update/delete checkboxes.
$node: Optional node for ACL.
3 calls to content_access_page_form()
- content_access_action_set_node_permissions_form in ./
content_access.workflow_ng.inc - Form for configuring content_access_action_set_node_permissions action.
- content_access_condition_check_permissions_form in ./
content_access.workflow_ng.inc - Form for configuring content_access_condition_check_permissions().
- content_access_page in ./
content_access.module
File
- ./
content_access.module, line 95
Code
function content_access_page_form($defaults = array(), $node = FALSE) {
// Make sure defaults array is full.
foreach (array(
'view',
'update',
'delete',
) as $op) {
if (!isset($defaults[$op])) {
$defaults[$op] = array();
}
}
$roles = content_access_get_roles_and_author();
$form['settings'] = array(
'#type' => 'fieldset',
'#title' => t('Role access control settings'),
'#collapsible' => TRUE,
);
if (!$node) {
$form['settings']['#description'] = t('Warning: No defaults are set; be sure to fill out all boxes appropriately.');
}
drupal_add_css(drupal_get_path('module', 'content_access') . '/content_access.css');
$form['settings']['view'] = array(
'#type' => 'checkboxes',
'#prefix' => '<div class="content_access-div">',
'#suffix' => '</div>',
'#options' => $roles,
'#title' => t('View'),
'#default_value' => $defaults['view'],
);
$form['settings']['update'] = array(
'#type' => 'checkboxes',
'#prefix' => '<div class="content_access-div">',
'#suffix' => '</div>',
'#options' => $roles,
'#title' => t('Edit'),
'#default_value' => $defaults['update'],
);
$form['settings']['delete'] = array(
'#type' => 'checkboxes',
'#prefix' => '<div class="content_access-div">',
'#suffix' => '</div>',
'#options' => $roles,
'#title' => t('Delete'),
'#default_value' => $defaults['delete'],
);
$form['settings']['clearer'] = array(
'#value' => '<br clear="all" />',
);
if (module_exists('acl') && $node) {
// This is disabled when there is no node passed.
$form['acl'] = array(
'#type' => 'fieldset',
'#title' => t('User access control lists'),
'#description' => t('These settings allow you to grant access to specific users.'),
'#collapsible' => TRUE,
'#tree' => TRUE,
);
foreach (array(
'view',
'update',
'delete',
) as $op) {
$acl_id = acl_get_id_by_name('content_access', $op . '_' . $node->nid);
if (!$acl_id) {
// Create one:
$acl_id = acl_create_new_acl('content_access', $op . '_' . $node->nid);
}
acl_node_add_acl($node->nid, $acl_id, $op == 'view', $op == 'update', $op == 'delete', content_access_get_settings('priority', $node->type));
$form['acl'][$op] = acl_edit_form($acl_id, 'Grant ' . $op . ' access');
$form['acl'][$op]['#collapsed'] = !isset($_POST['acl'][$op]['add_button']) && !isset($_POST['acl'][$op]['delete_button']);
}
}
return $form;
}