You are here

function commerce_wishlist_access in Commerce Wishlist 7

Determine whether the user has a given privilege to wishlist.

1 string reference to 'commerce_wishlist_access'
commerce_wishlist_menu in ./commerce_wishlist.module
Implements hook_menu().

File

./commerce_wishlist.module, line 85
Provides the wishlist for use in Drupal Commerce.

Code

function commerce_wishlist_access($user, $wishlist_id = '') {
  if (user_access('administer wishlists')) {
    return TRUE;
  }
  if (isset($wishlist_id)) {
    $result = db_select('commerce_wishlist', 'cw')
      ->addTag('wishlist')
      ->fields('cw', array(
      'uid',
    ))
      ->condition('wishlist_id', $wishlist_id)
      ->execute()
      ->fetchAssoc();
  }
  if ($result['uid'] == $user->uid && user_access('view own wishlist')) {
    return TRUE;
  }
  return FALSE;
}