Merge pull request #5964 from annando/item-thread

Use item class instead of direct call
This commit is contained in:
Hypolite Petovan 2018-10-18 23:52:40 -04:00 committed by GitHub
commit ee5f86d836
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item;
function community_init(App $a) function community_init(App $a)
{ {
@ -227,19 +228,12 @@ function community_getitems($start, $itemspage, $content, $accounttype)
return DBA::toArray($r); return DBA::toArray($r);
} elseif ($content == 'global') { } elseif ($content == 'global') {
if (!is_null($accounttype)) { if (!is_null($accounttype)) {
$sql_accounttype = " AND `owner`.`contact-type` = ?"; $condition = ["`uid` = ? AND `owner`.`contact-type` = ?", 0, $accounttype];
$values = [$accounttype, $start, $itemspage];
} else { } else {
$sql_accounttype = ""; $condition = ['uid' => 0];
$values = [$start, $itemspage];
} }
$r = DBA::p("SELECT `uri` FROM `thread` $r = Item::selectThreadForUser(0, ['uri'], $condition, ['order' => ['commented' => true], 'limit' => [$start, $itemspage]]);
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
INNER JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
INNER JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`
WHERE `thread`.`uid` = 0 AND NOT `author`.`hidden` AND NOT `author`.`blocked` $sql_accounttype
ORDER BY `thread`.`commented` DESC LIMIT ?, ?", $values);
return DBA::toArray($r); return DBA::toArray($r);
} }