function views_handler_field_privatemsg_link::render in Privatemsg 6
Same name and namespace in other branches
- 6.2 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()
- 7 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.
File
- views/
views_handler_field_privatemsg_link.inc, line 106 - 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->uid)) {
$uid = $values->uid;
}
elseif (isset($values->users_uid)) {
$uid = $values->users_uid;
}
else {
return '';
}
$text = t('Write private 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']) {
$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;
}