mirror of
https://github.com/friendica/friendica
synced 2025-04-22 01:10:13 +00:00
Display the post receivers
This commit is contained in:
parent
d2be291502
commit
39e820e6a3
5 changed files with 100 additions and 22 deletions
|
@ -25,8 +25,8 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
|
||||
$condition = ['id' => $referenceId];
|
||||
if ($type == 'item') {
|
||||
$fields = ['uid', 'psid', 'private'];
|
||||
$fields = ['uid', 'psid', 'private', 'uri-id'];
|
||||
$model = Post::selectFirst($fields, $condition);
|
||||
} else {
|
||||
$fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
||||
|
@ -72,13 +72,18 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
// Kept for backwards compatiblity
|
||||
Hook::callAll('lockview_content', $model);
|
||||
|
||||
if ($type == 'item') {
|
||||
$receivers = $this->fetchReceivers($model['uri-id']);
|
||||
} else {
|
||||
$receivers = '';
|
||||
}
|
||||
|
||||
if ($model['uid'] != local_user() ||
|
||||
isset($model['private'])
|
||||
&& $model['private'] == Item::PRIVATE
|
||||
&& empty($model['allow_cid'])
|
||||
empty($model['allow_cid'])
|
||||
&& empty($model['allow_gid'])
|
||||
&& empty($model['deny_cid'])
|
||||
&& empty($model['deny_gid']))
|
||||
&& empty($model['deny_gid'])
|
||||
&& empty($receivers))
|
||||
{
|
||||
echo DI::l10n()->t('Remote privacy information not available.');
|
||||
exit;
|
||||
|
@ -136,7 +141,48 @@ class PermissionTooltip extends \Friendica\BaseModule
|
|||
$l[] = '<strike>' . $contact['name'] . '</strike>';
|
||||
}
|
||||
|
||||
echo $o . implode(', ', $l);
|
||||
if (!empty($l)) {
|
||||
echo $o . implode(', ', $l);
|
||||
} else {
|
||||
echo $o . $receivers;
|
||||
}
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a list of receivers
|
||||
*
|
||||
* @param int $uriId
|
||||
* @return string
|
||||
*/
|
||||
private function fetchReceivers(int $uriId):string
|
||||
{
|
||||
// We only fetch "to" and "cc", because "bcc" should never be displayed
|
||||
$receivers = [];
|
||||
foreach (Tag::getByURIId($uriId, [Tag::TO, Tag::CC]) as $receiver) {
|
||||
$receivers[$receiver['type']][] = $receiver['name'];
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach ($receivers as $type => $receiver) {
|
||||
$max = DI::config()->get('system', 'max_receivers');
|
||||
$total = count($receiver);
|
||||
if ($total > $max) {
|
||||
$receiver = array_slice($receiver, 0, $max);
|
||||
$receiver[] = DI::l10n()->t('%d more', $total - $max);
|
||||
}
|
||||
switch ($type) {
|
||||
case Tag::TO:
|
||||
$output .= DI::l10n()->t('<b>To:</b> %s<br>', implode(', ', $receiver));
|
||||
break;
|
||||
case Tag::CC:
|
||||
$output .= DI::l10n()->t('<b>CC:</b> %s<br>', implode(', ', $receiver));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue