]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
getStreamName will now return nick/fullname based on current user's preferred represe...
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 30 Oct 2013 12:05:04 +0000 (13:05 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 30 Oct 2013 12:05:04 +0000 (13:05 +0100)
classes/Profile.php
lib/noticelistitem.php

index c93ba07c29b020cbb50ed459230e482807a5db3f..76b2ac28d0de52050b42f40dab0cf005938e05e6 100644 (file)
@@ -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.
index 734342819db553f49eb797e6c2de798926643dcc..6aef97a1a4b8716000004215a76ec1d64b9ef022 100644 (file)
@@ -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;