1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of views_handler_field_user_link.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Field handler to present a link to the user.
|
10 |
|
|
*
|
11 |
|
|
* @ingroup views_field_handlers
|
12 |
|
|
*/
|
13 |
|
|
class views_handler_field_user_link extends views_handler_field {
|
14 |
5d12d676
|
Assos Assos
|
|
15 |
|
|
/**
|
16 |
|
|
* {@inheritdoc}
|
17 |
|
|
*/
|
18 |
|
|
public function construct() {
|
19 |
85ad3d82
|
Assos Assos
|
parent::construct();
|
20 |
|
|
$this->additional_fields['uid'] = 'uid';
|
21 |
|
|
}
|
22 |
|
|
|
23 |
5d12d676
|
Assos Assos
|
/**
|
24 |
|
|
* {@inheritdoc}
|
25 |
|
|
*/
|
26 |
|
|
public function option_definition() {
|
27 |
85ad3d82
|
Assos Assos
|
$options = parent::option_definition();
|
28 |
|
|
$options['text'] = array('default' => '', 'translatable' => TRUE);
|
29 |
|
|
return $options;
|
30 |
|
|
}
|
31 |
|
|
|
32 |
5d12d676
|
Assos Assos
|
/**
|
33 |
|
|
* {@inheritdoc}
|
34 |
|
|
*/
|
35 |
|
|
public function options_form(&$form, &$form_state) {
|
36 |
85ad3d82
|
Assos Assos
|
$form['text'] = array(
|
37 |
|
|
'#type' => 'textfield',
|
38 |
|
|
'#title' => t('Text to display'),
|
39 |
|
|
'#default_value' => $this->options['text'],
|
40 |
|
|
);
|
41 |
|
|
parent::options_form($form, $form_state);
|
42 |
|
|
}
|
43 |
|
|
|
44 |
5d12d676
|
Assos Assos
|
/**
|
45 |
|
|
* An example of field level access control.
|
46 |
|
|
*/
|
47 |
|
|
public function access() {
|
48 |
85ad3d82
|
Assos Assos
|
return user_access('access user profiles');
|
49 |
|
|
}
|
50 |
|
|
|
51 |
5d12d676
|
Assos Assos
|
/**
|
52 |
|
|
* {@inheritdoc}
|
53 |
|
|
*/
|
54 |
|
|
public function query() {
|
55 |
85ad3d82
|
Assos Assos
|
$this->ensure_my_table();
|
56 |
|
|
$this->add_additional_fields();
|
57 |
|
|
}
|
58 |
|
|
|
59 |
5d12d676
|
Assos Assos
|
/**
|
60 |
|
|
* {@inheritdoc}
|
61 |
|
|
*/
|
62 |
|
|
public function render($values) {
|
63 |
85ad3d82
|
Assos Assos
|
$value = $this->get_value($values, 'uid');
|
64 |
|
|
return $this->render_link($this->sanitize_value($value), $values);
|
65 |
|
|
}
|
66 |
|
|
|
67 |
5d12d676
|
Assos Assos
|
/**
|
68 |
|
|
* {@inheritdoc}
|
69 |
|
|
*/
|
70 |
|
|
public function render_link($data, $values) {
|
71 |
85ad3d82
|
Assos Assos
|
$text = !empty($this->options['text']) ? $this->options['text'] : t('view');
|
72 |
|
|
|
73 |
|
|
$this->options['alter']['make_link'] = TRUE;
|
74 |
|
|
$this->options['alter']['path'] = "user/" . $data;
|
75 |
|
|
|
76 |
|
|
return $text;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
} |