You are here

function content_access_page in Content Access 6

Same name and namespace in other branches
  1. 5 content_access.module \content_access_page()
  2. 7 content_access.admin.inc \content_access_page()

Per node settings page.

1 string reference to 'content_access_page'
content_access_menu in ./content_access.module
Implementation of hook_menu().

File

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

Code

function content_access_page(&$form_state, $node) {
  drupal_set_title(t('Access control for %title', array(
    '%title' => $node->title,
  )));
  foreach (_content_access_get_operations() as $op) {
    $defaults[$op] = content_access_per_node_setting($op, $node);
  }
  $form = content_access_role_based_form($defaults, $node->type);

  // Add a after_build handler that disables checkboxes, which are enforced by permissions.
  $form['per_role']['#after_build'] = array(
    'content_access_force_permissions',
  );
  if (module_exists('acl')) {

    // 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 = content_access_get_acl_id($node, $op);
      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, t('Grant !op access', array(
        '!op' => $op,
      )));
      $form['acl'][$op]['#collapsed'] = !isset($_POST['acl_' . $acl_id]) && !unserialize($form['acl'][$op]['user_list']['#default_value']);
    }
  }
  $form_state['node'] = $node;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#weight' => 10,
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
    '#weight' => 10,
    '#submit' => array(
      'content_access_page_reset',
    ),
    '#access' => count(content_access_get_per_node_settings($node)) > 0,
  );
  if (!$node->status) {
    drupal_set_message(t("Warning: Your content is not published, so this settings are not taken into account as long as the content remains unpublished."), 'error');
  }
  return $form;
}