Index: modules/contact/contact.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.admin.inc,v retrieving revision 1.14 diff -u -p -r1.14 contact.admin.inc --- modules/contact/contact.admin.inc 19 Aug 2009 12:56:47 -0000 1.14 +++ modules/contact/contact.admin.inc 6 Sep 2009 22:40:03 -0000 @@ -162,18 +162,3 @@ function contact_admin_delete_submit($fo $form_state['redirect'] = 'admin/structure/contact'; return; } - -function contact_admin_settings() { - $form['contact_hourly_threshold'] = array('#type' => 'select', - '#title' => t('Hourly threshold'), - '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)), - '#default_value' => 3, - '#description' => t('The maximum number of contact form submissions a user can perform per hour.'), - ); - $form['contact_default_status'] = array( - '#type' => 'checkbox', - '#title' => t('Enable the personal contact form by default for new users'), - '#default_value' => 1, - ); - return system_settings_form($form, TRUE); -} Index: modules/contact/contact.install =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v retrieving revision 1.13 diff -u -p -r1.13 contact.install --- modules/contact/contact.install 27 May 2009 18:33:56 -0000 1.13 +++ modules/contact/contact.install 6 Sep 2009 22:40:03 -0000 @@ -84,3 +84,9 @@ function contact_schema() { return $schema; } + +function contact_update_7000() { + variable_set('contact_threshold_limit', variable_get('contact_hourly_threshold', 3)); + variable_del('contact_hourly_threshold'); + return array(); +} Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.125 diff -u -p -r1.125 contact.module --- modules/contact/contact.module 31 Aug 2009 18:40:00 -0000 1.125 +++ modules/contact/contact.module 6 Sep 2009 22:40:03 -0000 @@ -59,12 +59,6 @@ function contact_menu() { 'access arguments' => array('administer site-wide contact form'), 'file' => 'contact.admin.inc', ); - $items['admin/structure/contact/list'] = array( - 'title' => 'List', - 'page callback' => 'contact_admin_categories', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'file' => 'contact.admin.inc', - ); $items['admin/structure/contact/add'] = array( 'title' => 'Add category', 'page callback' => 'drupal_get_form', @@ -90,15 +84,6 @@ function contact_menu() { 'type' => MENU_CALLBACK, 'file' => 'contact.admin.inc', ); - $items['admin/structure/contact/settings'] = array( - 'title' => 'Settings', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('contact_admin_settings'), - 'access arguments' => array('administer site-wide contact form'), - 'file' => 'contact.admin.inc', - 'type' => MENU_LOCAL_TASK, - 'weight' => 1, - ); $items['contact'] = array( 'title' => 'Contact', 'page callback' => 'contact_site_page', @@ -201,3 +186,19 @@ function contact_mail($key, &$message, $ break; } } + +/** + * Implement of hook_form_FORM_ID_alter(). + */ +function contact_form_user_admin_settings_alter(&$form, $form_state) { + $form['contact'] = array( + '#type' => 'fieldset', + '#title' => t('Contact forms'), + '#weight' => 0, + ); + $form['contact']['contact_default_status'] = array( + '#type' => 'checkbox', + '#title' => t('Enable the personal contact form by default for new users'), + '#default_value' => 1, + ); +} Index: modules/contact/contact.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v retrieving revision 1.23 diff -u -p -r1.23 contact.pages.inc --- modules/contact/contact.pages.inc 20 Jul 2009 18:51:33 -0000 1.23 +++ modules/contact/contact.pages.inc 6 Sep 2009 22:40:03 -0000 @@ -11,8 +11,8 @@ * Site-wide contact page. */ function contact_site_page() { - if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3)) && !user_access('administer site-wide contact form')) { - $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3))); + if (!flood_is_allowed('contact', variable_get('contact_threshold_limit', 3), variable_get('contact_threshold_window', 3600)) && !user_access('administer site-wide contact form')) { + $output = t("You cannot send more than %number messages in @interval. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3), '@interval' => format_interval(variable_get('contact_threshold_window', 3600)))); } elseif (!db_query("SELECT COUNT(cid) FROM {contact}")->fetchField()) { if (user_access('administer site-wide contact form')) { Index: modules/contact/contact.test =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.test,v retrieving revision 1.30 diff -u -p -r1.30 contact.test --- modules/contact/contact.test 31 Aug 2009 18:40:00 -0000 1.30 +++ modules/contact/contact.test 6 Sep 2009 22:40:03 -0000 @@ -26,10 +26,10 @@ class ContactSitewideTestCase extends Dr $this->drupalLogin($admin_user); // Set settings. + variable_set('contact_threshold_limit', 3); $edit = array(); - $edit['contact_hourly_threshold'] = 3; $edit['contact_default_status'] = TRUE; - $this->drupalPost('admin/structure/contact/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); // Delete old categories to ensure that new categories are used. @@ -145,7 +145,7 @@ class ContactSitewideTestCase extends Dr } // Submit contact form one over limit. $this->drupalGet('contact'); - $this->assertRaw(t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => $edit['contact_hourly_threshold'])), t('Message threshold reached.')); + $this->assertRaw(t('You cannot send more than %number messages in @interval. Please try again later.', array('%number' => variable_get('contact_threshold_limit', 3), '@interval' => format_interval(variable_get('contact_threshold_window', 3600)))), t('Message threshold reached.')); // Delete created categories. $this->drupalLogin($admin_user); @@ -157,7 +157,7 @@ class ContactSitewideTestCase extends Dr */ function testAutoReply() { // Create and login administrative user. - $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer site-wide contact form', 'administer permissions')); + $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer site-wide contact form', 'administer permissions', 'administer users')); $this->drupalLogin($admin_user); // Set up three categories, 2 with an auto-reply and one without. @@ -314,15 +314,15 @@ class ContactPersonalTestCase extends Dr * Test personal contact form. */ function testPersonalContact() { - $admin_user = $this->drupalCreateUser(array('administer site-wide contact form')); + $admin_user = $this->drupalCreateUser(array('administer site-wide contact form', 'administer users')); $this->drupalLogin($admin_user); // Enable the personal contact form. $flood_control = 3; + variable_set('contact_threshold_limit', $flood_control); $edit = array(); $edit['contact_default_status'] = TRUE; - $edit['contact_hourly_threshold'] = $flood_control; - $this->drupalPost('admin/structure/contact/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); // Reload variables. @@ -357,7 +357,7 @@ class ContactPersonalTestCase extends Dr // Submit contact form one over limit. $this->drupalGet('user/' . $web_user2->uid . '/contact'); - $this->assertRaw(t('You cannot send more than %number messages per hour. Please try again later.', array('%number' => $flood_control)), t('Message threshold reached.')); + $this->assertRaw(t('You cannot send more than %number messages in @interval. Please try again later.', array('%number' => $flood_control, '@interval' => format_interval(variable_get('contact_threshold_window', 3600)))), t('Message threshold reached.')); $this->drupalLogout(); @@ -366,7 +366,7 @@ class ContactPersonalTestCase extends Dr // Disable the personal contact form. $edit = array(); $edit['contact_default_status'] = FALSE; - $this->drupalPost('admin/structure/contact/settings', $edit, t('Save configuration')); + $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), t('Setting successfully saved.')); // Reload variables.