public function uc_addresses_handler_filter_access::post_execute in Ubercart Addresses 7
Same name and namespace in other branches
- 6.2 views/uc_addresses_handler_filter_access.inc \uc_addresses_handler_filter_access::post_execute()
Removes the rows the user should have no access to.
@todo This doesn't work with pager.
Parameters
array $values: The loaded values.
Overrides views_handler::post_execute
File
- views/
uc_addresses_handler_filter_access.inc, line 90 - Contains uc_addresses_handler_filter_access class.
Class
- uc_addresses_handler_filter_access
- A handler to filter a view by checking address access.
Code
public function post_execute(&$values) {
$aid_field_alias = $this->aid_field_alias;
$uid_field_alias = $this->uid_field_alias;
foreach ($values as $index => $row) {
if (!isset($row->{$aid_field_alias})) {
// The address ID field is not found in the row.
// As a result, we can not check address access.
continue;
}
$aid = $row->{$aid_field_alias};
$uid = NULL;
if (isset($row->{$uid_field_alias})) {
$uid = $row->{$uid_field_alias};
}
if (!$aid) {
// The address ID can be missing, for example when used
// in Views where a relationship with uc_addresses is
// optional. In this case, just skip the row.
continue;
}
$address = $this
->loadAddress($aid, $uid);
// Reassign user ID, just in case it was empty in the results.
$uid = $address
->getUserId();
$address_user = user_load($uid);
// Check for access.
if ($this->value && !$this
->check_access($address_user, $address) || !$this->value && $this
->check_access($address_user, $address)) {
// No access. Remove the row from the results and decrease the calculated
// number of rows.
unset($values[$index]);
if (isset($this->view->total_rows)) {
$this->view->total_rows--;
}
}
}
}