You are here

function user_admin_access_add in Drupal 4

Same name and namespace in other branches
  1. 5 modules/user/user.module \user_admin_access_add()
  2. 6 modules/user/user.admin.inc \user_admin_access_add()

Menu callback: add an access rule

1 string reference to 'user_admin_access_add'
user_menu in modules/user.module
Implementation of hook_menu().

File

modules/user.module, line 1597
Enables the user registration and login system.

Code

function user_admin_access_add($mask = NULL, $type = NULL) {
  if ($edit = $_POST['edit']) {
    if (!$edit['mask']) {
      form_set_error('mask', t('You must enter a mask.'));
    }
    else {
      if (drupal_valid_token($_POST['edit']['form_token'], 'access_rule', TRUE)) {
        $aid = db_next_id('{access}_aid');
        db_query("INSERT INTO {access} (aid, mask, type, status) VALUES ('%s', '%s', '%s', %d)", $aid, $edit['mask'], $edit['type'], $edit['status']);
        drupal_set_message(t('The access rule has been added.'));
        drupal_goto('admin/access/rules');
      }
      else {
        form_set_error('form_token', t('Validation error, please try again.  If this error persists, please contact the site administrator.'));
      }
    }
  }
  else {
    $edit['mask'] = $mask;
    $edit['type'] = $type;
  }
  $form = _user_admin_access_form($edit);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add rule'),
  );
  return drupal_get_form('access_rule', $form);
}