Browse Source

show pinned items

pull/7823/head
Michael 2 years ago
parent
commit
ed58af25a5
10 changed files with 41 additions and 8 deletions
  1. +2
    -1
      database.sql
  2. +19
    -3
      src/Model/Item.php
  3. +7
    -1
      src/Module/Profile.php
  4. +6
    -0
      src/Object/Post.php
  5. +2
    -1
      static/dbstructure.config.php
  6. +1
    -1
      view/templates/wall_thread.tpl
  7. +1
    -0
      view/theme/frio/templates/wall_thread.tpl
  8. +1
    -0
      view/theme/quattro/templates/wall_thread.tpl
  9. +1
    -1
      view/theme/smoothly/templates/wall_thread.tpl
  10. +1
    -0
      view/theme/vier/templates/wall_thread.tpl

+ 2
- 1
database.sql 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',
`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';
--


+ 19
- 3
src/Model/Item.php View 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
*


+ 7
- 1
src/Module/Profile.php View 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) {


+ 6
- 0
src/Object/Post.php View 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,


+ 2
- 1
static/dbstructure.config.php View File

@ -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" => [


+ 1
- 1
view/templates/wall_thread.tpl View 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>


+ 1
- 0
view/theme/frio/templates/wall_thread.tpl 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}}
{{include file="sub/delivery_count.tpl" delivery=$item.delivery}}
{{/if}}
<span class="pinned">{{$item.pinned}}</span>
</small>
</div>


+ 1
- 0
view/theme/quattro/templates/wall_thread.tpl View 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>


+ 1
- 1
view/theme/smoothly/templates/wall_thread.tpl View 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>


+ 1
- 0
view/theme/vier/templates/wall_thread.tpl View 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}}">


Loading…
Cancel
Save