git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 20bd0c11 authored by mmn's avatar mmn

getStreamName will now return nick/fullname based on current user's preferred representation

parent 09ef1fff
......@@ -192,6 +192,20 @@ class Profile extends Managed_DataObject
return ($this->fullname) ? $this->fullname : $this->nickname;
}
/**
* Takes the currently scoped profile into account to give a name
* to list in notice streams. Preferences may differ between profiles.
*/
function getStreamName()
{
$user = common_current_user();
if ($user instanceof User && $user->streamNicknames()) {
return $this->nickname;
}
return $this->getBestName();
}
/**
* Gets the full name (if filled) with nickname as a parenthetical, or the nickname alone
* if no fullname is provided.
......
......@@ -222,14 +222,7 @@ class NoticeListItem extends Widget
$this->out->elementStart('a', $attrs);
$this->showAvatar();
$this->out->text(' ');
$user = common_current_user();
if (!empty($user) && $user->streamNicknames()) {
$this->out->element('span',array('class' => 'fn'),
$this->profile->nickname);
} else {
$this->out->element('span',array('class' => 'fn'),
$this->profile->getBestName());
}
$this->out->element('span',array('class' => 'fn'), $this->profile->getStreamName());
$this->out->elementEnd('a');
$this->out->elementEnd('span');
......@@ -268,16 +261,12 @@ class NoticeListItem extends Widget
$attentions = $this->getReplyProfiles();
$user = common_current_user();
$streamNicknames = !empty($user) && $user->streamNicknames();
foreach ($attentions as $attn) {
$class = $attn->isGroup() ? 'group' : 'account';
$pa[] = array('href' => $attn->profileurl,
'title' => $attn->nickname,
'class' => "addressee {$class}",
'text' => ($streamNicknames) ? $attn->nickname : $attn->getBestName());
'text' => $attn->getStreamName());
}
return $pa;
......
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