You are here

public function uc_addresses_views_plugin_argument_user_address_access::validate_argument in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 views/uc_addresses_views_plugin_argument_user_address_access.inc \uc_addresses_views_plugin_argument_user_address_access::validate_argument()

Validates if argument is a valid user and if the current user has access to addresses of the given user.

Overrides views_plugin_argument_validate_user::validate_argument

File

views/uc_addresses_views_plugin_argument_user_address_access.inc, line 55
Definition of uatest_views_plugin_argument_address_access.

Class

uc_addresses_views_plugin_argument_user_address_access
Checks if the current user has access to addresses of the given user.

Code

public function validate_argument($argument) {

  // Let the parent validate the argument first.
  if (!parent::validate_argument($argument)) {

    // If the parent says the argument is invalid, then
    // there is no need to check further for address access.
    return FALSE;
  }

  // Check for address access.
  $address_user = user_load($this->argument->argument);
  switch ($this->options['access_type']) {
    case 'view':
      return UcAddressesPermissions::canViewAddress($address_user);
    case 'edit':
      return UcAddressesPermissions::canEditAddress($address_user);
    case 'delete':
      return UcAddressesPermissions::canDeleteAddress($address_user);
  }
  return FALSE;
}