function _contact_personal_tab_access

Access callback: Checks access for a user's personal contact form.

Parameters

$account: The user object of the user whose contact form is being requested.

See also

contact_menu()

1 string reference to '_contact_personal_tab_access'
contact_menu in drupal/core/modules/contact/contact.module
Implements hook_menu().

File

drupal/core/modules/contact/contact.module, line 125
Enables the use of personal and site-wide contact forms.

Code

function _contact_personal_tab_access($account) {
  global $user;

  // Anonymous users cannot have contact forms.
  if (!$account->uid) {
    return FALSE;
  }

  // Users may not contact themselves.
  if ($user->uid == $account->uid) {
    return FALSE;
  }

  // User administrators should always have access to personal contact forms.
  if (user_access('administer users')) {
    return TRUE;
  }

  // If requested user has been blocked, do not allow users to contact them.
  if (empty($account->status)) {
    return FALSE;
  }

  // If the requested user has disabled their contact form, do not allow users
  // to contact them.
  $account_data = Drupal::service('user.data')
    ->get('contact', $account
    ->id(), 'enabled');
  if (isset($account_data) && empty($account_data)) {
    return FALSE;
  }
  elseif (!config('contact.settings')
    ->get('user_default_enabled')) {
    return FALSE;
  }
  return user_access('access user contact forms');
}