You are here

function user_admin_access_edit in Drupal 4

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

Menu callback: edit an access rule

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

File

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

Code

function user_admin_access_edit($aid = 0) {
  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)) {
        db_query("UPDATE {access} SET mask = '%s', type = '%s', status = '%s' WHERE aid = %d", $edit['mask'], $edit['type'], $edit['status'], $aid);
        drupal_set_message(t('The access rule has been saved.'));
        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 = db_fetch_array(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
  }
  $form = _user_admin_access_form($edit);
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save rule'),
  );
  return drupal_get_form('access_rule', $form);
}