The fetch function now centrally controls the content
This commit is contained in:
parent
62a61a95d3
commit
b03db4643f
|
@ -2078,7 +2078,7 @@ function api_statuses_mentions($type)
|
||||||
$start = ($page - 1) * $count;
|
$start = ($page - 1) * $count;
|
||||||
|
|
||||||
$condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ? AND `author-id` != ?
|
$condition = ["`uid` = ? AND `verb` = ? AND `item`.`id` > ? AND `author-id` != ?
|
||||||
AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `uid` = ? AND `mention` AND NOT `ignored`)",
|
AND `item`.`parent` IN (SELECT `iid` FROM `thread` WHERE `thread`.`uid` = ? AND `thread`.`mention` AND NOT `thread`.`ignored`)",
|
||||||
api_user(), ACTIVITY_POST, $since_id, $user_info['pid'], api_user()];
|
api_user(), ACTIVITY_POST, $since_id, $user_info['pid'], api_user()];
|
||||||
|
|
||||||
if ($max_id > 0) {
|
if ($max_id > 0) {
|
||||||
|
|
|
@ -562,15 +562,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['network'] == NETWORK_FEED) {
|
$profile_name = $item['author-name'];
|
||||||
$item['author-avatar'] = $item['contact-avatar'];
|
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
||||||
$item['author-name'] = $item['contact-name'];
|
|
||||||
$item['owner-avatar'] = $item['contact-avatar'];
|
|
||||||
$item['owner-name'] = $item['contact-name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$profile_name = (strlen($item['author-name']) ? $item['author-name'] : $item['name']);
|
|
||||||
if ($item['author-link'] && !$item['author-name']) {
|
|
||||||
$profile_name = $item['author-link'];
|
$profile_name = $item['author-link'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ function acl_content(App $a)
|
||||||
$params = ['order' => ['author-name' => true]];
|
$params = ['order' => ['author-name' => true]];
|
||||||
$authors = Item::selectForUser(local_user(), ['author-link'], $condition, $params);
|
$authors = Item::selectForUser(local_user(), ['author-link'], $condition, $params);
|
||||||
$item_authors = [];
|
$item_authors = [];
|
||||||
while ($author = dba::fetch($authors)) {
|
while ($author = Item::fetch($authors)) {
|
||||||
$item_authors[$author['author-link']] = $author['author-link'];
|
$item_authors[$author['author-link']] = $author['author-link'];
|
||||||
}
|
}
|
||||||
dba::close($authors);
|
dba::close($authors);
|
||||||
|
|
|
@ -347,7 +347,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
||||||
Item::update(['unseen' => false], $condition);
|
Item::update(['unseen' => false], $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = conv_sort(dba::inArray($items_obj), "`commented`");
|
$items = conv_sort(Item::inArray($items_obj), "`commented`");
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
|
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
|
||||||
|
|
|
@ -456,7 +456,7 @@ function networkFlatView(App $a, $update = 0)
|
||||||
|
|
||||||
$params = ['order' => ['id' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
$params = ['order' => ['id' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||||
$result = Item::selectForUser(local_user(), [], $condition, $params);
|
$result = Item::selectForUser(local_user(), [], $condition, $params);
|
||||||
$items = dba::inArray($result);
|
$items = Item::inArray($result);
|
||||||
|
|
||||||
$condition = ['unseen' => true, 'uid' => local_user()];
|
$condition = ['unseen' => true, 'uid' => local_user()];
|
||||||
networkSetSeen($condition);
|
networkSetSeen($condition);
|
||||||
|
|
|
@ -73,7 +73,7 @@ function notes_content(App $a, $update = false)
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$parents_arr = [];
|
$parents_arr = [];
|
||||||
|
|
||||||
while ($rr = dba::fetch($r)) {
|
while ($rr = Item::fetch($r)) {
|
||||||
$parents_arr[] = $rr['item_id'];
|
$parents_arr[] = $rr['item_id'];
|
||||||
}
|
}
|
||||||
dba::close($r);
|
dba::close($r);
|
||||||
|
@ -81,7 +81,7 @@ function notes_content(App $a, $update = false)
|
||||||
$condition = ['uid' => local_user(), 'parent' => $parents_arr];
|
$condition = ['uid' => local_user(), 'parent' => $parents_arr];
|
||||||
$result = Item::selectForUser(local_user(), [], $condition);
|
$result = Item::selectForUser(local_user(), [], $condition);
|
||||||
if (DBM::is_result($result)) {
|
if (DBM::is_result($result)) {
|
||||||
$items = conv_sort(dba::inArray($result), 'commented');
|
$items = conv_sort(Item::inArray($result), 'commented');
|
||||||
$o .= conversation($a, $items, 'notes', $update);
|
$o .= conversation($a, $items, 'notes', $update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ function ping_init(App $a)
|
||||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||||
|
|
||||||
if (DBM::is_result($items)) {
|
if (DBM::is_result($items)) {
|
||||||
$items_unseen = dba::inArray($items);
|
$items_unseen = Item::inArray($items);
|
||||||
$arr = ['items' => $items_unseen];
|
$arr = ['items' => $items_unseen];
|
||||||
Addon::callHooks('network_ping', $arr);
|
Addon::callHooks('network_ping', $arr);
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ function profile_content(App $a, $update = 0)
|
||||||
|
|
||||||
$condition = ['uid' => $a->profile['profile_uid'], 'parent' => $parents_arr];
|
$condition = ['uid' => $a->profile['profile_uid'], 'parent' => $parents_arr];
|
||||||
$result = Item::selectForUser($a->profile['profile_uid'], [], $condition);
|
$result = Item::selectForUser($a->profile['profile_uid'], [], $condition);
|
||||||
$items = conv_sort(dba::inArray($result), 'created');
|
$items = conv_sort(Item::inArray($result), 'created');
|
||||||
} else {
|
} else {
|
||||||
$items = [];
|
$items = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ function search_content(App $a) {
|
||||||
if (!empty($itemids)) {
|
if (!empty($itemids)) {
|
||||||
$params = ['order' => ['id' => true]];
|
$params = ['order' => ['id' => true]];
|
||||||
$items = Item::selectForUser(local_user(), [], ['id' => $itemids], $params);
|
$items = Item::selectForUser(local_user(), [], ['id' => $itemids], $params);
|
||||||
$r = dba::inArray($items);
|
$r = Item::inArray($items);
|
||||||
} else {
|
} else {
|
||||||
$r = [];
|
$r = [];
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ function search_content(App $a) {
|
||||||
$params = ['order' => ['id' => true],
|
$params = ['order' => ['id' => true],
|
||||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||||
$items = Item::selectForUser(local_user(), [], $condition, $params);
|
$items = Item::selectForUser(local_user(), [], $condition, $params);
|
||||||
$r = dba::inArray($items);
|
$r = Item::inArray($items);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ function starred_init(App $a) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = Item::selectForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $message_id]);
|
$item = Item::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $message_id]);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBM::is_result($item)) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,7 +410,7 @@ class NotificationsManager extends BaseObject
|
||||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||||
|
|
||||||
if (DBM::is_result($items)) {
|
if (DBM::is_result($items)) {
|
||||||
$notifs = $this->formatNotifs(dba::inArray($items), $ident);
|
$notifs = $this->formatNotifs(Item::inArray($items), $ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = [
|
$arr = [
|
||||||
|
@ -495,7 +495,7 @@ class NotificationsManager extends BaseObject
|
||||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||||
|
|
||||||
if (DBM::is_result($items)) {
|
if (DBM::is_result($items)) {
|
||||||
$notifs = $this->formatNotifs(dba::inArray($items), $ident);
|
$notifs = $this->formatNotifs(Item::inArray($items), $ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = [
|
$arr = [
|
||||||
|
@ -535,7 +535,7 @@ class NotificationsManager extends BaseObject
|
||||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||||
|
|
||||||
if (DBM::is_result($items)) {
|
if (DBM::is_result($items)) {
|
||||||
$notifs = $this->formatNotifs(dba::inArray($items), $ident);
|
$notifs = $this->formatNotifs(Item::inArray($items), $ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
$arr = [
|
$arr = [
|
||||||
|
|
|
@ -1070,7 +1070,7 @@ class Contact extends BaseObject
|
||||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||||
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
||||||
|
|
||||||
$items = dba::inArray($r);
|
$items = Item::inArray($r);
|
||||||
|
|
||||||
$o = conversation($a, $items, 'contact-posts', false);
|
$o = conversation($a, $items, 'contact-posts', false);
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,15 @@ require_once 'include/text.php';
|
||||||
class Item extends BaseObject
|
class Item extends BaseObject
|
||||||
{
|
{
|
||||||
// Field list that is used to display the items
|
// Field list that is used to display the items
|
||||||
const DISPLAY_FIELDLIST = ['uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid',
|
const DISPLAY_FIELDLIST = ['uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid', 'network',
|
||||||
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
|
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
|
||||||
'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'attach',
|
'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'attach',
|
||||||
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
|
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
|
||||||
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id',
|
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id',
|
||||||
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
|
'author-id', 'author-link', 'author-name', 'author-avatar',
|
||||||
'owner-id', 'owner-link', 'owner-name', 'owner-avatar',
|
'owner-id', 'owner-link', 'owner-name', 'owner-avatar',
|
||||||
'contact-id', 'contact-link', 'contact-name', 'contact-avatar',
|
'contact-id', 'contact-link', 'contact-name', 'contact-avatar',
|
||||||
'network', 'url', 'name', 'writable', 'self', 'cid', 'alias',
|
'writable', 'self', 'cid', 'alias',
|
||||||
'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
|
'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
|
||||||
'event-summary', 'event-desc', 'event-location', 'event-type',
|
'event-summary', 'event-desc', 'event-location', 'event-type',
|
||||||
'event-nofinish', 'event-adjust', 'event-ignore', 'event-id'];
|
'event-nofinish', 'event-adjust', 'event-ignore', 'event-id'];
|
||||||
|
@ -66,6 +66,33 @@ class Item extends BaseObject
|
||||||
{
|
{
|
||||||
$row = dba::fetch($stmt);
|
$row = dba::fetch($stmt);
|
||||||
|
|
||||||
|
// We prefer the data from the user's contact over the public one
|
||||||
|
if (!empty($row['author-link']) && !empty($row['contact-link']) &&
|
||||||
|
($row['author-link'] == $row['contact-link'])) {
|
||||||
|
if (isset($row['author-avatar']) && !empty($row['contact-avatar'])) {
|
||||||
|
$row['author-avatar'] = $row['contact-avatar'];
|
||||||
|
}
|
||||||
|
if (isset($row['author-name']) && !empty($row['contact-name'])) {
|
||||||
|
$row['author-name'] = $row['contact-name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($row['owner-link']) && !empty($row['contact-link']) &&
|
||||||
|
($row['owner-link'] == $row['contact-link'])) {
|
||||||
|
if (isset($row['owner-avatar']) && !empty($row['contact-avatar'])) {
|
||||||
|
$row['owner-avatar'] = $row['contact-avatar'];
|
||||||
|
}
|
||||||
|
if (isset($row['owner-name']) && !empty($row['contact-name'])) {
|
||||||
|
$row['owner-name'] = $row['contact-name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We can always comment on posts from these networks
|
||||||
|
if (isset($row['writable']) && !empty($row['network']) &&
|
||||||
|
in_array($row['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
|
||||||
|
$row['writable'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,14 +361,14 @@ class Item extends BaseObject
|
||||||
'id' => 'item_id', 'network'];
|
'id' => 'item_id', 'network'];
|
||||||
|
|
||||||
$fields['author'] = ['url' => 'author-link', 'name' => 'author-name',
|
$fields['author'] = ['url' => 'author-link', 'name' => 'author-name',
|
||||||
'thumb' => 'author-avatar', 'nick' => 'author-nick', 'network' => 'author-network'];
|
'thumb' => 'author-avatar', 'nick' => 'author-nick'];
|
||||||
|
|
||||||
$fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name',
|
$fields['owner'] = ['url' => 'owner-link', 'name' => 'owner-name',
|
||||||
'thumb' => 'owner-avatar', 'nick' => 'owner-nick', 'network' => 'owner-network'];
|
'thumb' => 'owner-avatar', 'nick' => 'owner-nick'];
|
||||||
|
|
||||||
$fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
|
$fields['contact'] = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
|
||||||
'url', 'name', 'writable', 'self', 'id' => 'cid', 'alias', 'uid' => 'contact-uid',
|
'writable', 'self', 'id' => 'cid', 'alias', 'uid' => 'contact-uid',
|
||||||
'photo', 'name-date', 'uri-date', 'avatar-date', 'thumb', 'dfrn-id', 'network' => 'contact-network'];
|
'photo', 'name-date', 'uri-date', 'avatar-date', 'thumb', 'dfrn-id'];
|
||||||
|
|
||||||
$fields['parent-item'] = ['guid' => 'parent-guid', 'network' => 'parent-network'];
|
$fields['parent-item'] = ['guid' => 'parent-guid', 'network' => 'parent-network'];
|
||||||
|
|
||||||
|
@ -1126,8 +1153,9 @@ class Item extends BaseObject
|
||||||
$user = dba::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
|
$user = dba::selectFirst('user', ['nickname'], ['uid' => $item['uid']]);
|
||||||
if (DBM::is_result($user)) {
|
if (DBM::is_result($user)) {
|
||||||
$self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']);
|
$self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']);
|
||||||
logger("'myself' is ".$self." for parent ".$parent_id." checking against ".$item['author-link']." and ".$item['owner-link'], LOGGER_DEBUG);
|
$self_id = Contact::getIdForURL($self, 0, true);
|
||||||
if ((normalise_link($item['author-link']) == $self) || (normalise_link($item['owner-link']) == $self)) {
|
logger("'myself' is ".$self_id." for parent ".$parent_id." checking against ".$item['author-id']." and ".$item['owner-id'], LOGGER_DEBUG);
|
||||||
|
if (($item['author-id'] == $self_id) || ($item['owner-id'] == $self_id)) {
|
||||||
dba::update('thread', ['mention' => true], ['iid' => $parent_id]);
|
dba::update('thread', ['mention' => true], ['iid' => $parent_id]);
|
||||||
logger("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
logger("tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,16 +198,8 @@ class Post extends BaseObject
|
||||||
|
|
||||||
$filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
|
$filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
|
||||||
|
|
||||||
if ($item['network'] == NETWORK_FEED) {
|
$profile_name = htmlentities($item['author-name']);
|
||||||
$item['author-avatar'] = $item['contact-avatar'];
|
if (!empty($item['author-link']) && empty($item['author-name'])) {
|
||||||
$item['author-name'] = $item['contact-name'];
|
|
||||||
$item['owner-avatar'] = $item['contact-avatar'];
|
|
||||||
$item['owner-name'] = $item['contact-name'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$diff_author = !link_compare($item['url'], $item['author-link']);
|
|
||||||
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
|
|
||||||
if ($item['author-link'] && (!$item['author-name'])) {
|
|
||||||
$profile_name = $item['author-link'];
|
$profile_name = $item['author-link'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user