Commit e1d25621 authored by merlinofchaos's avatar merlinofchaos

#523222 by gpk: Contact link should not be allowed for the anonymous user.

parent fa149f72
......@@ -40,6 +40,7 @@ Views 2.x-dev
o #535424 by Hugo Wetterberg: Download file link could provide empty a tag if no file is available.
o #554000 by killes: Preview checking wrong flag for preview state causes feeds to display incorrectly when embedded.
o #554016 by webchick: views_embed_view() should check view access.
o #523222 by gpk: Contact link should not be allowed for the anonymous user.
Other changes:
o Implement a post_render hook (for themes too) and cache method.
......
......@@ -4,7 +4,7 @@
* A field that links to the user contact page, if access is permitted.
*/
class views_handler_field_contact_link extends views_handler_field_user_link {
function option_definition() {
$options = parent::option_definition();
$options['link_display'] = array('default' => 'link', 'translatable' => FALSE);
......@@ -30,20 +30,28 @@ class views_handler_field_contact_link extends views_handler_field_user_link {
function render($values) {
global $user;
$uid = $values->{$this->aliases['uid']};
$account = user_load(array('uid' => $uid));
// Only registered users can view other registered user's contact page.
if (empty($user->uid) || 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.
if (! _contact_user_tab_access($account)) {
if (!_contact_user_tab_access($account) || empty($account->contact)) {
return;
}
if ($account !== FALSE && $account->contact && $user->uid > 0) {
if ($this->options['link_display'] == 'icon') {
return l(theme('image', 'misc/forum-new.png'), 'user/'. $account->uid .'/contact', array('html' => TRUE, 'attributes' => array('title' => t('Contact %user', array('%user' => $account->name)))));
}
else {
return l($this->options['text'], 'user/'. $account->uid .'/contact', array('attributes' => array('title' => t('Contact %user', array('%user' => $account->name)))));
}
if ($this->options['link_display'] == 'icon') {
return l(theme('image', 'misc/forum-new.png'), 'user/'. $account->uid .'/contact', array('html' => TRUE, 'attributes' => array('title' => t('Contact %user', array('%user' => $account->name)))));
}
else {
return l($this->options['text'], 'user/'. $account->uid .'/contact', array('attributes' => array('title' => t('Contact %user', array('%user' => $account->name)))));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment