`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';
--
/**
* Set the pinned state of an item
- *
+ *
* @param integer $iid Item ID
* @param integer $uid User ID
* @param boolean $pinned Pinned state
/**
* 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)
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
*
}
if (!$update) {
- $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
+ $tab = Strings::escapeTags(trim($_GET['tab'] ?? ''));
$o .= ProfileModel::getTabs($a, $tab, $is_owner, $a->profile['nickname']);
$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) {
$sparkle = '';
$buttons = '';
$dropping = false;
+ $pinned = '';
$pin = false;
$star = false;
$ignore = false;
if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) {
if ($origin) {
+ if ($item['pinned']) {
+ $pinned = L10n::t('pinned item');
+ }
+
$ispinned = ($item['pinned'] ? 'pinned' : 'unpinned');
$pin = [
'edpost' => $edpost,
'ispinned' => $ispinned,
'pin' => $pin,
+ 'pinned' => $pinned,
'isstarred' => $isstarred,
'star' => $star,
'ignore' => $ignore,
"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" => [
</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>
{{if $item.owner_self}}
{{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
{{/if}}
+ <span class="pinned">{{$item.pinned}}</span>
</small>
</div>
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>
<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>
{{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}}">