X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FWidget.php;h=86339928702dadadd879f02e1dbef365d6785d8d;hb=70392df68d4e5e0881c1184e7d368593ccfa7068;hp=653c99624b5a1907f21965d5db642fdc0240bdaf;hpb=a3e42a8c07d6a319f2523295b8bea5d1512300d6;p=friendica.git diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 653c99624b..8633992870 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -1,6 +1,6 @@ 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'] .= ''; @@ -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)) { @@ -334,23 +318,20 @@ class Widget /** * Return categories widget * - * @param string $baseurl baseurl - * @param string $selected optional, default empty + * @param int $uid Id of the user owning the categories + * @param string $baseurl Base page URL + * @param string $selected Selected category * @return string|void * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ - public static function categories($baseurl, $selected = '') + public static function categories(int $uid, string $baseurl, string $selected = '') { - $a = DI::app(); - - $uid = intval($a->getProfileOwner()); - if (!Feature::isEnabled($uid, 'categories')) { return ''; } $terms = array(); - foreach (Post\Category::getArray(local_user(), Post\Category::CATEGORY) as $savedFolderName) { + foreach (Post\Category::getArray($uid, Post\Category::CATEGORY) as $savedFolderName) { $terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName]; } @@ -525,7 +506,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