crm_core_contact_handler_field_contact_revision.inc in CRM Core 7
File
modules/crm_core_contact/includes/views/handlers/crm_core_contact_handler_field_contact_revision.inc
View source
<?php
class crm_core_contact_handler_field_contact_revision extends views_handler_field {
function init(&$view, &$options) {
parent::init($view, $options);
if (!empty($this->options['link_to_revision'])) {
$this->additional_fields['contact_id'] = 'contact_id';
$this->additional_fields['vid'] = 'vid';
}
}
function option_definition() {
$options = parent::option_definition();
$options['link_to_revision'] = array(
'default' => FALSE,
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['link_to_revision'] = array(
'#title' => t('Link this field to the revert the contact to previous version.'),
'#description' => t('This will override any other link you have set.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_revision']),
);
}
function render_link($data, $values) {
if (!empty($this->options['link_to_revision']) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'crm-core/contact/' . $values->{$this->aliases['contact_id']} . '/revert/' . $values->{$this->aliases['vid']};
}
return $data;
}
function render($values) {
return $this
->render_link(check_plain($values->{$this->field_alias}), $values);
}
}