protected static $itemsPerPage;
protected static $since_id;
protected static $max_id;
+ protected static $item_id;
public static function content(array $parameters = [])
{
self::$since_id = $_GET['since_id'] ?? null;
self::$max_id = $_GET['max_id'] ?? null;
self::$max_id = $_GET['last_commented'] ?? self::$max_id;
+ self::$item_id = $_GET['item'] ?? null;
}
/**
*/
protected static function getItems()
{
- $items = self::selectItems(self::$since_id, self::$max_id, self::$itemsPerPage);
+ $items = self::selectItems(self::$since_id, self::$max_id, self::$item_id, self::$itemsPerPage);
$maxpostperauthor = (int) DI::config()->get('system', 'max_author_posts_community_page');
if ($maxpostperauthor != 0 && self::$content == 'local') {
self::$max_id = $items[count($items) - 1]['commented'];
}
- $items = self::selectItems(self::$since_id, self::$max_id, self::$itemsPerPage);
+ $items = self::selectItems(self::$since_id, self::$max_id, self::$item_id, self::$itemsPerPage);
}
} else {
$selected_items = $items;
* @throws \Exception
* @TODO Move to repository/factory
*/
- private static function selectItems($since_id, $max_id, $itemspage)
+ private static function selectItems($since_id, $max_id, $item_id, $itemspage)
{
$r = false;
return [];
}
- if (local_user() && !empty($_REQUEST['no_sharer'])) {
- $condition[0] .= " AND NOT EXISTS (SELECT `uri-id` FROM `thread` AS t1 WHERE `t1`.`uri-id` = `thread`.`uri-id` AND `t1`.`uid` = ?)";
- $condition[] = local_user();
- }
-
- if (isset($max_id)) {
- $condition[0] .= " AND `commented` < ?";
- $condition[] = $max_id;
- }
+ if (isset($item_id)) {
+ $condition[0] .= " AND `iid` = ?";
+ $condition[] = $item_id;
+ } else {
+ if (local_user() && !empty($_REQUEST['no_sharer'])) {
+ $condition[0] .= " AND NOT EXISTS (SELECT `uri-id` FROM `thread` AS t1 WHERE `t1`.`uri-id` = `thread`.`uri-id` AND `t1`.`uid` = ?)";
+ $condition[] = local_user();
+ }
+
+ if (isset($max_id)) {
+ $condition[0] .= " AND `commented` < ?";
+ $condition[] = $max_id;
+ }
- if (isset($since_id)) {
- $condition[0] .= " AND `commented` > ?";
- $condition[] = $since_id;
+ if (isset($since_id)) {
+ $condition[0] .= " AND `commented` > ?";
+ $condition[] = $since_id;
+ }
}
$r = Item::selectThreadForUser(0, ['uri', 'commented', 'author-link'], $condition, ['order' => ['commented' => true], 'limit' => $itemspage]);