function views_handler_field_contact_link::render_link in Views (for Drupal 7) 6.3
Same name and namespace in other branches
- 7.3 modules/contact/views_handler_field_contact_link.inc \views_handler_field_contact_link::render_link()
Overrides views_handler_field_user_link::render_link
File
- modules/
contact/ views_handler_field_contact_link.inc, line 45
Class
- views_handler_field_contact_link
- A field that links to the user contact page, if access is permitted.
Code
function render_link($data, $values) {
global $user;
$uid = $this
->get_value($values, 'uid');
if (empty($uid)) {
return;
}
$account = user_load($uid);
if (empty($account)) {
return;
}
// Check access when we pull up the user account so we know
// if the user has made the contact page available.
$menu_item = menu_get_item("user/{$uid}/contact");
if (!$menu_item['access'] || empty($account->contact)) {
return;
}
$this->options['alter']['path'] = 'user/' . $account->uid . '/contact';
$this->options['alter']['attributes'] = array(
'title' => t('Contact %user', array(
'%user' => $account->name,
)),
);
if ($this->options['link_display'] == 'icon') {
$text = theme('image', 'misc/forum-new.png');
$this->options['alter']['html'] = TRUE;
}
else {
$text = $this->options['text'];
}
return $text;
}