mirror of
https://github.com/friendica/friendica
synced 2024-11-17 21:43:41 +00:00
show pinned items
This commit is contained in:
parent
cf56992444
commit
ed58af25a5
10 changed files with 41 additions and 8 deletions
|
@ -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';
|
||||
|
||||
--
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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" => [
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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">•</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>
|
||||
|
|
|
@ -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}}">
|
||||
|
|
Loading…
Reference in a new issue