public static function UcAddressesPermissions::canDeleteAddress in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 class/UcAddressesPermissions.class.php \UcAddressesPermissions::canDeleteAddress()
Check if the user can delete addresses of this user. Default addresses can never be deleted.
@access public @static
Parameters
object $address_user: The owner of the address.
UcAddressesAddress: (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 delete the address. FALSE otherwise.
8 calls to UcAddressesPermissions::canDeleteAddress()
- 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_get_address_form in ./
uc_addresses.pages.inc - Creates a form used to add a new address or edit an existing address.
- uc_addresses_handler_filter_access::check_access in views/
uc_addresses_handler_filter_access.inc - Checks address access for the current user.
File
- class/
UcAddressesPermissions.class.php, line 213 - Permission class.
Class
- UcAddressesPermissions
- The permission class: UcAddressesPermissions.
Code
public static function canDeleteAddress($address_user, UcAddressesAddress $address = NULL, $account = NULL) {
$account = self::getAccount($account);
if ($address instanceof UcAddressesAddress) {
// Check if the address is a default address. If so, the address may not be deleted.
if ($address
->isDefault('shipping') || $address
->isDefault('billing')) {
return FALSE;
}
}
if ($address_user->uid == $account->uid && self::canDeleteOwn($account)) {
// Ask other modules if the address may be deleted.
return self::invoke('uc_addresses_may_delete', $address_user, $address, $account);
}
if ($address_user->uid != $account->uid && self::canDeleteAll($account)) {
// Ask other modules if the address may be deleted.
return self::invoke('uc_addresses_may_delete', $address_user, $address, $account);
}
// No other cases are permitted.
return FALSE;
}