show pinned items

This commit is contained in:
Michael 2019-11-07 06:53:18 +00:00
parent cf56992444
commit ed58af25a5
10 changed files with 41 additions and 8 deletions

View 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', `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide an item from the user',
`ignored` boolean COMMENT 'Ignore this thread if set', `ignored` boolean COMMENT 'Ignore this thread if set',
`pinned` boolean COMMENT 'The item is pinned on the profile page', `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'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific item data';
-- --

View file

@ -116,7 +116,7 @@ class Item extends BaseObject
/** /**
* Set the pinned state of an item * Set the pinned state of an item
* *
* @param integer $iid Item ID * @param integer $iid Item ID
* @param integer $uid User ID * @param integer $uid User ID
* @param boolean $pinned Pinned state * @param boolean $pinned Pinned state
@ -128,10 +128,10 @@ class Item extends BaseObject
/** /**
* Get the pinned state * Get the pinned state
* *
* @param integer $iid Item ID * @param integer $iid Item ID
* @param integer $uid User ID * @param integer $uid User ID
* *
* @return boolean pinned state * @return boolean pinned state
*/ */
public static function getPinned(int $iid, int $uid) public static function getPinned(int $iid, int $uid)
@ -143,6 +143,22 @@ class Item extends BaseObject
return (bool)$useritem['pinned']; 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 * @brief returns an activity index from an activity string
* *

View file

@ -177,7 +177,7 @@ class Profile extends BaseModule
} }
if (!$update) { if (!$update) {
$tab = Strings::escapeTags(trim($_GET['tab'] ?? '')); $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
$o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']); $o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
@ -349,6 +349,12 @@ class Profile extends BaseModule
$items = DBA::toArray($items_stmt); $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']); $o .= conversation($a, $items, $pager, 'profile', $update, false, 'received', $a->profile['profile_uid']);
if (!$update) { if (!$update) {

View file

@ -140,6 +140,7 @@ class Post extends BaseObject
$sparkle = ''; $sparkle = '';
$buttons = ''; $buttons = '';
$dropping = false; $dropping = false;
$pinned = '';
$pin = false; $pin = false;
$star = false; $star = false;
$ignore = false; $ignore = false;
@ -287,6 +288,10 @@ class Post extends BaseObject
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
if ($origin) { if ($origin) {
if ($item['pinned']) {
$pinned = L10n::t('pinned item');
}
$ispinned = ($item['pinned'] ? 'pinned' : 'unpinned'); $ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
$pin = [ $pin = [
@ -424,6 +429,7 @@ class Post extends BaseObject
'edpost' => $edpost, 'edpost' => $edpost,
'ispinned' => $ispinned, 'ispinned' => $ispinned,
'pin' => $pin, 'pin' => $pin,
'pinned' => $pinned,
'isstarred' => $isstarred, 'isstarred' => $isstarred,
'star' => $star, 'star' => $star,
'ignore' => $ignore, 'ignore' => $ignore,

View file

@ -1388,7 +1388,8 @@ return [
"pinned" => ["type" => "boolean", "comment" => "The item is pinned on the profile page"] "pinned" => ["type" => "boolean", "comment" => "The item is pinned on the profile page"]
], ],
"indexes" => [ "indexes" => [
"PRIMARY" => ["uid", "iid"] "PRIMARY" => ["uid", "iid"],
"uid_pinned" => ["uid", "pinned"]
] ]
], ],
"worker-ipc" => [ "worker-ipc" => [

View file

@ -50,7 +50,7 @@
</div> </div>
<div class="wall-item-author"> <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 /> <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>
<div class="wall-item-content" id="wall-item-content-{{$item.id}}" > <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> <div class="wall-item-title p-name" id="wall-item-title-{{$item.id}}">{{$item.title}}</div>

View 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}} {{if $item.owner_self}}
{{include file="sub/delivery_count.tpl" delivery=$item.delivery}} {{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
{{/if}} {{/if}}
<span class="pinned">{{$item.pinned}}</span>
</small> </small>
</div> </div>

View file

@ -88,6 +88,7 @@
class="wall-item-name-link"><span class="wall-item-name-link"><span
class="wall-item-name{{$item.sparkle}}">{{$item.name}}</span></a> 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="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 $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}} {{/if}}
</div> </div>

View file

@ -54,7 +54,7 @@
<span class="wall-item-name{{$item.sparkle}}" id="wall-item-name-{{$item.id}}" >{{$item.name}}</span> <span class="wall-item-name{{$item.sparkle}}" id="wall-item-name-{{$item.id}}" >{{$item.name}}</span>
</a> </a>
<div class="wall-item-ago">&bull;</div> <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>
<div> <div>

View file

@ -60,6 +60,7 @@
{{if $item.owner_self}} {{if $item.owner_self}}
{{include file="sub/delivery_count.tpl" delivery=$item.delivery}} {{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
{{/if}} {{/if}}
<span class="pinned">{{$item.pinned}}</span>
</span> </span>
{{if $item.lock}}<span class="icon s10 lock fakelink" onclick="lockview(event,{{$item.id}});" title="{{$item.lock}}">{{$item.lock}}</span>{{/if}} {{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}}"> <span class="wall-item-network" title="{{$item.app}}">