]> git.mxchange.org Git - friendica.git/commitdiff
show pinned items
authorMichael <heluecht@pirati.ca>
Thu, 7 Nov 2019 06:53:18 +0000 (06:53 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 7 Nov 2019 06:53:18 +0000 (06:53 +0000)
database.sql
src/Model/Item.php
src/Module/Profile.php
src/Object/Post.php
static/dbstructure.config.php
view/templates/wall_thread.tpl
view/theme/frio/templates/wall_thread.tpl
view/theme/quattro/templates/wall_thread.tpl
view/theme/smoothly/templates/wall_thread.tpl
view/theme/vier/templates/wall_thread.tpl

index e80c5cda221667780d3dd4d06fc9990809a437b3..86207a122100d040930de884ad5610036e1a3c91 100644 (file)
@@ -1282,7 +1282,8 @@ CREATE TABLE IF NOT EXISTS `user-item` (
        `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
        `ignored` boolean COMMENT 'Ignore this thread if set',
        `pinned` boolean COMMENT 'The item is pinned on the profile page',
-        PRIMARY KEY(`uid`,`iid`)
+        PRIMARY KEY(`uid`,`iid`),
+        INDEX `uid_pinned` (`uid`,`pinned`)
 ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
 
 --
index 882aa6444b1e37a6c2f82a50350acbce86ea2123..98b058215de89bdf649f18bc8eb521a4785d8e72 100644 (file)
@@ -116,7 +116,7 @@ class Item extends BaseObject
 
        /**
         * Set the pinned state of an item
-        * 
+        *
         * @param integer $iid    Item ID
         * @param integer $uid    User ID
         * @param boolean $pinned Pinned state
@@ -128,10 +128,10 @@ class Item extends BaseObject
 
        /**
         * Get the pinned state
-        * 
+        *
         * @param integer $iid Item ID
         * @param integer $uid User ID
-        * 
+        *
         * @return boolean pinned state
         */
        public static function getPinned(int $iid, int $uid)
@@ -143,6 +143,22 @@ class Item extends BaseObject
                return (bool)$useritem['pinned'];
        }
 
+       public static function selectPinned(int $uid, array $selected = [])
+       {
+               $useritems = DBA::select('user-item', ['iid'], ['uid' => $uid, 'pinned' => true]);
+               if (!DBA::isResult($useritems)) {
+                       return $useritems;
+               }
+
+               $pinned = [];
+               while ($useritem = self::fetch($useritems)) {
+                       $pinned[] = $useritem['iid'];
+               }
+               DBA::close($useritems);
+
+               return self::selectThreadForUser($uid, $selected, ['iid' => $pinned]);
+       }
+
        /**
         * @brief returns an activity index from an activity string
         *
index 69db45acf1fe0bf0107fbc9222c86442fa386516..ac345fad243047ba589e9bf944263d8b6c262f8e 100644 (file)
@@ -177,7 +177,7 @@ class Profile extends BaseModule
                }
 
                if (!$update) {
-            $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
+                       $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
 
                        $o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
 
@@ -349,6 +349,12 @@ class Profile extends BaseModule
 
                $items = DBA::toArray($items_stmt);
 
+               if ($pager->getStart() == 0) {
+                       $pinned_items = Item::selectPinned($a->profile['profile_uid'], ['uri']);
+                       $pinned = Item::inArray($pinned_items);
+                       $items = array_merge($items, $pinned);
+               }
+
                $o .= conversation($a, $items, $pager, 'profile', $update, false, 'received', $a->profile['profile_uid']);
 
                if (!$update) {
index f3c607ee64411d5cc84c934a6a0348ddc67b99fc..f9119ee032676eb85ab1e292eb4f4c9fd25f8eb8 100644 (file)
@@ -140,6 +140,7 @@ class Post extends BaseObject
                $sparkle = '';
                $buttons = '';
                $dropping = false;
+               $pinned = '';
                $pin = false;
                $star = false;
                $ignore = false;
@@ -287,6 +288,10 @@ class Post extends BaseObject
 
                                if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
                                        if ($origin) {
+                                               if ($item['pinned']) {
+                                                       $pinned = L10n::t('pinned item');
+                                               }
+
                                                $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
 
                                                $pin = [
@@ -424,6 +429,7 @@ class Post extends BaseObject
                        'edpost'          => $edpost,
                        'ispinned'        => $ispinned,
                        'pin'             => $pin,
+                       'pinned'          => $pinned,
                        'isstarred'       => $isstarred,
                        'star'            => $star,
                        'ignore'          => $ignore,
index 65e0b26a6a4bafb1951015f275d50bc450b41cbb..7f4cd71286f3513b1908a403bb3988957987d12f 100755 (executable)
@@ -1388,7 +1388,8 @@ return [
                        "pinned" => ["type" => "boolean", "comment" => "The item is pinned on the profile page"]
                ],
                "indexes" => [
-                       "PRIMARY" => ["uid", "iid"]
+                       "PRIMARY" => ["uid", "iid"],
+                       "uid_pinned" => ["uid", "pinned"]
                ]
        ],
        "worker-ipc" => [
index 001bdaebb42774a5b45651d7577b31736b168795..0816400d5258ee811e8886a240bc00a62a4cf96d 100644 (file)
@@ -50,7 +50,7 @@
                </div>
                <div class="wall-item-author">
                                <a href="{{$item.profile_url}}" target="redir" title="{{$item.linktitle}}" class="wall-item-name-link"><span class="wall-item-name{{$item.sparkle}}" id="wall-item-name-{{$item.id}}" >{{$item.name}}</span></a>{{if $item.owner_url}} {{$item.to}} <a href="{{$item.owner_url}}" target="redir" title="{{$item.olinktitle}}" class="wall-item-name-link"><span class="wall-item-name{{$item.osparkle}}" id="wall-item-ownername-{{$item.id}}">{{$item.owner_name}}</span></a> {{$item.vwall}}{{/if}}<br />
-                               <div class="wall-item-ago"  id="wall-item-ago-{{$item.id}}" title="{{$item.localtime}}"><time class="dt-published" datetime="{{$item.localtime}}">{{$item.ago}}</time></div>
+                               <div class="wall-item-ago" id="wall-item-ago-{{$item.id}}" title="{{$item.localtime}}"><time class="dt-published" datetime="{{$item.localtime}}">{{$item.ago}}</time><span class="pinned">{{$item.pinned}}</span></div>
                </div>
                <div class="wall-item-content" id="wall-item-content-{{$item.id}}" >
                        <div class="wall-item-title p-name" id="wall-item-title-{{$item.id}}">{{$item.title}}</div>
index cffe1087bd14820f6d4185049e8291f916ba044e..31f13ea379ba2f55b5b25a33d7d76cdc2753ed01 100644 (file)
@@ -236,6 +236,7 @@ as the value of $top_child_total (this is done at the end of this file)
                                                {{if $item.owner_self}}
                                                        {{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
                                                {{/if}}
+                                               <span class="pinned">{{$item.pinned}}</span>
                                        </small>
                                </div>
 
index c3d65000219c6c1a04a7addd54313d8317264716..77d63f6e5d94c9f8bb9424b58afa68d95edd603a 100644 (file)
@@ -88,6 +88,7 @@
                                 class="wall-item-name-link"><span
                                 class="wall-item-name{{$item.sparkle}}">{{$item.name}}</span></a>
                                 <span class="wall-item-ago" title="{{$item.localtime}}"><time class="dt-published" datetime="{{$item.localtime}}">{{$item.ago}}</time></span>
+                               <span class="pinned">{{$item.pinned}}</span>
                                 {{if $item.owner_url}}<br/>{{$item.to}} <a href="{{$item.owner_url}}" target="redir" title="{{$item.olinktitle}}" class="wall-item-name-link"><span class="wall-item-name{{$item.osparkle}}" id="wall-item-ownername-{{$item.id}}">{{$item.owner_name}}</span></a> {{$item.vwall}}
                                 {{/if}}
                        </div>
index 7b56c9130fa6aca6c406842c72171a1e2b1f13d7..b372fbefbc0667113b7e65e65c4868011f94c707 100644 (file)
@@ -54,7 +54,7 @@
                        <span class="wall-item-name{{$item.sparkle}}" id="wall-item-name-{{$item.id}}" >{{$item.name}}</span>
                        </a>
                        <div class="wall-item-ago">&bull;</div>
-                       <div class="wall-item-ago" id="wall-item-ago-{{$item.id}}" title="{{$item.localtime}}"><time class="dt-published" datetime="{{$item.localtime}}">{{$item.ago}}</time></div>
+                       <div class="wall-item-ago" id="wall-item-ago-{{$item.id}}" title="{{$item.localtime}}"><time class="dt-published" datetime="{{$item.localtime}}">{{$item.ago}}</time><span class="pinned">{{$item.pinned}}</span></div>
                </div>
 
                <div>
index 1d432ea45306ee0c71b11bae94b47ac26f2c7250..c27ec33cdc73d481853a66902f7acb81adccce56 100644 (file)
@@ -60,6 +60,7 @@
                                {{if $item.owner_self}}
                                        {{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
                                {{/if}}
+                               <span class="pinned">{{$item.pinned}}</span>
                        </span>
                        {{if $item.lock}}<span class="icon s10 lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}}
                        <span class="wall-item-network" title="{{$item.app}}">