You are here

function commerce_cardonfile_user_access in Commerce Card on File 7

Same name and namespace in other branches
  1. 7.2 commerce_cardonfile.module \commerce_cardonfile_user_access()

Determines if the current user has access to the specified account's "Stored payment methods" tab.

1 string reference to 'commerce_cardonfile_user_access'
commerce_cardonfile_menu in ./commerce_cardonfile.module
Implements hook_menu().

File

./commerce_cardonfile.module, line 77
Supports card on file functionality for credit card payment methods by associating card data reference IDs from payment gateways with user accounts.

Code

function commerce_cardonfile_user_access($account) {
  global $user;

  // Only show the tab if a user actually has card data on file.
  $stored_cards = commerce_cardonfile_data_load_multiple($account->uid);
  if (empty($stored_cards)) {
    return FALSE;
  }

  // Grant access for any user with administer permission.
  if (user_access('administer card data')) {
    return TRUE;
  }

  // Grant access for users with permission to manage their own card data.
  if ($user->uid && user_access('manage own card data') && $user->uid == $account->uid) {
    return TRUE;
  }
  return FALSE;
}