summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-01-18 17:08:20 +0000
committerDries Buytaert <dries@buytaert.net>2010-01-18 17:08:20 +0000
commite7b9ad7676f1aa5fe33e1910bf39f27877a3e9c7 (patch)
tree7e3d4103bc0ae4ca3902d854aa00ffaec78f96cf /modules
parent36e33b75d5bc991a085755444d20b510b7ff9e1d (diff)
downloadbrdo-e7b9ad7676f1aa5fe33e1910bf39f27877a3e9c7.tar.gz
brdo-e7b9ad7676f1aa5fe33e1910bf39f27877a3e9c7.tar.bz2
- Patch #678504 by heyrocker, David_Rothstein: incorrect menu argument for ip address blocking.
Diffstat (limited to 'modules')
-rw-r--r--modules/system/system.admin.inc12
-rw-r--r--modules/system/system.module8
-rw-r--r--modules/system/system.test7
3 files changed, 15 insertions, 12 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 2fe7b5cc5..9e58b25f3 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -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(
diff --git a/modules/system/system.module b/modules/system/system.module
index 9d89278a7..465f6e266 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -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',
diff --git a/modules/system/system.test b/modules/system/system.test
index 9bdd3a5d6..cca0f6689 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -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();