X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FPermissionTooltip.php;h=c1ef4c2b4b794a5286cbd9d22ece63f98314d54e;hb=40777d08c198ed5f435a7b029e25ea139de62c16;hp=372c508d6f6f217465513918d00c0188597073b0;hpb=59630a2c821cda6ac3a5ced81f2fb8831f8755f4;p=friendica.git
diff --git a/src/Module/PermissionTooltip.php b/src/Module/PermissionTooltip.php
index 372c508d6f..c1ef4c2b4b 100644
--- a/src/Module/PermissionTooltip.php
+++ b/src/Module/PermissionTooltip.php
@@ -22,11 +22,15 @@
namespace Friendica\Module;
use Friendica\Core\Hook;
+use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Model\APContact;
use Friendica\Model\Group;
+use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag;
+use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Protocol\ActivityPub;
@@ -45,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];
+ $condition = ['id' => $referenceId, 'uid' => [0, DI::userSession()->getLocalUserId()]];
if ($type == 'item') {
$fields = ['uid', 'psid', 'private', 'uri-id'];
$model = Post::selectFirst($fields, $condition);
@@ -75,12 +79,26 @@ class PermissionTooltip extends \Friendica\BaseModule
if ($type == 'item') {
$receivers = $this->fetchReceivers($model['uri-id']);
+ if (empty($receivers)) {
+ switch ($model['private']) {
+ 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 = '';
}
- if ($model['uid'] != local_user() ||
- empty($model['allow_cid'])
+ if (empty($model['allow_cid'])
&& empty($model['allow_gid'])
&& empty($model['deny_cid'])
&& empty($model['deny_gid'])
@@ -147,30 +165,51 @@ 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
{
- // We only fetch "to" and "cc", because "bcc" should never be displayed
+ $own_url = '';
+ $uid = DI::userSession()->getLocalUserId();
+ if ($uid) {
+ $owner = User::getOwnerDataById($uid);
+ if (!empty($owner['url'])) {
+ $own_url = $owner['url'];
+ }
+ }
+
$receivers = [];
- foreach (Tag::getByURIId($uriId, [Tag::TO, Tag::CC]) as $receiver) {
- 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']);
- } else {
+ foreach (Tag::getByURIId($uriId, [Tag::TO, Tag::CC, Tag::BCC]) as $receiver) {
+ // We only display BCC when it contains the current user
+ if (($receiver['type'] == Tag::BCC) && ($receiver['url'] != $own_url)) {
+ continue;
+ }
+
+ 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;
}
}
@@ -190,6 +229,9 @@ class PermissionTooltip extends \Friendica\BaseModule
case Tag::CC:
$output .= DI::l10n()->t('CC: %s
', implode(', ', $receiver));
break;
+ case Tag::BCC:
+ $output .= DI::l10n()->t('BCC: %s
', implode(', ', $receiver));
+ break;
}
}