You are here

function commerce_gc_views_plugin_argument_validate_user_giftcards::validate_argument in Commerce GC 7

Overrides views_plugin_argument_validate::validate_argument

File

includes/views/plugins/commerce_gc_views_plugin_argument_validate_user_giftcards.inc, line 8

Class

commerce_gc_views_plugin_argument_validate_user_giftcards
Validate that an argument user can access a view that displays giftcards that reference a user as a recipient.

Code

function validate_argument($arg) {
  global $user;

  // If the person is viewing their own page, make sure they are allowed to
  // view own giftcards.
  if ($user->uid == $arg) {
    return user_access('view received coupons of type giftcard_coupon');
  }

  // Otherwise, the user must be able to view all giftcards.
  return user_access('view any commerce_coupon entity of bundle giftcard_coupon') || user_access('view any commerce_coupon entity') || user_access('administer commerce_coupon entities');
}