You are here

function _contact_personal_tab_access in Contact 6.2

Same name and namespace in other branches
  1. 7.2 contact.module \_contact_personal_tab_access()

Menu access callback for a user's personal contact form.

Parameters

$account: A user account object.

Return value

TRUE if the current user has access to the requested user's contact form, or FALSE otherwise.

1 call to _contact_personal_tab_access()
_contact_user_tab_access in ./contact.module
Contact 6.x-1.x legacy access mapping.
1 string reference to '_contact_personal_tab_access'
contact_menu in ./contact.module
Implements hook_menu().

File

./contact.module, line 118
Enables the use of personal and site-wide contact forms.

Code

function _contact_personal_tab_access(stdClass $account) {
  global $user;

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

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

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

  // If the requested user has disabled their contact form, or this preference
  // has not yet been saved, do not allow users to contact them.
  if (empty($account->contact)) {
    return FALSE;
  }
  return user_access('access user contact forms');
}