You are here

function uc_addresses_handler_field_uc_addresses_link_edit::uc_addresses_render_link in Ubercart Addresses 6.2

Renders the link if the user may edit the address.

Parameters

UcAddressesAddress $address: An address object.

Return value

string The rendered link, if the current user has access.

Overrides uc_addresses_handler_field_uc_addresses_link::uc_addresses_render_link

File

views/uc_addresses_handler_field_uc_addresses_link_edit.inc, line 23
Definition of uc_addresses_handler_field_uc_addresses_link_edit.

Class

uc_addresses_handler_field_uc_addresses_link_edit
Field handler to present a link edit an address.

Code

function uc_addresses_render_link(UcAddressesAddress $address) {
  $address_user = user_load($address
    ->getUserId());
  if (UcAddressesPermissions::canEditAddress($address_user, $address)) {
    $uri = $address
      ->uri();
    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['path'] = $uri['path'] . '/edit';
    $this->options['alter']['query'] = drupal_get_destination();
    $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
    return $text;
  }
}