Commit 48dd14a8 authored by Dries's avatar Dries

- Patch #597784 by Dave Reid: rename 'administer site-wide contact form' to...

- Patch #597784 by Dave Reid: rename 'administer site-wide contact form' to 'administer contact forms'.
parent dcdb584f
......@@ -87,6 +87,16 @@ function contact_update_7000() {
variable_del('contact_hourly_threshold');
}
/**
* Rename the administer contact forms permission.
*/
function contact_update_7001() {
db_update('role_permission')
->fields(array('permission' => 'administer contact forms'))
->condition('permission', 'administer site-wide contact form')
->execute();
}
/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
......
......@@ -37,13 +37,13 @@ function contact_help($path, $arg) {
*/
function contact_permission() {
return array(
'administer site-wide contact form' => array(
'title' => t('Administer site-wide contact form'),
'description' => t('Configure site-wide contact form administration settings.'),
'administer contact forms' => array(
'title' => t('Administer contact forms'),
'description' => t('Manage contact forms and configure contact form adminstrative settings.'),
),
'access site-wide contact form' => array(
'title' => t('Access site-wide contact form'),
'description' => t('Send feedback to administrators via e-mail using the site-wide contact form.'),
'description' => t('Send e-mails to administer-defiend recipients using the site-wide contact form.'),
),
);
}
......@@ -56,14 +56,14 @@ function contact_menu() {
'title' => 'Contact form',
'description' => 'Create a system contact form and set up categories for the form to use.',
'page callback' => 'contact_admin_categories',
'access arguments' => array('administer site-wide contact form'),
'access arguments' => array('administer contact forms'),
'file' => 'contact.admin.inc',
);
$items['admin/structure/contact/add'] = array(
'title' => 'Add category',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_admin_edit', 3),
'access arguments' => array('administer site-wide contact form'),
'access arguments' => array('administer contact forms'),
'type' => MENU_LOCAL_ACTION,
'weight' => 1,
'file' => 'contact.admin.inc',
......@@ -72,7 +72,7 @@ function contact_menu() {
'title' => 'Edit contact category',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_admin_edit', 3, 4),
'access arguments' => array('administer site-wide contact form'),
'access arguments' => array('administer contact forms'),
'type' => MENU_CALLBACK,
'file' => 'contact.admin.inc',
);
......@@ -80,7 +80,7 @@ function contact_menu() {
'title' => 'Delete contact',
'page callback' => 'drupal_get_form',
'page arguments' => array('contact_admin_delete', 4),
'access arguments' => array('administer site-wide contact form'),
'access arguments' => array('administer contact forms'),
'type' => MENU_CALLBACK,
'file' => 'contact.admin.inc',
);
......
......@@ -11,11 +11,11 @@
* Site-wide contact page.
*/
function contact_site_page() {
if (!flood_is_allowed('contact', variable_get('contact_threshold_limit', 5), variable_get('contact_threshold_window', 3600)) && !user_access('administer site-wide contact form')) {
if (!flood_is_allowed('contact', variable_get('contact_threshold_limit', 5), variable_get('contact_threshold_window', 3600)) && !user_access('administer contact forms')) {
$output = 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))));
}
elseif (!db_query("SELECT COUNT(cid) FROM {contact}")->fetchField()) {
if (user_access('administer site-wide contact form')) {
if (user_access('administer contact forms')) {
$output = t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.', array('@add' => url('admin/structure/contact/add')));
}
else {
......@@ -157,7 +157,7 @@ function contact_personal_page($account) {
if (!valid_email_address($user->mail)) {
$output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit", array('query' => drupal_get_destination()))));
}
elseif (!flood_is_allowed('contact', variable_get('contact_threshold_limit', 5), variable_get('contact_threshold_window', 3600)) && !user_access('administer site-wide contact form')) {
elseif (!flood_is_allowed('contact', variable_get('contact_threshold_limit', 5), variable_get('contact_threshold_window', 3600)) && !user_access('administer contact forms')) {
$output = 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))));
}
else {
......
......@@ -22,9 +22,9 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
*/
function testSiteWideContact() {
// Create and login administrative user.
$admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer site-wide contact form', 'administer users'));
$admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer users'));
$this->drupalLogin($admin_user);
$flood_limit = 3;
variable_set('contact_threshold_limit', $flood_limit);
variable_set('contact_threshold_window', 600);
......@@ -156,7 +156,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
*/
function testAutoReply() {
// Create and login administrative user.
$admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer site-wide contact form', 'administer permissions', 'administer users'));
$admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users'));
$this->drupalLogin($admin_user);
// Set up three categories, 2 with an auto-reply and one without.
......@@ -290,9 +290,9 @@ class ContactPersonalTestCase extends DrupalWebTestCase {
* Test personal contact form.
*/
function testPersonalContact() {
$admin_user = $this->drupalCreateUser(array('administer site-wide contact form', 'administer users'));
$admin_user = $this->drupalCreateUser(array('administer contact forms', 'administer users'));
$this->drupalLogin($admin_user);
$flood_limit = 3;
variable_set('contact_threshold_limit', $flood_limit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment