mirror of
https://github.com/friendica/friendica
synced 2025-04-26 15:50:10 +00:00
Merge pull request #10861 from annando/no-q
Replace the legacy function "unavailableNetworks"
This commit is contained in:
commit
f05faf22a1
4 changed files with 26 additions and 128 deletions
|
@ -92,11 +92,13 @@ class Widget
|
|||
|
||||
/**
|
||||
* Return unavailable networks as array
|
||||
*
|
||||
* @return array Unsupported networks
|
||||
*/
|
||||
public static function unavailableNetworksAsArray()
|
||||
public static function unavailableNetworks()
|
||||
{
|
||||
// Always hide content from these networks
|
||||
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET];
|
||||
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::ZOT];
|
||||
|
||||
if (!Addon::isEnabled("discourse")) {
|
||||
$networks[] = Protocol::DISCOURSE;
|
||||
|
@ -128,24 +130,6 @@ class Widget
|
|||
return $networks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unavailable networks
|
||||
*/
|
||||
public static function unavailableNetworks()
|
||||
{
|
||||
$networks = self::unavailableNetworksAsArray();
|
||||
|
||||
if (!sizeof($networks)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$network_filter = implode("','", $networks);
|
||||
|
||||
$network_filter = "AND `network` NOT IN ('$network_filter')";
|
||||
|
||||
return $network_filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a generic filter widget based on a list of options
|
||||
*
|
||||
|
@ -274,11 +258,11 @@ class Widget
|
|||
return '';
|
||||
}
|
||||
|
||||
$extra_sql = self::unavailableNetworks();
|
||||
$networks = self::unavailableNetworks();
|
||||
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
|
||||
$condition = array_merge([$query], array_merge([local_user()], $networks));
|
||||
|
||||
$r = DBA::p("SELECT `network` FROM `contact` WHERE `uid` = ? AND NOT `deleted` AND `network` != '' $extra_sql GROUP BY `network` ORDER BY `network`",
|
||||
local_user()
|
||||
);
|
||||
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
|
||||
|
||||
$nets = array();
|
||||
while ($rr = DBA::fetch($r)) {
|
||||
|
@ -525,7 +509,7 @@ class Widget
|
|||
/**
|
||||
* Display the account types sidebar
|
||||
* The account type value is added as a parameter to the url
|
||||
*
|
||||
*
|
||||
* @param string $base Basepath
|
||||
* @param int $accounttype Acount type
|
||||
* @return string
|
||||
|
|
|
@ -664,42 +664,25 @@ class Contact extends BaseModule
|
|||
}
|
||||
|
||||
if ($group) {
|
||||
$sql_extra = " AND EXISTS(SELECT `id` FROM `group_member` WHERE `gid` = ? AND `contact`.`id` = `contact-id`)";
|
||||
$sql_extra .= " AND EXISTS(SELECT `id` FROM `group_member` WHERE `gid` = ? AND `contact`.`id` = `contact-id`)";
|
||||
$sql_values[] = $group;
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$stmt = DBA::p("SELECT COUNT(*) AS `total`
|
||||
FROM `contact`
|
||||
WHERE `uid` = ?
|
||||
AND `self` = 0
|
||||
AND NOT `deleted`
|
||||
$sql_extra
|
||||
" . Widget::unavailableNetworks(),
|
||||
$sql_values
|
||||
);
|
||||
if (DBA::isResult($stmt)) {
|
||||
$total = DBA::fetch($stmt)['total'];
|
||||
}
|
||||
DBA::close($stmt);
|
||||
$networks = Widget::unavailableNetworks();
|
||||
$sql_extra .= " AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
|
||||
$sql_values = array_merge($sql_values, $networks);
|
||||
|
||||
$condition = ["`uid` = ? AND NOT `self` AND NOT `deleted`" . $sql_extra];
|
||||
$condition = array_merge($condition, $sql_values);
|
||||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$sql_values[] = $pager->getStart();
|
||||
$sql_values[] = $pager->getItemsPerPage();
|
||||
|
||||
$contacts = [];
|
||||
|
||||
$stmt = DBA::p("SELECT *
|
||||
FROM `contact`
|
||||
WHERE `uid` = ?
|
||||
AND `self` = 0
|
||||
AND NOT `deleted`
|
||||
$sql_extra
|
||||
ORDER BY `name` ASC
|
||||
LIMIT ?, ?",
|
||||
$sql_values
|
||||
);
|
||||
$stmt = DBA::select('contact', [], $condition, ['order' => ['name'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
|
||||
|
||||
while ($contact = DBA::fetch($stmt)) {
|
||||
$contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], local_user());
|
||||
$contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], local_user());
|
||||
|
|
|
@ -130,20 +130,22 @@ class Acl extends BaseModule
|
|||
$group_count = DBA::count('group', $condition_group);
|
||||
}
|
||||
|
||||
$networks = Widget::unavailableNetworksAsArray();
|
||||
if (!empty($networks)) {
|
||||
$condition = DBA::mergeConditions($condition, array_merge(["NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"], $networks));
|
||||
}
|
||||
$networks = Widget::unavailableNetworks();
|
||||
$condition = DBA::mergeConditions($condition, array_merge(["NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"], $networks));
|
||||
|
||||
switch ($type) {
|
||||
case self::TYPE_MENTION_CONTACT_GROUP:
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND NOT `network` IN (?, ?)", '', Protocol::OSTATUS, Protocol::STATUSNET
|
||||
]);
|
||||
break;
|
||||
|
||||
case self::TYPE_MENTION_CONTACT:
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND `network` != ?", '', Protocol::STATUSNET
|
||||
]);
|
||||
break;
|
||||
|
||||
case self::TYPE_MENTION_FORUM:
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["NOT `self` AND NOT `blocked` AND `notify` != ? AND `contact-type` = ?", '', Contact::TYPE_COMMUNITY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue