From ddd60e7142dc0175d3cbaba5fa54430857d64e00 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 1 Mar 2016 23:37:38 +0100 Subject: [PATCH] Make Profile->getFancyName() return including the acct URI --- classes/Profile.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 36e91c3ad0..4fa20d7cd4 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -225,11 +225,11 @@ class Profile extends Managed_DataObject */ function getFancyName() { - if ($this->fullname) { - // TRANS: Full name of a profile or group (%1$s) followed by nickname (%2$s) in parentheses. - return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->fullname, $this->nickname); + if ($this->getFullname()) { + // TRANS: Full name of a profile or group (%1$s) followed by acct URI (%2$s) in parentheses without acct:. + return sprintf(_m('FANCYNAME','%1$s (%2$s)'), $this->getFullname(), $this->getAcctUri()); } else { - return $this->nickname; + return $this->getAcctUri(false); } } @@ -1575,7 +1575,7 @@ class Profile extends Managed_DataObject * * @return string $uri */ - public function getAcctUri() + public function getAcctUri($scheme=true) { $acct = null; @@ -1586,11 +1586,15 @@ class Profile extends Managed_DataObject if ($acct === null) { throw new ProfileNoAcctUriException($this); } + if (parse_url($acct, PHP_URL_SCHEME) !== 'acct') { + throw new ServerException('Acct URI does not have acct: scheme'); + } - return $acct; + // if we don't return the scheme, just remove the 'acct:' in the beginning + return $scheme ? $acct : mb_substr($acct, 5); } - function hasBlocked($other) + function hasBlocked(Profile $other) { $block = Profile_block::exists($this, $other); return !empty($block);