You are here

function _acl_edit_form in ACL 7

Same name and namespace in other branches
  1. 8 acl.admin.inc \_acl_edit_form()
  2. 6 acl.admin.inc \_acl_edit_form()

Implementation of acl_edit_form().

1 call to _acl_edit_form()
acl_edit_form in ./acl.module
Provide a form to edit the ACL that can be embedded in other forms.

File

./acl.admin.inc, line 24
Implementations of administration functions for the acl module.

Code

function _acl_edit_form($acl_id, $label = NULL, $new_acl = FALSE) {
  $users = array();
  if (!$new_acl) {

    // Ensure the ACL in question even exists.
    if (!($record = db_query("SELECT name, number FROM {acl} WHERE acl_id = :acl_id", array(
      'acl_id' => $acl_id,
    ))
      ->fetchAssoc())) {
      return array();
    }
    $users = _acl_get_usernames($acl_id);
  }
  if (!isset($label)) {
    $label = isset($record['name']) ? $record['name'] : (isset($record['number']) ? $record['number'] : $acl_id);
  }
  $form = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#title' => check_plain($label),
    '#tree' => TRUE,
  );
  $form['acl_id'] = array(
    '#type' => 'value',
    '#value' => $acl_id,
  );
  $form['deletions'] = array(
    '#type' => 'checkboxes',
    '#options' => array(),
  );

  // placeholder
  $form['delete_button'] = array(
    '#type' => 'button',
    '#name' => 'acl_' . $acl_id,
    '#value' => t('Remove Checked'),
    '#submit' => FALSE,
  );
  $form['add'] = array(
    '#type' => 'textfield',
    '#title' => t('Add user'),
    '#maxlength' => 60,
    '#size' => 40,
    '#autocomplete_path' => 'user/autocomplete',
  );
  $form['add_button'] = array(
    '#type' => 'button',
    '#name' => 'acl_' . $acl_id,
    '#value' => t('Add User'),
    '#submit' => FALSE,
  );
  $form['user_list'] = array(
    '#type' => 'hidden',
    '#default_value' => serialize($users),
  );
  $form['#after_build'] = array(
    '_acl_edit_form_after_build',
  );
  return $form;
}