X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FWidget.php;h=8ec57dce40f8316906ff9698c389b9bc4b9d572e;hb=63da4a75e9da71a2decebd81b62554457dbd1fb5;hp=a899644c3ce5a80c27ad2de9e13667e0dce320e4;hpb=e34795762d72347746bd506f253495da7d0ab329;p=friendica.git diff --git a/src/Content/Widget.php b/src/Content/Widget.php index a899644c3c..8ec57dce40 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -22,7 +22,7 @@ namespace Friendica\Content; use Friendica\Core\Addon; -use Friendica\Core\Cache\Duration; +use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Database\DBA; @@ -63,7 +63,7 @@ class Widget if (DI::config()->get('system', 'invitation_only')) { $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining')); - if ($x || is_site_admin()) { + if ($x || DI::app()->isSiteAdmin()) { DI::page()['aside'] .= ''; @@ -91,12 +91,14 @@ class Widget } /** - * Return unavailable networks + * Return unavailable networks as array + * + * @return array Unsupported networks */ 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; @@ -125,16 +127,7 @@ class Widget if (!Addon::isEnabled("pnut")) { $networks[] = Protocol::PNUT; } - - if (!sizeof($networks)) { - return ""; - } - - $network_filter = implode("','", $networks); - - $network_filter = "AND `network` NOT IN ('$network_filter')"; - - return $network_filter; + return $networks; } /** @@ -265,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)) { @@ -516,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