function views_handler_field_privatemsg_link::render in Privatemsg 7
Same name and namespace in other branches
- 6.2 views/views_handler_field_privatemsg_link.inc \views_handler_field_privatemsg_link::render()
- 6 views/views_handler_field_privatemsg_link.inc \views_handler_field_privatemsg_link::render()
- 7.2 views/views_handler_field_privatemsg_link.inc \views_handler_field_privatemsg_link::render()
Renders our field, displays a link if the user is allowed to.
Overrides views_handler_field::render
File
- views/
views_handler_field_privatemsg_link.inc, line 128 - Contains the privatemsg link views field handler.
Class
- views_handler_field_privatemsg_link
- Provides a configurable link to the new message form for a specific user.
Code
function render($values) {
if (isset($values->{$this->aliases['uid']})) {
$uid = $values->{$this->aliases['uid']};
}
else {
return '';
}
$text = t('Send message');
if (!empty($this->options['text'])) {
$tokens = $this
->get_render_tokens($this);
$text = strip_tags(strtr($this->options['text'], $tokens));
}
$subject = NULL;
if (!empty($this->options['subject'])) {
$tokens = $this
->get_render_tokens($this);
$subject = strip_tags(strtr($this->options['subject'], $tokens));
}
$options = array();
if ($this->options['return']) {
if (!empty($this->options['custom_destination'])) {
$tokens = $this
->get_render_tokens($this);
$destination = strip_tags(strtr($this->options['custom_destination'], $tokens));
$options['query'] = array(
'destination' => $destination,
);
}
else {
$options['query'] = drupal_get_destination();
}
}
$data = '';
if (($recipient = user_load($uid)) && ($url = privatemsg_get_link(array(
$recipient,
), NULL, $subject))) {
$data = l($text, $url, $options);
}
return $data;
}