public static function UcAddressesPermissions::canViewAddress in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 class/UcAddressesPermissions.class.php \UcAddressesPermissions::canViewAddress()
Check if user may view this address.
@access public @static
Parameters
object $address_user: The owner of the address.
UcAddressesAddress|NULL $address: (optional) The address object.
object $account: (optional) The account to check access for. Defaults to the current active user.
Return value
boolean TRUE if the given user has permission to view the address. FALSE otherwise.
9 calls to UcAddressesPermissions::canViewAddress()
- UcAddressesEntityController::buildContent in class/
uc_addresses.entity.inc - Overrides EntityAPIController::buildContent().
- uc_addresses_check_access_by_ids in ./
uc_addresses.module - Checks address access by ID's.
- uc_addresses_entity_access in ./
uc_addresses.module - Access callback for address entity.
- uc_addresses_handler_filter_access::check_access in views/
uc_addresses_handler_filter_access.inc - Checks address access for the current user.
- uc_addresses_list_one_address in ./
uc_addresses.pages.inc - Displays a single address.
File
- class/
UcAddressesPermissions.class.php, line 97 - Permission class.
Class
- UcAddressesPermissions
- The permission class: UcAddressesPermissions.
Code
public static function canViewAddress($address_user, UcAddressesAddress $address = NULL, $account = NULL) {
$account = self::getAccount($account);
if ($address_user->uid == $account->uid) {
// User is the owner of the address.
// If trying to view own address.
if (self::canViewOwn($account)) {
// Ask other modules if the address may be viewed.
return self::invoke('uc_addresses_may_view', $address_user, $address, $account);
}
// If viewing all addresses, we permit the operation if the user
// can view the default address. The non-default addresses will
// need to be filtered out elsewhere.
if ($address == NULL) {
if (self::canViewOwnDefault($account)) {
// Ask other modules if the address may be viewed.
return self::invoke('uc_addresses_may_view', $address_user, $address, $account);
}
return FALSE;
}
// Check if the address is a default address and if the user
// may view own default addresses.
if ($address
->isDefault('shipping') || $address
->isDefault('billing')) {
if (self::canViewOwnDefault($account)) {
// Ask other modules if the address may be viewed.
return self::invoke('uc_addresses_may_view', $address_user, $address, $account);
}
}
}
else {
// User is NOT the owner of the address.
// If trying to view someone else's address.
if (self::canViewAll($account)) {
// Ask other modules if the address may be viewed.
return self::invoke('uc_addresses_may_view', $address_user, $address, $account);
}
// If viewing all addresses, we permit the operation if the user
// can view the default address. The non-default addresses will
// need to be filtered out elsewhere.
if ($address == NULL) {
if (self::canViewAllDefaults($account)) {
// Ask other modules if the address may be viewed.
return self::invoke('uc_addresses_may_view', $address_user, $address, $account);
}
return FALSE;
}
// Check if the address is a default address and if the user
// may view default addresses of all users.
if ($address
->isDefault('shipping') || $address
->isDefault('billing')) {
if (self::canViewAllDefaults($account)) {
// Ask other modules if the address may be viewed.
return self::invoke('uc_addresses_may_view', $address_user, $address, $account);
}
}
}
// No other cases are permitted.
return FALSE;
}