You are here

function commerce_file_handler_field_license::render_link in Commerce File 7

Render whatever the data is as a link to the license.

Data should be made XSS safe prior to calling this function.

2 calls to commerce_file_handler_field_license::render_link()
commerce_file_handler_field_license::render in views/handlers/commerce_file_handler_field_license.inc
Render the field.
commerce_file_handler_field_license_status::render in views/handlers/commerce_file_handler_field_license_status.inc
Render the field.

File

views/handlers/commerce_file_handler_field_license.inc, line 60
Contains the basic license field handler.

Class

commerce_file_handler_field_license
Field handler to provide simple renderer that allows linking to an entity.

Code

function render_link($data, $values) {
  if (!empty($this->options['link_to_entity']) && $this
    ->_valid_link_to_entity_option($this->options['link_to_entity']) && $data !== NULL && $data !== '') {
    $uid = $this
      ->get_value($values, 'uid');
    $entity_id = $this
      ->get_value($values, 'license_id');
    if (!empty($uid) && !empty($entity_id)) {
      $entity = commerce_file_license_load($entity_id);
      if ($entity
        ->access('view')) {
        if ($this->options['link_to_entity'] == 'user' && !empty($uid)) {
          $this->options['alter']['make_link'] = TRUE;
          $this->options['alter']['path'] = 'user/' . $uid . '/licensed-files/' . $entity_id;
        }
        elseif ($this->options['link_to_entity'] == 'admin' && ($uri = $entity
          ->uri())) {
          $this->options['alter']['make_link'] = TRUE;
          $this->options['alter']['path'] = url($uri['path'], array(
            'query' => drupal_get_destination(),
          ) + $uri);
          $this->options['alter']['path'] = $uri['path'] . '?' . drupal_http_build_query(drupal_get_destination());
        }
      }
    }
  }
  return $data;
}