You are here

function content_access_role_based_form in Content Access 7

Same name and namespace in other branches
  1. 6 content_access.admin.inc \content_access_role_based_form()

Builds the role based permission form for the given defaults.

Parameters

$defaults: Array of defaults for all operations.

2 calls to content_access_role_based_form()
content_access_admin_settings in ./content_access.admin.inc
Per content type settings form.
content_access_page in ./content_access.admin.inc
Per node settings page.

File

./content_access.admin.inc, line 269
Content access administration UI.

Code

function content_access_role_based_form(&$form, $defaults = array(), $type = NULL) {
  $form['per_role'] = array(
    '#type' => 'fieldset',
    '#title' => t('Role based access control settings'),
    '#collapsible' => TRUE,
    '#description' => t('Note that users need at least the %view_published_content permission to be able to deal in any way with content.', array(
      '%view_published_content' => t('view published content'),
    )) . ' ' . t('Furthermore note that content which is not @published is treated in a different way by drupal: It can be viewed only by its author or users with the %bypass_node_access permission.', array(
      '@published' => t('published'),
      '%bypass_node_access' => t('bypass content access control'),
    )),
  );
  $operations = _content_access_get_operations($type);
  $roles = array_map('filter_xss_admin', user_roles());
  foreach ($operations as $op => $label) {

    // Make sure defaults are set properly
    $defaults += array(
      $op => array(),
    );
    $form['per_role'][$op] = array(
      '#type' => 'checkboxes',
      '#prefix' => '<div class="content_access-div">',
      '#suffix' => '</div>',
      '#options' => $roles,
      '#title' => $label,
      '#default_value' => $defaults[$op],
      '#process' => array(
        'form_process_checkboxes',
        'content_access_disable_checkboxes',
      ),
    );
  }
  $form['per_role']['clearer'] = array(
    '#value' => '<br clear="all" />',
  );
  drupal_add_css(drupal_get_path('module', 'content_access') . '/content_access.css');
  return $form;
}