"Allfriends" now work again
This commit is contained in:
parent
a36d305984
commit
14bb6daa5d
|
@ -26,6 +26,8 @@ use Friendica\Core\Logger;
|
|||
use Friendica\Core\Protocol;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -218,12 +220,8 @@ class Relation
|
|||
public static function countFollows(int $cid, array $condition = [])
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)', $cid]
|
||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
||||
$cid]
|
||||
);
|
||||
|
||||
return DI::dba()->count('contact', $condition);
|
||||
|
@ -243,24 +241,13 @@ class Relation
|
|||
public static function listFollows(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)', $cid]
|
||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
||||
$cid]
|
||||
);
|
||||
|
||||
$follows = DI::dba()->selectToArray(
|
||||
'contact',
|
||||
$condition,
|
||||
[
|
||||
'limit' => [$offset, $count],
|
||||
'order' => [$shuffle ? 'RAND()' : 'name']
|
||||
]
|
||||
return DI::dba()->selectToArray('contact', [], $condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||
);
|
||||
|
||||
return $follows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,12 +261,8 @@ class Relation
|
|||
public static function countFollowers(int $cid, array $condition = [])
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `relation-cid` = ?
|
||||
AND `follows`
|
||||
)', $cid]
|
||||
['`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)',
|
||||
$cid]
|
||||
);
|
||||
|
||||
return DI::dba()->count('contact', $condition);
|
||||
|
@ -299,21 +282,11 @@ class Relation
|
|||
public static function listFollowers(int $cid, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `relation-cid` = ?
|
||||
AND `follows`
|
||||
)', $cid]
|
||||
['`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)', $cid]
|
||||
);
|
||||
|
||||
$followers = DI::dba()->selectToArray(
|
||||
'contact',
|
||||
$condition,
|
||||
[
|
||||
'limit' => [$offset, $count],
|
||||
'order' => [$shuffle ? 'RAND()' : 'name']
|
||||
]
|
||||
$followers = DI::dba()->selectToArray('contact', [], $condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
|
||||
);
|
||||
|
||||
return $followers;
|
||||
|
@ -332,16 +305,9 @@ class Relation
|
|||
public static function countCommon(int $sourceId, int $targetId, array $condition = [])
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
)
|
||||
AND `id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
)', $sourceId, $targetId]
|
||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)
|
||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)',
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
$total = DI::dba()->count('contact', $condition);
|
||||
|
@ -365,27 +331,13 @@ class Relation
|
|||
public static function listCommon(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)
|
||||
AND `id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)", $sourceId, $targetId]
|
||||
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
$contacts = DI::dba()->selectToArray(
|
||||
'contact',
|
||||
$condition,
|
||||
[
|
||||
'limit' => [$offset, $count],
|
||||
'order' => [$shuffle ? 'name' : 'RAND()'],
|
||||
]
|
||||
$contacts = DI::dba()->selectToArray('contact', [], $condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
|
||||
);
|
||||
|
||||
return $contacts;
|
||||
|
@ -404,18 +356,9 @@ class Relation
|
|||
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = [])
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)
|
||||
AND `id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)', $sourceId, $targetId]
|
||||
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
$total = DI::dba()->count('contact', $condition);
|
||||
|
@ -438,27 +381,13 @@ class Relation
|
|||
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)
|
||||
AND `id` IN (
|
||||
SELECT `relation-cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `cid` = ?
|
||||
AND `follows`
|
||||
)", $sourceId, $targetId]
|
||||
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
$contacts = DI::dba()->selectToArray(
|
||||
'contact',
|
||||
$condition,
|
||||
[
|
||||
'limit' => [$offset, $count],
|
||||
'order' => [$shuffle ? 'name' : 'RAND()'],
|
||||
]
|
||||
$contacts = DI::dba()->selectToArray('contact', [], $condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
|
||||
);
|
||||
|
||||
return $contacts;
|
||||
|
@ -476,23 +405,12 @@ class Relation
|
|||
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = [])
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
['`id` IN (
|
||||
SELECT `cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `relation-cid` = ?
|
||||
AND `follows`
|
||||
)
|
||||
AND `id` IN (
|
||||
SELECT `cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `relation-cid` = ?
|
||||
AND `follows`
|
||||
)', $sourceId, $targetId]
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
$total = DI::dba()->count('contact', $condition);
|
||||
|
||||
return $total;
|
||||
return DI::dba()->count('contact', $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -510,29 +428,13 @@ class Relation
|
|||
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
|
||||
{
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["`id` IN (
|
||||
SELECT `cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `relation-cid` = ?
|
||||
AND `follows`
|
||||
)
|
||||
AND `id` IN (
|
||||
SELECT `cid`
|
||||
FROM `contact-relation`
|
||||
WHERE `relation-cid` = ?
|
||||
AND `follows`
|
||||
)", $sourceId, $targetId]
|
||||
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
|
||||
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
|
||||
$sourceId, $targetId]
|
||||
);
|
||||
|
||||
$contacts = DI::dba()->selectToArray(
|
||||
'contact',
|
||||
$condition,
|
||||
[
|
||||
'limit' => [$offset, $count],
|
||||
'order' => [$shuffle ? 'name' : 'RAND()'],
|
||||
]
|
||||
return DI::dba()->selectToArray('contact', [], $condition,
|
||||
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
|
||||
);
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,20 +54,20 @@ class AllFriends extends BaseModule
|
|||
|
||||
$uid = $app->user['uid'];
|
||||
|
||||
$contact = Model\Contact::getById($cid, ['name', 'url', 'photo', 'uid', 'id']);
|
||||
$contact = Model\Contact::getById($cid, []);
|
||||
|
||||
if (empty($contact)) {
|
||||
throw new HTTPException\BadRequestException(DI::l10n()->t('Invalid contact.'));
|
||||
}
|
||||
|
||||
DI::page()['aside'] = "";
|
||||
Model\Profile::load($app, "", Model\Contact::getByURL($contact["url"], false));
|
||||
Model\Profile::load($app, "", $contact);
|
||||
|
||||
$total = Model\Contact\Relation::countFollows($cid);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$friends = Model\Contact\Relation::listFollows($cid, [], $pager->getStart(), $pager->getItemsPerPage());
|
||||
$friends = Model\Contact\Relation::listFollows($cid, [], $pager->getItemsPerPage(), $pager->getStart());
|
||||
if (empty($friends)) {
|
||||
return DI::l10n()->t('No friends to display.');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue