summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-05-29 13:26:41 +0000
committerDries Buytaert <dries@buytaert.net>2006-05-29 13:26:41 +0000
commit27fc34069ff316bc4cb124adfcca415dc4671d16 (patch)
treeb75c80c40c02a8f7fadae76371a0b056e9f71f9e /modules
parent87dca6df9ab6da06134d7bb535e530512325cdae (diff)
downloadbrdo-27fc34069ff316bc4cb124adfcca415dc4671d16.tar.gz
brdo-27fc34069ff316bc4cb124adfcca415dc4671d16.tar.bz2
- Patch #60483 by budda, Morbus, webchick et al: hide contact tab for users who have option disabled.
Diffstat (limited to 'modules')
-rw-r--r--modules/contact.module31
-rw-r--r--modules/contact/contact.module31
2 files changed, 24 insertions, 38 deletions
diff --git a/modules/contact.module b/modules/contact.module
index 051235b14..0615dd20b 100644
--- a/modules/contact.module
+++ b/modules/contact.module
@@ -101,14 +101,17 @@ function contact_menu($may_cache) {
}
else {
if (arg(0) == 'user' && is_numeric(arg(1))) {
- global $user;
- $items[] = array('path' => 'user/'. arg(1) .'/contact',
- 'title' => t('contact'),
- 'callback' => 'contact_mail_user',
- 'type' => MENU_LOCAL_TASK,
- 'access' => ($user->uid && user_access('access personal contact forms')),
- 'weight' => 2,
- );
+ $account = user_load(array('uid' => arg(1)));
+ if ($account->contact || user_access('administer users')) {
+ global $user;
+ $items[] = array('path' => 'user/'. arg(1) .'/contact',
+ 'title' => t('contact'),
+ 'callback' => 'contact_mail_user',
+ 'type' => MENU_LOCAL_TASK,
+ 'access' => ($user->uid && user_access('access personal contact forms')),
+ 'weight' => 2,
+ );
+ }
}
}
@@ -317,17 +320,7 @@ function contact_mail_user() {
global $user;
if ($account = user_load(array('uid' => arg(1)))) {
- $admin_access = user_access('administer users');
- if (!$account->status && !$admin_access) {
- drupal_access_denied();
- }
- else if (!$account->contact && !$admin_access) {
- $output = t('%name is not accepting e-mails.', array('%name' => $account->name));
- }
- else if (!$user->uid) {
- $output = t('Please <a href="%login">login</a> or <a href="%register">register</a> to send %name a message.', array('%login' => url('user/login'), '%register' => url('user/register'), '%name' => $account->name));
- }
- else if (!valid_email_address($user->mail)) {
+ 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")));
}
else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
diff --git a/modules/contact/contact.module b/modules/contact/contact.module
index 051235b14..0615dd20b 100644
--- a/modules/contact/contact.module
+++ b/modules/contact/contact.module
@@ -101,14 +101,17 @@ function contact_menu($may_cache) {
}
else {
if (arg(0) == 'user' && is_numeric(arg(1))) {
- global $user;
- $items[] = array('path' => 'user/'. arg(1) .'/contact',
- 'title' => t('contact'),
- 'callback' => 'contact_mail_user',
- 'type' => MENU_LOCAL_TASK,
- 'access' => ($user->uid && user_access('access personal contact forms')),
- 'weight' => 2,
- );
+ $account = user_load(array('uid' => arg(1)));
+ if ($account->contact || user_access('administer users')) {
+ global $user;
+ $items[] = array('path' => 'user/'. arg(1) .'/contact',
+ 'title' => t('contact'),
+ 'callback' => 'contact_mail_user',
+ 'type' => MENU_LOCAL_TASK,
+ 'access' => ($user->uid && user_access('access personal contact forms')),
+ 'weight' => 2,
+ );
+ }
}
}
@@ -317,17 +320,7 @@ function contact_mail_user() {
global $user;
if ($account = user_load(array('uid' => arg(1)))) {
- $admin_access = user_access('administer users');
- if (!$account->status && !$admin_access) {
- drupal_access_denied();
- }
- else if (!$account->contact && !$admin_access) {
- $output = t('%name is not accepting e-mails.', array('%name' => $account->name));
- }
- else if (!$user->uid) {
- $output = t('Please <a href="%login">login</a> or <a href="%register">register</a> to send %name a message.', array('%login' => url('user/login'), '%register' => url('user/register'), '%name' => $account->name));
- }
- else if (!valid_email_address($user->mail)) {
+ 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")));
}
else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {