Show permissions for all posts when possible

This commit is contained in:
Michael 2022-03-10 07:38:12 +00:00
parent c81eb78e38
commit 03d38d9e35
2 changed files with 50 additions and 30 deletions

View File

@ -26,6 +26,7 @@ use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\APContact; use Friendica\Model\APContact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
@ -47,7 +48,7 @@ class PermissionTooltip extends \Friendica\BaseModule
throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes))); 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, local_user()]];
if ($type == 'item') { if ($type == 'item') {
$fields = ['uid', 'psid', 'private', 'uri-id']; $fields = ['uid', 'psid', 'private', 'uri-id'];
$model = Post::selectFirst($fields, $condition); $model = Post::selectFirst($fields, $condition);
@ -77,12 +78,26 @@ class PermissionTooltip extends \Friendica\BaseModule
if ($type == 'item') { if ($type == 'item') {
$receivers = $this->fetchReceivers($model['uri-id']); $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 { } else {
$receivers = ''; $receivers = '';
} }
if ($model['uid'] != local_user() || if (empty($model['allow_cid'])
empty($model['allow_cid'])
&& empty($model['allow_gid']) && empty($model['allow_gid'])
&& empty($model['deny_cid']) && empty($model['deny_cid'])
&& empty($model['deny_gid']) && empty($model['deny_gid'])

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2022.05-dev\n" "Project-Id-Version: 2022.05-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-06 11:22+0000\n" "POT-Creation-Date: 2022-03-10 07:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1967,7 +1967,7 @@ msgstr ""
msgid "Friend Suggestions" msgid "Friend Suggestions"
msgstr "" msgstr ""
#: mod/tagger.php:78 src/Content/Item.php:338 src/Model/Item.php:2670 #: mod/tagger.php:78 src/Content/Item.php:338 src/Model/Item.php:2677
msgid "photo" msgid "photo"
msgstr "" msgstr ""
@ -2151,8 +2151,8 @@ msgid "All contacts"
msgstr "" msgstr ""
#: src/BaseModule.php:409 src/Content/Widget.php:231 src/Core/ACL.php:194 #: src/BaseModule.php:409 src/Content/Widget.php:231 src/Core/ACL.php:194
#: src/Module/Contact.php:367 src/Module/PermissionTooltip.php:106 #: src/Module/Contact.php:367 src/Module/PermissionTooltip.php:121
#: src/Module/PermissionTooltip.php:128 #: src/Module/PermissionTooltip.php:143
msgid "Followers" msgid "Followers"
msgstr "" msgstr ""
@ -2726,7 +2726,7 @@ msgstr ""
msgid "%1$s poked %2$s" msgid "%1$s poked %2$s"
msgstr "" msgstr ""
#: src/Content/Item.php:330 src/Model/Item.php:2668 #: src/Content/Item.php:330 src/Model/Item.php:2675
msgid "event" msgid "event"
msgstr "" msgstr ""
@ -3077,8 +3077,8 @@ msgid ""
"<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s" "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
msgstr "" msgstr ""
#: src/Content/Text/BBCode.php:1185 src/Model/Item.php:3199 #: src/Content/Text/BBCode.php:1185 src/Model/Item.php:3206
#: src/Model/Item.php:3205 src/Model/Item.php:3206 #: src/Model/Item.php:3212 src/Model/Item.php:3213
msgid "Link to source" msgid "Link to source"
msgstr "" msgstr ""
@ -3310,8 +3310,8 @@ msgstr ""
msgid "Yourself" msgid "Yourself"
msgstr "" msgstr ""
#: src/Core/ACL.php:201 src/Module/PermissionTooltip.php:112 #: src/Core/ACL.php:201 src/Module/PermissionTooltip.php:127
#: src/Module/PermissionTooltip.php:134 #: src/Module/PermissionTooltip.php:149
msgid "Mutuals" msgid "Mutuals"
msgstr "" msgstr ""
@ -3319,7 +3319,8 @@ msgstr ""
msgid "Post to Email" msgid "Post to Email"
msgstr "" msgstr ""
#: src/Core/ACL.php:320 src/Module/PermissionTooltip.php:181 #: src/Core/ACL.php:320 src/Module/PermissionTooltip.php:84
#: src/Module/PermissionTooltip.php:196
msgid "Public" msgid "Public"
msgstr "" msgstr ""
@ -3329,7 +3330,7 @@ msgid ""
"community pages and by anyone with its link." "community pages and by anyone with its link."
msgstr "" msgstr ""
#: src/Core/ACL.php:322 #: src/Core/ACL.php:322 src/Module/PermissionTooltip.php:92
msgid "Limited/Private" msgid "Limited/Private"
msgstr "" msgstr ""
@ -4250,33 +4251,33 @@ msgstr ""
msgid "Edit groups" msgid "Edit groups"
msgstr "" msgstr ""
#: src/Model/Item.php:1764 #: src/Model/Item.php:1771
#, php-format #, php-format
msgid "Detected languages in this post:\\n%s" msgid "Detected languages in this post:\\n%s"
msgstr "" msgstr ""
#: src/Model/Item.php:2672 #: src/Model/Item.php:2679
msgid "activity" msgid "activity"
msgstr "" msgstr ""
#: src/Model/Item.php:2674 #: src/Model/Item.php:2681
msgid "comment" msgid "comment"
msgstr "" msgstr ""
#: src/Model/Item.php:2677 #: src/Model/Item.php:2684
msgid "post" msgid "post"
msgstr "" msgstr ""
#: src/Model/Item.php:2814 #: src/Model/Item.php:2821
#, php-format #, php-format
msgid "Content warning: %s" msgid "Content warning: %s"
msgstr "" msgstr ""
#: src/Model/Item.php:3164 #: src/Model/Item.php:3171
msgid "bytes" msgid "bytes"
msgstr "" msgstr ""
#: src/Model/Item.php:3193 src/Model/Item.php:3194 #: src/Model/Item.php:3200 src/Model/Item.php:3201
msgid "View on separate page" msgid "View on separate page"
msgstr "" msgstr ""
@ -8553,44 +8554,48 @@ msgstr ""
msgid "Unsupported or missing grant type" msgid "Unsupported or missing grant type"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:47 #: src/Module/PermissionTooltip.php:48
#, php-format #, php-format
msgid "Wrong type \"%s\", expected one of: %s" msgid "Wrong type \"%s\", expected one of: %s"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:64 #: src/Module/PermissionTooltip.php:65
msgid "Model not found" msgid "Model not found"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:91 #: src/Module/PermissionTooltip.php:88
msgid "Unlisted"
msgstr ""
#: src/Module/PermissionTooltip.php:106
msgid "Remote privacy information not available." msgid "Remote privacy information not available."
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:100 #: src/Module/PermissionTooltip.php:115
msgid "Visible to:" msgid "Visible to:"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:185 #: src/Module/PermissionTooltip.php:200
#, php-format #, php-format
msgid "Followers (%s)" msgid "Followers (%s)"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:201 #: src/Module/PermissionTooltip.php:216
#, php-format #, php-format
msgid "%d more" msgid "%d more"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:205 #: src/Module/PermissionTooltip.php:220
#, php-format #, php-format
msgid "<b>To:</b> %s<br>" msgid "<b>To:</b> %s<br>"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:208 #: src/Module/PermissionTooltip.php:223
#, php-format #, php-format
msgid "<b>CC:</b> %s<br>" msgid "<b>CC:</b> %s<br>"
msgstr "" msgstr ""
#: src/Module/PermissionTooltip.php:211 #: src/Module/PermissionTooltip.php:226
#, php-format #, php-format
msgid "<b>BCC:</b> %s<br>" msgid "<b>BCC:</b> %s<br>"
msgstr "" msgstr ""