Skip to content
Snippets Groups Projects
Commit 27fc3406 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #60483 by budda, Morbus, webchick et al: hide contact tab for users...

- Patch #60483 by budda, Morbus, webchick et al: hide contact tab for users who have option disabled.
parent 87dca6df
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -101,14 +101,17 @@ function contact_menu($may_cache) { ...@@ -101,14 +101,17 @@ function contact_menu($may_cache) {
} }
else { else {
if (arg(0) == 'user' && is_numeric(arg(1))) { if (arg(0) == 'user' && is_numeric(arg(1))) {
global $user; $account = user_load(array('uid' => arg(1)));
$items[] = array('path' => 'user/'. arg(1) .'/contact', if ($account->contact || user_access('administer users')) {
'title' => t('contact'), global $user;
'callback' => 'contact_mail_user', $items[] = array('path' => 'user/'. arg(1) .'/contact',
'type' => MENU_LOCAL_TASK, 'title' => t('contact'),
'access' => ($user->uid && user_access('access personal contact forms')), 'callback' => 'contact_mail_user',
'weight' => 2, 'type' => MENU_LOCAL_TASK,
); 'access' => ($user->uid && user_access('access personal contact forms')),
'weight' => 2,
);
}
} }
} }
...@@ -317,17 +320,7 @@ function contact_mail_user() { ...@@ -317,17 +320,7 @@ function contact_mail_user() {
global $user; global $user;
if ($account = user_load(array('uid' => arg(1)))) { if ($account = user_load(array('uid' => arg(1)))) {
$admin_access = user_access('administer users'); if (!valid_email_address($user->mail)) {
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)) {
$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"))); $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))) { else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
......
...@@ -101,14 +101,17 @@ function contact_menu($may_cache) { ...@@ -101,14 +101,17 @@ function contact_menu($may_cache) {
} }
else { else {
if (arg(0) == 'user' && is_numeric(arg(1))) { if (arg(0) == 'user' && is_numeric(arg(1))) {
global $user; $account = user_load(array('uid' => arg(1)));
$items[] = array('path' => 'user/'. arg(1) .'/contact', if ($account->contact || user_access('administer users')) {
'title' => t('contact'), global $user;
'callback' => 'contact_mail_user', $items[] = array('path' => 'user/'. arg(1) .'/contact',
'type' => MENU_LOCAL_TASK, 'title' => t('contact'),
'access' => ($user->uid && user_access('access personal contact forms')), 'callback' => 'contact_mail_user',
'weight' => 2, 'type' => MENU_LOCAL_TASK,
); 'access' => ($user->uid && user_access('access personal contact forms')),
'weight' => 2,
);
}
} }
} }
...@@ -317,17 +320,7 @@ function contact_mail_user() { ...@@ -317,17 +320,7 @@ function contact_mail_user() {
global $user; global $user;
if ($account = user_load(array('uid' => arg(1)))) { if ($account = user_load(array('uid' => arg(1)))) {
$admin_access = user_access('administer users'); if (!valid_email_address($user->mail)) {
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)) {
$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"))); $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))) { else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment