- Patch #678504 by heyrocker, David_Rothstein: incorrect menu argument for ip address blocking.
parent
36e33b75d5
commit
e7b9ad7676
|
@ -1390,8 +1390,12 @@ function system_modules_uninstall_submit($form, &$form_state) {
|
|||
|
||||
/**
|
||||
* Menu callback. Display blocked IP addresses.
|
||||
*
|
||||
* @param $default_ip
|
||||
* Optional IP address to be passed on to drupal_get_form() for
|
||||
* use as the default value of the IP address form field.
|
||||
*/
|
||||
function system_ip_blocking() {
|
||||
function system_ip_blocking($default_ip = '') {
|
||||
$output = '';
|
||||
$rows = array();
|
||||
$header = array(t('IP address'), t('Operations'));
|
||||
|
@ -1403,7 +1407,7 @@ function system_ip_blocking() {
|
|||
);
|
||||
}
|
||||
|
||||
$build['system_ip_blocking_form'] = drupal_get_form('system_ip_blocking_form');
|
||||
$build['system_ip_blocking_form'] = drupal_get_form('system_ip_blocking_form', $default_ip);
|
||||
|
||||
$build['system_ip_blocking_table'] = array(
|
||||
'#theme' => 'table',
|
||||
|
@ -1421,13 +1425,13 @@ function system_ip_blocking() {
|
|||
* @see system_ip_blocking_form_validate()
|
||||
* @see system_ip_blocking_form_submit()
|
||||
*/
|
||||
function system_ip_blocking_form($form, $form_state) {
|
||||
function system_ip_blocking_form($form, $form_state, $default_ip) {
|
||||
$form['ip'] = array(
|
||||
'#title' => t('IP address'),
|
||||
'#type' => 'textfield',
|
||||
'#size' => 64,
|
||||
'#maxlength' => 32,
|
||||
'#default_value' => arg(4),
|
||||
'#default_value' => $default_ip,
|
||||
'#description' => t('Enter a valid IP address.'),
|
||||
);
|
||||
$form['submit'] = array(
|
||||
|
|
|
@ -692,14 +692,6 @@ function system_menu() {
|
|||
'access arguments' => array('block IP addresses'),
|
||||
'file' => 'system.admin.inc',
|
||||
);
|
||||
$items['admin/config/people/ip-blocking/%'] = array(
|
||||
'title' => 'IP address blocking',
|
||||
'description' => 'Manage blocked IP addresses.',
|
||||
'page callback' => 'system_ip_blocking',
|
||||
'access arguments' => array('block IP addresses'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'system.admin.inc',
|
||||
);
|
||||
$items['admin/config/people/ip-blocking/delete/%blocked_ip'] = array(
|
||||
'title' => 'Delete IP address',
|
||||
'page callback' => 'drupal_get_form',
|
||||
|
|
|
@ -372,6 +372,13 @@ class IPAddressBlockingTestCase extends DrupalWebTestCase {
|
|||
$this->drupalPost('admin/config/people/ip-blocking', $edit, t('Save'));
|
||||
$this->assertText(t('Enter a valid IP address.'));
|
||||
|
||||
// Pass an IP address as a URL parameter and submit it.
|
||||
$submit_ip = '1.2.3.4';
|
||||
$this->drupalPost('admin/config/people/ip-blocking/' . $submit_ip, NULL, t('Save'));
|
||||
$ip = db_query("SELECT iid from {blocked_ips} WHERE ip = :ip", array(':ip' => $submit_ip))->fetchField();
|
||||
$this->assertTrue($ip, t('IP address found in database'));
|
||||
$this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $submit_ip)), t('IP address was blocked.'));
|
||||
|
||||
// Submit your own IP address. This fails, although it works when testing manually.
|
||||
// TODO: on some systems this test fails due to a bug or inconsistency in cURL.
|
||||
// $edit = array();
|
||||
|
|
Loading…
Reference in New Issue