You are here

uc_addresses_handler_field_uc_addresses_link_edit.inc in Ubercart Addresses 6.2

Same filename and directory in other branches
  1. 7 views/uc_addresses_handler_field_uc_addresses_link_edit.inc

Definition of uc_addresses_handler_field_uc_addresses_link_edit.

File

views/uc_addresses_handler_field_uc_addresses_link_edit.inc
View source
<?php

/**
 * @file
 * Definition of uc_addresses_handler_field_uc_addresses_link_edit.
 */

/**
 * Field handler to present a link edit an address.
 *
 * @ingroup views_field_handlers
 */
class uc_addresses_handler_field_uc_addresses_link_edit extends uc_addresses_handler_field_uc_addresses_link {

  /**
   * Renders the link if the user may edit the address.
   *
   * @param UcAddressesAddress $address
   *   An address object.
   *
   * @return string
   *   The rendered link, if the current user has access.
   */
  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;
    }
  }

}

Classes

Namesort descending Description
uc_addresses_handler_field_uc_addresses_link_edit Field handler to present a link edit an address.