1 views_handler_field_contact_link.inc | views_handler_field_contact_link::render_link($data, $values) |
Overrides views_handler_field_user_link::render_link
File
- core/
modules/ contact/ views/ views_handler_field_contact_link.inc, line 28 - Definition of views_handler_field_contact_link.
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->data['contact'])) {
return;
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'user/' . $account->uid . '/contact';
$this->options['alter']['attributes'] = array('title' => t('Contact %user', array('%user' => $account->name)));
$text = $this->options['text'];
return $text;
}