--- modules/user.module 2006-01-07 20:26:57.000000000 +0530 +++ modules/user.module.new 2006-01-07 21:23:48.000000000 +0530 @@ -1363,60 +1363,67 @@ function user_configure_settings() { * Menu callback: check an access rule */ function user_admin_access_check() { - $op = isset($_POST['op']) ? $_POST['op'] : ''; - $edit = isset($_POST['edit']) ? $_POST['edit'] : ''; - - if (!empty($op)) { - if (!empty($edit['user']['test'])) { - if (drupal_is_denied('user', $edit['user']['test'])) { - drupal_set_message(t('The username %name is not allowed.', array('%name' => theme('placeholder', $edit['user']['test'])))); - } - else { - drupal_set_message(t('The username %name is allowed.', array('%name' => theme('placeholder', $edit['user']['test'])))); - } - } - if (!empty($edit['mail']['test'])) { - if (drupal_is_denied('mail', $edit['mail']['test'])) { - drupal_set_message(t('The e-mail address %mail is not allowed.', array('%mail' => theme('placeholder', $edit['mail']['test'])))); - } - else { - drupal_set_message(t('The e-mail address %mail is allowed.', array('%mail' => theme('placeholder', $edit['mail']['test'])))); - } - } - if (!empty($edit['host']['test'])) { - if (drupal_is_denied('host', $edit['host']['test'])) { - drupal_set_message(t('The hostname %host is not allowed.', array('%host' => theme('placeholder', $edit['host']['test'])))); - } - else { - drupal_set_message(t('The hostname %host is allowed.', array('%host' => theme('placeholder', $edit['host']['test'])))); - } - } - } - $form['user'] = array('#type' => 'fieldset', '#title' => t('Username')); $form['user']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a username to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64); $form['user']['type'] = array('#type' => 'hidden', '#value' => 'user'); $form['user']['submit'] = array('#type' => 'submit', '#value' => t('Check username')); - $output .= drupal_get_form('check_user', $form); + $output .= drupal_get_form('check_user', $form, 'user_admin_access_check'); unset($form); // prevent endless loop? $form['mail'] = array('#type' => 'fieldset', '#title' => t('E-mail')); $form['mail']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter an e-mail address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64); $form['mail']['type'] = array('#type' => 'hidden', '#value' => 'mail'); $form['mail']['submit'] = array('#type' => 'submit', '#value' => t('Check e-mail')); - $output .= drupal_get_form('check_mail', $form); + $output .= drupal_get_form('check_mail', $form, 'user_admin_access_check'); unset($form); // prevent endless loop? $form['host'] = array('#type' => 'fieldset', '#title' => t('Hostname')); $form['host']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a hostname or IP address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64); $form['host']['type'] = array('#type' => 'hidden', '#value' => 'host'); $form['host']['submit'] = array('#type' => 'submit', '#value' => t('Check hostname')); - $output .= drupal_get_form('check_host', $form); + $output .= drupal_get_form('check_host', $form, 'user_admin_access_check'); unset($form); // prevent endless loop? return $output; } +function user_admin_access_check_validate($form_id, $edit) { + if (empty($edit['test'])) { + form_set_error($edit['type'], t('No value entered. Please enter a test string and try again.')); + } +} + +function user_admin_access_check_submit($form_id, $edit) { + switch ($edit['type']) { + case 'user': + if (drupal_is_denied('user', $edit['test'])) { + drupal_set_message(t('The username %name is not allowed.', array('%name' => theme('placeholder', $edit['test'])))); + } + else { + drupal_set_message(t('The username %name is allowed.', array('%name' => theme('placeholder', $edit['test'])))); + } + break; + case 'mail': + if (drupal_is_denied('mail', $edit['test'])) { + drupal_set_message(t('The e-mail address %mail is not allowed.', array('%mail' => theme('placeholder', $edit['test'])))); + } + else { + drupal_set_message(t('The e-mail address %mail is allowed.', array('%mail' => theme('placeholder', $edit['test'])))); + } + break; + case 'host': + if (drupal_is_denied('host', $edit['test'])) { + drupal_set_message(t('The hostname %host is not allowed.', array('%host' => theme('placeholder', $edit['test'])))); + } + else { + drupal_set_message(t('The hostname %host is allowed.', array('%host' => theme('placeholder', $edit['test'])))); + } + break; + default: + break; + } +} + /** * Menu callback: add an access rule */