acl_edit_form

Versions
5
acl_edit_form($acl_id, $label = NULL)
6 – 7
acl_edit_form($acl_id, $label = NULL, $new_acl = FALSE)

Provide a form to edit the ACL that can be embedded in other forms.

Code

contributions/acl/acl.module, line 64

<?php
function acl_edit_form($acl_id, $label = NULL) {
  // Ensure the ACL in question even exists.
  if (!$acl_name = db_result(db_query("SELECT name FROM {acl} WHERE acl_id = %d", $acl_id))) {
    return array();
  }
  if (!$label) {
    $label = $acl_name;
  }

  $form = array(
    '#type' => 'fieldset', 
    '#collapsible' => true, 
    '#title' => $label,
    '#tree' => true);


  $result = db_query("SELECT u.uid, u.name FROM {users} u LEFT JOIN {acl_user} aclu ON aclu.uid = u.uid WHERE acl_id = %d", $acl_id);
  $users = array();
  while ($user = db_fetch_object($result)) {
    $users[$user->uid] = $user->name;
  }

  $form['acl_id'] = array('#type' => 'value', '#value' => $acl_id);

  $form['deletions'] = array('#type' => 'checkboxes'); // placeholder
  $form['delete_button'] = array(
    '#type' => 'acl_button',
    '#label' => t('Remove Checked')
  );

  $form['add'] = array(
    '#type' => 'textfield', 
    '#title' => t('Add user'), 
    '#maxlength' => 60, 
    '#size' => 40,
    '#autocomplete_path' => 'user/autocomplete', 
  );
  $form['add_button'] = array(
    '#type' => 'acl_button',
    '#label' => t('Add User'),
  );

  $form['user_list'] = array(
    '#type' => 'hidden',
    '#default_value' => serialize($users),
  );

  $form['#after_build'] = array('acl_edit_form_after_build');
  
  return $form;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.