Merge pull request #8975 from MrPetovan/task/8918-move-mod-common

Move mod/common.php to src/ Part 2: Add Module\Profile\Common class
This commit is contained in:
Michael Vogel 2020-08-05 23:17:12 +02:00 committed by GitHub
commit 1fb47b96aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 258 additions and 140 deletions

View file

@ -431,7 +431,7 @@ class Relation
* @return array
* @throws Exception
*/
public static function listCommon(int $sourceId, int $targetId, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
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`)
@ -439,7 +439,7 @@ class Relation
$sourceId, $targetId]
);
return DI::dba()->selectToArray('contact', $fields, $condition,
return DI::dba()->selectToArray('contact', [], $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
}
@ -470,7 +470,6 @@ class Relation
*
* @param int $sourceId Public contact id
* @param int $targetId Public contact id
* @param array $field Field list
* @param array $condition Additional condition array on the contact table
* @param int $count
* @param int $offset
@ -478,7 +477,7 @@ class Relation
* @return array
* @throws Exception
*/
public static function listCommonFollows(int $sourceId, int $targetId, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
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`)
@ -486,7 +485,7 @@ class Relation
$sourceId, $targetId]
);
return DI::dba()->selectToArray('contact', $fields, $condition,
return DI::dba()->selectToArray('contact', [], $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
}
@ -516,7 +515,6 @@ class Relation
*
* @param int $sourceId Public contact id
* @param int $targetId Public contact id
* @param array $field Field list
* @param array $condition Additional condition on the contact table
* @param int $count
* @param int $offset
@ -524,7 +522,7 @@ class Relation
* @return array
* @throws Exception
*/
public static function listCommonFollowers(int $sourceId, int $targetId, array $fields = [], array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
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`)
@ -532,7 +530,7 @@ class Relation
$sourceId, $targetId]
);
return DI::dba()->selectToArray('contact', $fields, $condition,
return DI::dba()->selectToArray('contact', [], $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'name' : 'RAND()']]
);
}

View file

@ -46,7 +46,7 @@ class GContact
$sourceId,
];
return Contact\Relation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, [], $condition);
return Contact\Relation::countCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition);
}
/**
@ -74,7 +74,7 @@ LIMIT 1",
$sourceId,
];
return Contact\Relation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0, [], $condition);
return Contact\Relation::countCommonFollowers($sourceId, $targetPublicContact['id'] ?? 0, $condition);
}
/**
@ -100,7 +100,7 @@ LIMIT 1",
$sourceId,
];
return Contact\Relation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, [], $condition, $limit, $start, $shuffle);
return Contact\Relation::listCommonFollows($sourceId, $targetIds['public'] ?? 0, $condition, $limit, $start, $shuffle);
}
/**
@ -134,6 +134,6 @@ LIMIT 1",
$sourceId,
];
return Contact\Relation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, [], $condition, $limit, $start, $shuffle);
return Contact\Relation::listCommonFollows($sourceId, $targetPublicContact['id'] ?? 0, $condition, $limit, $start, $shuffle);
}
}