}
// Currently only the order modes "received" and "commented" are in use
- if (isset(self::$max_id)) {
- switch (self::$order) {
- case 'received':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` < ?", self::$max_id]);
- break;
- case 'commented':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` < ?", self::$max_id]);
- break;
- case 'created':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` < ?", self::$max_id]);
- break;
- case 'uriid':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` < ?", self::$max_id]);
- break;
+ if (!empty(self::$item_uri_id)) {
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ['uri-id' => self::$item_uri_id]);
+ } else {
+ if (isset(self::$max_id)) {
+ switch (self::$order) {
+ case 'received':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` < ?", self::$max_id]);
+ break;
+ case 'commented':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` < ?", self::$max_id]);
+ break;
+ case 'created':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` < ?", self::$max_id]);
+ break;
+ case 'uriid':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` < ?", self::$max_id]);
+ break;
+ }
}
- }
- if (isset(self::$min_id)) {
- switch (self::$order) {
- case 'received':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` > ?", self::$min_id]);
- break;
- case 'commented':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` > ?", self::$min_id]);
- break;
- case 'created':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` > ?", self::$min_id]);
- break;
- case 'uriid':
- $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` > ?", self::$min_id]);
- break;
+ if (isset(self::$min_id)) {
+ switch (self::$order) {
+ case 'received':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` > ?", self::$min_id]);
+ break;
+ case 'commented':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` > ?", self::$min_id]);
+ break;
+ case 'created':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` > ?", self::$min_id]);
+ break;
+ case 'uriid':
+ $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` > ?", self::$min_id]);
+ break;
+ }
}
}
use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Database\Database;
+use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Module\Response;
/** @var int */
protected static $item_id;
/** @var int */
+ protected static $item_uri_id;
+ /** @var int */
protected static $itemsPerPage;
/** @var bool */
protected static $no_sharer;
*/
protected function parseRequest(array $request)
{
+ $this->logger->debug('Got request', $request);
self::$selectedTab = $this->parameters['content'] ?? '';
self::$accountTypeString = $request['accounttype'] ?? $this->parameters['accounttype'] ?? '';
);
}
+ if (!empty($request['item'])) {
+ $item = Post::selectFirst(['parent', 'parent-uri-id'], ['id' => $request['item']]);
+ self::$item_id = $item['parent'] ?? 0;
+ self::$item_uri_id = $item['parent-uri-id'] ?? 0;
+ } else {
+ self::$item_id = 0;
+ self::$item_uri_id = 0;
+ }
+
self::$min_id = $request['min_id'] ?? null;
self::$max_id = $request['max_id'] ?? null;
$condition = $this->addLanguageCondition($uid, $condition);
}
- $condition[0] .= " AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))";
- $condition[] = $uid;
+ $condition = DBA::mergeConditions($condition, ["NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))", $uid]);
if ((self::$selectedTab != TimelineEntity::WHATSHOT) && !is_null(self::$accountType)) {
- $condition[0] .= " AND `contact-type` = ?";
- $condition[] = self::$accountType;
+ $condition = DBA::mergeConditions($condition, ['contact-type' => self::$accountType]);
}
$params = ['order' => ['created' => true], 'limit' => self::$itemsPerPage];
- if (!empty(self::$item_id)) {
- $condition[0] .= " AND `uri-id` = ?";
- $condition[] = self::$item_id;
+ if (!empty(self::$item_uri_id)) {
+ $condition = DBA::mergeConditions($condition, ['uri-id' => self::$item_uri_id]);
} else {
if (self::$no_sharer) {
- $condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-engagement`.`uri-id`)";
- $condition[] = $uid;
+ $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-engagement`.`uri-id`)", $this->session->getLocalUserId()]);
}
if (isset(self::$max_id)) {
- $condition[0] .= " AND `created` < ?";
- $condition[] = self::$max_id;
+ $condition = DBA::mergeConditions($condition, ["`created` < ?", self::$max_id]);
}
if (isset(self::$min_id)) {
- $condition[0] .= " AND `created` > ?";
- $condition[] = self::$min_id;
+ $condition = DBA::mergeConditions($condition, ["`created` > ?", self::$min_id]);
// Previous page case: we want the items closest to min_id but for that we need to reverse the query order
if (!isset(self::$max_id)) {
}
// Previous page case: once we get the relevant items closest to min_id, we need to restore the expected display order
- if (empty(self::$item_id) && isset(self::$min_id) && !isset(self::$max_id)) {
+ if (empty(self::$item_uri_id) && isset(self::$min_id) && !isset(self::$max_id)) {
$items = array_reverse($items);
}
$params = ['order' => ['commented' => true], 'limit' => self::$itemsPerPage];
- if (!empty(self::$item_id)) {
- $condition[0] .= " AND `id` = ?";
- $condition[] = self::$item_id;
+ if (!empty(self::$item_uri_id)) {
+ $condition = DBA::mergeConditions($condition, ['uri-id' => self::$item_uri_id]);
} else {
if ($this->session->getLocalUserId() && self::$no_sharer) {
- $condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-thread-user-view`.`uri-id`)";
- $condition[] = $this->session->getLocalUserId();
+ $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-thread-user-view`.`uri-id`)", $this->session->getLocalUserId()]);
}
if (isset(self::$max_id)) {
- $condition[0] .= " AND `commented` < ?";
- $condition[] = self::$max_id;
+ $condition = DBA::mergeConditions($condition, ["`commented` < ?", self::$max_id]);
}
if (isset(self::$min_id)) {
- $condition[0] .= " AND `commented` > ?";
- $condition[] = self::$min_id;
+ $condition = DBA::mergeConditions($condition, ["`commented` > ?", self::$min_id]);
// Previous page case: we want the items closest to min_id but for that we need to reverse the query order
if (!isset(self::$max_id)) {
}
// Previous page case: once we get the relevant items closest to min_id, we need to restore the expected display order
- if (empty(self::$item_id) && isset(self::$min_id) && !isset(self::$max_id)) {
+ if (empty(self::$item_uri_id) && isset(self::$min_id) && !isset(self::$max_id)) {
$items = array_reverse($items);
}