You are here

function redhen_contact_user_contact_access in RedHen CRM 7

Access callback for redhen_contact_user_categories().

1 call to redhen_contact_user_contact_access()
redhen_contact_form_user_profile_form_alter in modules/redhen_contact/redhen_contact.module
Implements hook_form_FORM_ID_alter().
1 string reference to 'redhen_contact_user_contact_access'
redhen_contact_menu in modules/redhen_contact/redhen_contact.module
Implements hook_menu().

File

modules/redhen_contact/redhen_contact.module, line 1140
Module file for RedHen contacts.

Code

function redhen_contact_user_contact_access($account = NULL) {
  global $user;
  if (!$account) {
    $account = $user;
  }
  $contact = redhen_contact_load_by_user($account);

  // There is no contact linked to this user account.
  if (!$contact) {
    return FALSE;
  }

  // User is editing their own contact information.
  if ($contact->uid == $user->uid && user_access('edit own redhen contact')) {
    return TRUE;
  }

  // Privileged user trying to edit contact information.
  if (redhen_contact_access('edit', $contact, $user)) {
    return TRUE;
  }
  return FALSE;
}