function uc_addresses_check_access_by_ids in Ubercart Addresses 6.2
Same name and namespace in other branches
- 7 uc_addresses.module \uc_addresses_check_access_by_ids()
Checks address access by ID's.
Parameters
string $access_type: The operation to check:
- view
- edit
- delete
int $uid: ID of the address owner.
int $aid: (optional) ID of the address.
object $account: (optional) The account to check access for. Defaults to current user.
Return value
boolean TRUE if access is granted. FALSE otherwise.
2 calls to uc_addresses_check_access_by_ids()
- uc_addresses_views2_check_access in ./
uc_addresses.module - Access callback for views access plugin 'uc_addresses_views_access'.
- uc_addresses_views_access::access in views/
uc_addresses_views_access.inc - Implements views_plugin_access#access().
1 string reference to 'uc_addresses_check_access_by_ids'
- uc_addresses_views_access::get_access_callback in views/
uc_addresses_views_access.inc - Implements views_plugin_access#get_access_callback().
File
- ./
uc_addresses.module, line 433 - Adds user profile address support to Ubercart.
Code
function uc_addresses_check_access_by_ids($access_type, $uid, $aid = NULL, $account = NULL) {
// Get objects.
if (empty($uid) && empty($aid)) {
// Nothing to check permissions for. No access.
return FALSE;
}
if (!empty($aid)) {
if (!empty($uid)) {
$address = UcAddressesAddressBook::get($uid)
->getAddressById($aid);
}
else {
$address = UcAddressesAddressBook::loadAddress($aid);
$uid = $address
->getUserId();
}
}
if (empty($address)) {
$address = NULL;
}
$address_user = user_load($uid);
switch ($access_type) {
case 'view':
return UcAddressesPermissions::canViewAddress($address_user, $address, $account);
case 'edit':
return UcAddressesPermissions::canEditAddress($address_user, $address, $account);
case 'delete':
return UcAddressesPermissions::canDeleteAddress($address_user, $address, $account);
}
return FALSE;
}