X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FPermissionTooltip.php;h=c1ef4c2b4b794a5286cbd9d22ece63f98314d54e;hb=7072a7178896c567caf5003e94a8f8045221bd8f;hp=58b6df086d1f6ad01fcb753a3c0b2c0879dfd39a;hpb=03d38d9e354b4dbd124cc69ecfa5c3773d33d962;p=friendica.git diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php index 58b6df086d..c1ef4c2b4b 100644 --- a/src/Module/PermissionTooltip.php +++ b/src/Module/PermissionTooltip.php @@ -22,6 +22,7 @@ namespace Friendica\Module; use Friendica\Core\Hook; +use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\APContact; @@ -48,7 +49,7 @@ class PermissionTooltip extends \Friendica\BaseModule throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes))); } - $condition = ['id' => $referenceId, 'uid' => [0, local_user()]]; + $condition = ['id' => $referenceId, 'uid' => [0, DI::userSession()->getLocalUserId()]]; if ($type == 'item') { $fields = ['uid', 'psid', 'private', 'uri-id']; $model = Post::selectFirst($fields, $condition); @@ -83,15 +84,15 @@ class PermissionTooltip extends \Friendica\BaseModule case Item::PUBLIC: $receivers = DI::l10n()->t('Public'); break; - + case Item::UNLISTED: $receivers = DI::l10n()->t('Unlisted'); break; - + case Item::PRIVATE: $receivers = DI::l10n()->t('Limited/Private'); break; - } + } } } else { $receivers = ''; @@ -164,20 +165,19 @@ class PermissionTooltip extends \Friendica\BaseModule } else { echo $o . $receivers; } - - exit(); + System::exit(); } /** * Fetch a list of receivers * * @param int $uriId - * @return string + * @return string */ - private function fetchReceivers(int $uriId):string + private function fetchReceivers(int $uriId): string { $own_url = ''; - $uid = local_user(); + $uid = DI::userSession()->getLocalUserId(); if ($uid) { $owner = User::getOwnerDataById($uid); if (!empty($owner['url'])) { @@ -192,17 +192,24 @@ class PermissionTooltip extends \Friendica\BaseModule continue; } - if ($receiver['url'] == ActivityPub::PUBLIC_COLLECTION) { - $receivers[$receiver['type']][] = DI::l10n()->t('Public'); - } else { - $apcontact = DBA::selectFirst('apcontact', ['name'], ['followers' => $receiver['url']]); - if (!empty($apcontact['name'])) { - $receivers[$receiver['type']][] = DI::l10n()->t('Followers (%s)', $apcontact['name']); - } elseif ($apcontact = APContact::getByURL($receiver['url'], false)) { - $receivers[$receiver['type']][] = $apcontact['name']; - } else { + switch (Tag::getTargetType($receiver['url'], false)) { + case Tag::PUBLIC_COLLECTION: + $receivers[$receiver['type']][] = DI::l10n()->t('Public'); + break; + case Tag::GENERAL_COLLECTION: + $receivers[$receiver['type']][] = DI::l10n()->t('Collection (%s)', $receiver['name']); + break; + case Tag::FOLLOWER_COLLECTION: + $apcontact = DBA::selectFirst('apcontact', ['name'], ['followers' => $receiver['url']]); + $receivers[$receiver['type']][] = DI::l10n()->t('Followers (%s)', $apcontact['name'] ?? $receiver['name']); + break; + case Tag::ACCOUNT: + $apcontact = APContact::getByURL($receiver['url'], false); + $receivers[$receiver['type']][] = $apcontact['name'] ?? $receiver['name']; + break; + default: $receivers[$receiver['type']][] = $receiver['name']; - } + break; } }