2
// $Id: views_handler_field_user.inc,v 1.3 2009/01/30 00:01:42 merlinofchaos Exp $
5
* Field handler to provide simple renderer that allows linking to a user.
7
class views_handler_field_user extends views_handler_field {
9
* Override init function to provide generic option to link to user.
11
function init(&$view, &$data) {
12
parent::init($view, $data);
13
if (!empty($this->options['link_to_user'])) {
14
$this->additional_fields['uid'] = 'uid';
18
function option_definition() {
19
$options = parent::option_definition();
20
$options['link_to_user'] = array('default' => TRUE);
25
* Provide link to node option
27
function options_form(&$form, &$form_state) {
28
parent::options_form($form, $form_state);
29
$form['link_to_user'] = array(
30
'#title' => t('Link this field to its user'),
31
'#description' => t('This will override any other link you have set.'),
32
'#type' => 'checkbox',
33
'#default_value' => $this->options['link_to_user'],
37
function render_link($data, $values) {
38
if (!empty($this->options['link_to_user']) && user_access('access user profiles') && $values->{$this->aliases['uid']} && $data !== NULL && $data !== '') {
39
$this->options['alter']['make_link'] = TRUE;
40
$this->options['alter']['path'] = "user/" . $values->{$this->aliases['uid']};
45
function render($values) {
46
return $this->render_link(check_plain($values->{$this->field_alias}), $values);