From 189c55d1d332eeb805b4536f206bffe76111d6d6 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 18 May 2015 15:39:34 -0700 Subject: [PATCH] People - fix hovercards for people Summary: Fixes T8242. D12833 removed the title as well as the blurb from people hovercards. When re-adding the title don't bother throwing things through pht since that seems like not something you translate exactly and also lose the flavor text which most users end up having since title is rarely set (at least on this install). Test Plan: viewed hovercards and saw title and blurb again as appropos relative to the data being set Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8242 Differential Revision: https://secure.phabricator.com/D12915 --- .../PhabricatorPeopleHovercardEventListener.php | 15 ++++++++++++++- .../people/storage/PhabricatorUser.php | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php b/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php index f2b957f363..6ecf0a9bd9 100644 --- a/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php +++ b/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php @@ -31,10 +31,16 @@ final class PhabricatorPeopleHovercardEventListener ->setViewer($viewer) ->withIDs(array($user->getID())) ->needAvailability(true) + ->needProfile(true) ->executeOne(); $hovercard->setTitle($user->getUsername()); - $hovercard->setDetail($user->getRealName()); + $profile = $user->getUserProfile(); + $detail = $user->getRealName(); + if ($profile->getTitle()) { + $detail .= ' - '.$profile->getTitle().'.'; + } + $hovercard->setDetail($detail); if ($user->getIsDisabled()) { $hovercard->addField(pht('Account'), pht('Disabled')); @@ -52,6 +58,13 @@ final class PhabricatorPeopleHovercardEventListener pht('User Since'), phabricator_date($user->getDateCreated(), $viewer)); + if ($profile->getBlurb()) { + $hovercard->addField(pht('Blurb'), + id(new PhutilUTF8StringTruncator()) + ->setMaximumGlyphs(120) + ->truncateString($profile->getBlurb())); + } + $event->setValue('hovercard', $hovercard); } diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 0c7ef73b0e..e66a34d9a1 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -396,6 +396,10 @@ final class PhabricatorUser return substr(PhabricatorHash::digest($vec), 0, $len); } + public function getUserProfile() { + return $this->assertAttached($this->profile); + } + public function attachUserProfile(PhabricatorUserProfile $profile) { $this->profile = $profile; return $this;