You are here

function crm_core_contact_handler_field_contact_revert::render_link in CRM Core 7

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

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

1 call to crm_core_contact_handler_field_contact_revert::render_link()
crm_core_contact_handler_field_contact_revert::render in modules/crm_core_contact/includes/views/handlers/crm_core_contact_handler_field_contact_revert.inc
Render the field.

File

modules/crm_core_contact/includes/views/handlers/crm_core_contact_handler_field_contact_revert.inc, line 44

Class

crm_core_contact_handler_field_contact_revert
Field handler to provide simple renderer that allows linking to a contact.

Code

function render_link($data, $values) {

  // do a db check to get the highest version for this contact
  $max_vid = db_query("SELECT max(vid) FROM {crm_core_contact_revision} WHERE contact_id = :contact_id", array(
    ':contact_id' => $values->{$this->aliases['contact_id']},
  ))
    ->fetchField();
  if ($values->{$this->aliases['vid']} == $max_vid) {
    return t('current');
  }
  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['path'] = 'crm-core/contact/' . $values->{$this->aliases['contact_id']} . '/revert/' . $values->{$this->aliases['vid']};
  $text = !empty($this->options['text']) ? $this->options['text'] : t('revert');
  return $text;
}