You are here

function content_access_role_based_form in Content Access 6

Same name and namespace in other branches
  1. 7 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.

3 calls to content_access_role_based_form()
content_access_admin_settings in ./content_access.admin.inc
Per content type administration page form.
content_access_page in ./content_access.admin.inc
Per node settings page.
content_access_rules_role_based_form in ./content_access.rules.inc
Adds the role based settings to the form.

File

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

Code

function content_access_role_based_form($defaults = array(), $type = NULL) {

  // Make sure defaults are set properly
  foreach (_content_access_get_operations() as $op) {
    $defaults += array(
      $op => array(),
    );
  }
  $roles = array_map('filter_xss_admin', user_roles());

  // Per type:
  $form['per_role'] = array(
    '#type' => 'fieldset',
    '#title' => t('Role based access control settings'),
    '#collapsible' => TRUE,
    '#description' => t('Note that users need at least the %access_content permission to be able to deal in any way with content.', array(
      '%access_content' => t('access 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 %administer_nodes permission.', array(
      '@published' => t('published'),
      '%administer_nodes' => t('administer nodes'),
    )),
  );
  drupal_add_css(drupal_get_path('module', 'content_access') . '/content_access.css');
  $form['per_role']['view'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div class="content_access-div">',
    '#suffix' => '</div>',
    '#options' => $roles,
    '#title' => t('View any @type content', array(
      '@type' => $type,
    )),
    '#default_value' => $defaults['view'],
    '#process' => array(
      'expand_checkboxes',
      'content_access_disable_checkboxes',
    ),
  );
  $form['per_role']['update'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div class="content_access-div">',
    '#suffix' => '</div>',
    '#options' => $roles,
    '#title' => t('Edit any @type content', array(
      '@type' => $type,
    )),
    '#default_value' => $defaults['update'],
    '#process' => array(
      'expand_checkboxes',
      'content_access_disable_checkboxes',
    ),
  );
  $form['per_role']['delete'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div class="content_access-div">',
    '#suffix' => '</div>',
    '#options' => $roles,
    '#title' => t('Delete any @type content', array(
      '@type' => $type,
    )),
    '#default_value' => $defaults['delete'],
    '#process' => array(
      'expand_checkboxes',
      'content_access_disable_checkboxes',
    ),
  );
  $form['per_role']['clearer'] = array(
    '#value' => '<br clear="all" />',
  );
  $form['per_role']['view_own'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div class="content_access-div">',
    '#suffix' => '</div>',
    '#options' => $roles,
    '#title' => t('View own @type content', array(
      '@type' => $type,
    )),
    '#default_value' => $defaults['view_own'],
    '#process' => array(
      'expand_checkboxes',
      'content_access_disable_checkboxes',
    ),
  );
  $form['per_role']['update_own'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div class="content_access-div">',
    '#suffix' => '</div>',
    '#options' => $roles,
    '#title' => t('Edit own @type content', array(
      '@type' => $type,
    )),
    '#default_value' => $defaults['update_own'],
    '#process' => array(
      'expand_checkboxes',
      'content_access_disable_checkboxes',
    ),
  );
  $form['per_role']['delete_own'] = array(
    '#type' => 'checkboxes',
    '#prefix' => '<div class="content_access-div">',
    '#suffix' => '</div>',
    '#options' => $roles,
    '#title' => t('Delete own @type content', array(
      '@type' => $type,
    )),
    '#default_value' => $defaults['delete_own'],
    '#process' => array(
      'expand_checkboxes',
      'content_access_disable_checkboxes',
    ),
  );
  $form['per_role']['clearer'] = array(
    '#value' => '<br clear="all" />',
  );
  return $form;
}