Merge pull request #7824 from annando/pin2
Pinning now works as expected
This commit is contained in:
commit
907414497d
|
@ -801,10 +801,12 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
|
||||||
/**
|
/**
|
||||||
* Fetch all comments from a query. Additionally set the newest resharer as thread owner.
|
* Fetch all comments from a query. Additionally set the newest resharer as thread owner.
|
||||||
*
|
*
|
||||||
* @param $thread_items Database statement with thread posts
|
* @param array $thread_items Database statement with thread posts
|
||||||
|
* @param boolean $pinned Is the item pinned?
|
||||||
|
*
|
||||||
* @return array items with parents and comments
|
* @return array items with parents and comments
|
||||||
*/
|
*/
|
||||||
function conversation_fetch_comments($thread_items) {
|
function conversation_fetch_comments($thread_items, $pinned) {
|
||||||
$comments = [];
|
$comments = [];
|
||||||
$parentlines = [];
|
$parentlines = [];
|
||||||
$lineno = 0;
|
$lineno = 0;
|
||||||
|
@ -822,6 +824,10 @@ function conversation_fetch_comments($thread_items) {
|
||||||
$parentlines[] = $lineno;
|
$parentlines[] = $lineno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($row['gravity'] == GRAVITY_PARENT) {
|
||||||
|
$row['pinned'] = $pinned;
|
||||||
|
}
|
||||||
|
|
||||||
$comments[] = $row;
|
$comments[] = $row;
|
||||||
$lineno++;
|
$lineno++;
|
||||||
}
|
}
|
||||||
|
@ -872,7 +878,7 @@ function conversation_add_children(array $parents, $block_authors, $order, $uid)
|
||||||
|
|
||||||
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
|
$thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
|
||||||
|
|
||||||
$comments = conversation_fetch_comments($thread_items);
|
$comments = conversation_fetch_comments($thread_items, $parent['pinned'] ?? false);
|
||||||
|
|
||||||
if (count($comments) != 0) {
|
if (count($comments) != 0) {
|
||||||
$items = array_merge($items, $comments);
|
$items = array_merge($items, $comments);
|
||||||
|
|
|
@ -148,11 +148,13 @@ class Item extends BaseObject
|
||||||
*
|
*
|
||||||
* @param integer $uid User ID
|
* @param integer $uid User ID
|
||||||
* @param array $selected Array of selected fields, empty for all
|
* @param array $selected Array of selected fields, empty for all
|
||||||
|
* @param array $condition Array of fields for condition
|
||||||
|
* @param array $params Array of several parameters
|
||||||
*
|
*
|
||||||
* @return boolean|object
|
* @return boolean|object
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function selectPinned(int $uid, array $selected = [])
|
public static function selectPinned(int $uid, array $selected = [], array $condition = [], $params = [])
|
||||||
{
|
{
|
||||||
$useritems = DBA::select('user-item', ['iid'], ['uid' => $uid, 'pinned' => true]);
|
$useritems = DBA::select('user-item', ['iid'], ['uid' => $uid, 'pinned' => true]);
|
||||||
if (!DBA::isResult($useritems)) {
|
if (!DBA::isResult($useritems)) {
|
||||||
|
@ -165,7 +167,25 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
DBA::close($useritems);
|
DBA::close($useritems);
|
||||||
|
|
||||||
return self::selectThreadForUser($uid, $selected, ['iid' => $pinned]);
|
if (empty($pinned)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($condition) || !is_array($condition)) {
|
||||||
|
$condition = ['iid' => $pinned];
|
||||||
|
} else {
|
||||||
|
reset($condition);
|
||||||
|
$first_key = key($condition);
|
||||||
|
if (!is_int($first_key)) {
|
||||||
|
$condition['iid'] = $pinned;
|
||||||
|
} else {
|
||||||
|
$values_string = substr(str_repeat("?, ", count($pinned)), 0, -2);
|
||||||
|
$condition[0] = '(' . $condition[0] . ") AND `iid` IN (" . $values_string . ")";
|
||||||
|
$condition = array_merge($condition, $pinned);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::selectThreadForUser($uid, $selected, $condition, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -350,7 +350,7 @@ class Profile extends BaseModule
|
||||||
$items = DBA::toArray($items_stmt);
|
$items = DBA::toArray($items_stmt);
|
||||||
|
|
||||||
if ($pager->getStart() == 0 && !empty($a->profile['profile_uid'])) {
|
if ($pager->getStart() == 0 && !empty($a->profile['profile_uid'])) {
|
||||||
$pinned_items = Item::selectPinned($a->profile['profile_uid'], ['uri']);
|
$pinned_items = Item::selectPinned($a->profile['profile_uid'], ['uri', 'pinned'], ['true' . $sql_extra]);
|
||||||
$pinned = Item::inArray($pinned_items);
|
$pinned = Item::inArray($pinned_items);
|
||||||
$items = array_merge($items, $pinned);
|
$items = array_merge($items, $pinned);
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,6 +193,8 @@ class Post extends BaseObject
|
||||||
if (DBA::isResult($parent)) {
|
if (DBA::isResult($parent)) {
|
||||||
$origin = $parent['origin'];
|
$origin = $parent['origin'];
|
||||||
}
|
}
|
||||||
|
} elseif ($item['pinned']) {
|
||||||
|
$pinned = L10n::t('pinned item');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
|
if ($origin && ($item['id'] != $item['parent']) && ($item['network'] == Protocol::ACTIVITYPUB)) {
|
||||||
|
@ -288,10 +290,6 @@ 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 = [
|
||||||
|
|
|
@ -1162,6 +1162,10 @@ input#dfrn-url {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
.pin-item {
|
||||||
|
margin-left: 10px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
.star-item {
|
.star-item {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -3201,6 +3205,8 @@ aside input[type='text'] {
|
||||||
.on { background-position: -144px -32px; }
|
.on { background-position: -144px -32px; }
|
||||||
|
|
||||||
.off { background-position: 0px -48px; }
|
.off { background-position: 0px -48px; }
|
||||||
|
.pinned { background-position: -16px -48px; }
|
||||||
|
.unpinned { background-position: -32px -48px; }
|
||||||
.starred { background-position: -16px -48px; }
|
.starred { background-position: -16px -48px; }
|
||||||
.unstarred { background-position: -32px -48px; }
|
.unstarred { background-position: -32px -48px; }
|
||||||
.tagged { background-position: -48px -48px; }
|
.tagged { background-position: -48px -48px; }
|
||||||
|
|
|
@ -120,8 +120,8 @@ as the value of $top_child_total (this is done at the end of this file)
|
||||||
|
|
||||||
{{if $item.pin}}
|
{{if $item.pin}}
|
||||||
<li role="menuitem">
|
<li role="menuitem">
|
||||||
<button type="button" id="pin-{{$item.id}}" onclick="dopin({{$item.id}});" class="btn-link {{$item.pin.classdo}}" title="{{$item.pin.do}}"><i class="fa fa-check-square-o" aria-hidden="true"></i> {{$item.pin.do}}</button>
|
<button type="button" id="pin-{{$item.id}}" onclick="dopin({{$item.id}});" class="btn-link {{$item.pin.classdo}}" title="{{$item.pin.do}}"><i class="fa fa-circle-o" aria-hidden="true"></i> {{$item.pin.do}}</button>
|
||||||
<button type="button" id="unpin-{{$item.id}}" onclick="dopin({{$item.id}});" class="btn-link {{$item.pin.classundo}}" title="{{$item.pin.undo}}"><i class="fa fa-check-square" aria-hidden="true"></i> {{$item.pin.undo}}</button>
|
<button type="button" id="unpin-{{$item.id}}" onclick="dopin({{$item.id}});" class="btn-link {{$item.pin.classundo}}" title="{{$item.pin.undo}}"><i class="fa fa-dot-circle-o" aria-hidden="true"></i> {{$item.pin.undo}}</button>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -1615,6 +1615,7 @@ ul .sidebar-group-li .icon {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pin-item,
|
||||||
.star-item,
|
.star-item,
|
||||||
.tag-item {
|
.tag-item {
|
||||||
float: left;
|
float: left;
|
||||||
|
@ -3990,6 +3991,15 @@ margin-left: 0px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
background-image: url("images/icons.png");
|
background-image: url("images/icons.png");
|
||||||
}
|
}
|
||||||
|
.pinned {
|
||||||
|
background-image: url("images/star.png");
|
||||||
|
repeat: no-repeat;
|
||||||
|
}
|
||||||
|
.unpinned {
|
||||||
|
background-image: url("images/premium.png");
|
||||||
|
repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
.starred {
|
.starred {
|
||||||
background-image: url("images/star.png");
|
background-image: url("images/star.png");
|
||||||
repeat: no-repeat;
|
repeat: no-repeat;
|
||||||
|
|
|
@ -124,8 +124,8 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $item.pin}}
|
{{if $item.pin}}
|
||||||
<a role="button" id="pin-{{$item.id}}" onclick="dopin({{$item.id}}); return false;" class="{{$item.pin.classdo}}" title="{{$item.pin.do}}"><i class="icon-pin icon-large"><span class="sr-only">{{$item.pin.do}}</span></i></a>
|
<a role="button" id="pin-{{$item.id}}" onclick="dopin({{$item.id}}); return false;" class="{{$item.pin.classdo}}" title="{{$item.pin.do}}"><i class="icon-circle icon-large"><span class="sr-only">{{$item.pin.do}}</span></i></a>
|
||||||
<a role="button" id="unpin-{{$item.id}}" onclick="dopin({{$item.id}}); return false;" class="{{$item.pin.classundo}}" title="{{$item.pin.undo}}"><i class="icon-pin-empty icon-large"><span class="sr-only">{{$item.pin.undo}}</span></i></a>
|
<a role="button" id="unpin-{{$item.id}}" onclick="dopin({{$item.id}}); return false;" class="{{$item.pin.classundo}}" title="{{$item.pin.undo}}"><i class="icon-remove-circle icon-large"><span class="sr-only">{{$item.pin.undo}}</span></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{if $item.star}}
|
{{if $item.star}}
|
||||||
<a role="button" id="star-{{$item.id}}" onclick="dostar({{$item.id}}); return false;" class="{{$item.star.classdo}}" title="{{$item.star.do}}"><i class="icon-star icon-large"><span class="sr-only">{{$item.star.do}}</span></i></a>
|
<a role="button" id="star-{{$item.id}}" onclick="dostar({{$item.id}}); return false;" class="{{$item.star.classdo}}" title="{{$item.star.do}}"><i class="icon-star icon-large"><span class="sr-only">{{$item.star.do}}</span></i></a>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user