]> git.mxchange.org Git - friendica.git/commitdiff
Display the post receivers
authorMichael <heluecht@pirati.ca>
Sun, 20 Feb 2022 19:25:55 +0000 (19:25 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 20 Feb 2022 19:25:55 +0000 (19:25 +0000)
src/Module/PermissionTooltip.php
src/Object/Post.php
static/settings.config.php
view/theme/frio/css/style.css
view/theme/frio/templates/wall_thread.tpl

index 71ce2beee2aca1a11a4402e3130266bf102c56fe..f6722c984a755ea6508b9935d8a7ae62158df0e0 100644 (file)
@@ -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;
+       }
 }
index 17303bd62d7540abd84de44e875fbf9da7d4380c..bbd1e9ce1c037bb73dec3e9435af5020f115a6ea 100644 (file)
@@ -121,6 +121,29 @@ class Post
                }
        }
 
+       /**
+        * Fetch the privacy of the post
+        *
+        * @param array $item 
+        * @return string 
+        */
+       private function fetchPrivacy(array $item):string
+       {
+               switch ($item['private']) {
+                       case Item::PRIVATE:
+                               $output = DI::l10n()->t('Private Message');
+                               break;
+                       case Item::PUBLIC:
+                               $output = DI::l10n()->t('Public Message');
+                               break;
+                       case Item::UNLISTED:
+                               $output = DI::l10n()->t('Unlisted Message');
+                               break;
+               }
+
+               return $output;
+       }
+
        /**
         * Get data in a form usable by a conversation template
         *
@@ -170,12 +193,9 @@ class Post
 
                $conv = $this->getThread();
 
-               $lock = ((($item['private'] == Item::PRIVATE) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
-                       || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
-                       ? DI::l10n()->t('Private Message')
-                       : false);
-
-               $connector = !$item['global'] ? DI::l10n()->t('Connector Message') : false;
+               $privacy   = $this->fetchPrivacy($item);
+               $lock      = ($item['private'] == Item::PRIVATE) ? $privacy : false;
+               $connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false;
 
                $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE;
                $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
@@ -463,6 +483,8 @@ class Post
                        'app'             => $item['app'],
                        'created'         => $ago,
                        'lock'            => $lock,
+                       'private'         => $item['private'],
+                       'privacy'         => $privacy,
                        'connector'       => $connector,
                        'location_html'   => $location_html,
                        'indent'          => $indent,
index 24fce52f21716776552a034c41006eb7edef24f7..ea7558e5f751ed9df074330a89495037a64080dd 100644 (file)
@@ -140,6 +140,10 @@ return [
                // If you don't want to set a maximum length, set to -1.
                'max_image_length' => -1,
 
+               // max_receivers (Integer)
+               // The maximum number of displayed receivers of posts
+               'max_receivers' => 10,
+
                // maximagesize (Integer)
                // Maximum size in bytes of an uploaded photo.
                'maximagesize' => 800000,
index f96239c3074fcdb974545b9cda7c86ed8301f922..c619ee678f8ce80a2b906a1a60e2066900b17a8b 100644 (file)
@@ -1757,8 +1757,7 @@ blockquote.shared_content {
        font-weight: 500;
        color: $font_color_darker;
 }
-.media .media-body .addional-info a,
-.media .media-body h5.media-heading > a {
+.media .media-body .addional-info a {
        display: block;
 }
 .media .contact-info-comment {
@@ -1769,7 +1768,7 @@ blockquote.shared_content {
        margin: 0 0 5px;
 }
 .media-heading {
-       margin: 0 0 5px;
+       margin: 0px;
 }
 .wall-item-name,
 .shared-author {
index 55858d811ea9dba5c773a830623c7bd1c46fe710..c57ea091b6104c5670a3c8478657ece6ebfa4307 100644 (file)
@@ -158,12 +158,12 @@ as the value of $top_child_total (this is done at the end of this file)
                                                <span class="wall-item-name {{$item.osparkle}}" id="wall-item-ownername-{{$item.id}}">{{$item.owner_name}}</span>
                                        </a>
                                {{/if}}
-                               {{if $item.lock}}
-                                       <span class="navicon lock fakelink" onClick="lockview(event, 'item', {{$item.id}});" title="{{$item.lock}}" data-toggle="tooltip">
-                                               &nbsp;<small><i class="fa fa-lock" aria-hidden="true"></i></small>
+                               {{if $item.connector}}
+                                       <small><i class="fa fa-plug" title="{{$item.connector}}" aria-hidden="true"></i></small>
+                               {{else}}
+                                       <span class="navicon lock fakelink" onClick="lockview(event, 'item', {{$item.id}});" title="{{$item.privacy}}" data-toggle="tooltip">
+                                               &nbsp;<small><i class="fa {{if $item.private == 1}}fa-lock{{elseif $item.private == 0}}fa-globe{{else}}fa-low-vision{{/if}}" aria-hidden="true"></i></small>
                                        </span>
-                               {{elseif $item.connector}}
-                                       <small><i class="fa fa-lock" title="{{$item.connector}}"></i></small>
                                {{/if}}
                                </h4>
 
@@ -221,7 +221,15 @@ as the value of $top_child_total (this is done at the end of this file)
                        <div class="contact-info-comment">
                                <h5 class="media-heading">
                                        <a href="{{$item.profile_url}}" title="{{$item.linktitle}}" class="wall-item-name-link userinfo hover-card"><span class="fakelink">{{$item.name}}</span></a>
+                                       {{if $item.connector}}
+                                               <small><i class="fa fa-plug" title="{{$item.connector}}" aria-hidden="true"></i></small>
+                                       {{else}}
+                                               <span class="navicon lock fakelink" onClick="lockview(event, 'item', {{$item.id}});" title="{{$item.privacy}}" data-toggle="tooltip">
+                                                       &nbsp;<small><i class="fa {{if $item.private == 1}}fa-lock{{elseif $item.private == 0}}fa-globe{{else}}fa-low-vision{{/if}}" aria-hidden="true"></i></small>
+                                               </span>
+                                       {{/if}}
                                        <span class="text-muted">
+                               </h5>
                                <small>
                                        <a href="{{$item.plink.orig}}">
                                                <time class="time" title="{{$item.localtime}}" data-toggle="tooltip" datetime="{{$item.utc}}">{{$item.ago}}</time>
@@ -235,7 +243,6 @@ as the value of $top_child_total (this is done at the end of this file)
                                        {{/if}}
                                </small>
                        </span>
-                               </h5>
                        </div>
                {{/if}} {{* End of if $item.thread_level != 1 *}}
                </div>