You are here

function commerce_addressbook_profile_page_access in Commerce Addressbook 7.3

Same name and namespace in other branches
  1. 7.2 commerce_addressbook.module \commerce_addressbook_profile_page_access()

Access callback: determine if the user can access the listing page of a given profile type.

1 call to commerce_addressbook_profile_page_access()
commerce_addressbook_page_access in ./commerce_addressbook.module
Access callback for path /user/%user/addressbook.
1 string reference to 'commerce_addressbook_profile_page_access'
commerce_addressbook_menu in ./commerce_addressbook.module
Implements hook_menu().

File

./commerce_addressbook.module, line 150
Defines addressbook functionality for customer profiles, allowing them to be reused and managed on a per-user basis.

Code

function commerce_addressbook_profile_page_access($account, $profile_type) {
  global $user;

  // Check if the user can access any page.
  if (user_access('administer commerce_customer_profile entities') || user_access('view any commerce_customer_profile entity') || user_access('view any commerce_customer_profile entity of bundle ' . $profile_type) || user_access('edit any commerce_customer_profile entity') || user_access('edit any commerce_customer_profile entity of bundle ' . $profile_type)) {
    return TRUE;
  }

  // Check if the user can access his own page.
  if ($user->uid == $account->uid) {
    if (user_access('view own commerce_customer_profile entities') || user_access('create commerce_customer_profile entities') || user_access('create commerce_customer_profile entities of bundle ' . $profile_type) || user_access('view own commerce_customer_profile entities of bundle ' . $profile_type) || user_access('edit own commerce_customer_profile entities') || user_access('edit own commerce_customer_profile entities of bundle ' . $profile_type)) {
      return TRUE;
    }
  }
  return FALSE;
}