X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FContent%2FWidget.php;h=b5ccd6f14db7640fa1561cccd3b0d6118f15b280;hb=a3173ccb5074d0da75ecc76fd069fa328e2a9cc4;hp=032b9e7534d3f8a3e05a12ab1c1b067697a5b463;hpb=d666b6cb42a1b0d46e9fae914a803fbd5e10e2ab;p=friendica.git diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 032b9e7534..b5ccd6f14d 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'] .= ''; @@ -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)) { @@ -334,7 +327,7 @@ class Widget { $a = DI::app(); - $uid = intval($a->profile['uid']); + $uid = intval($a->getProfileOwner()); if (!Feature::isEnabled($uid, 'categories')) { return ''; @@ -416,23 +409,20 @@ class Widget /** * Insert a tag cloud widget for the present profile. * + * @param int $uid User ID * @param int $limit Max number of displayed tags. * @return string HTML formatted output. * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - public static function tagCloud($limit = 50) + public static function tagCloud(int $uid, int $limit = 50) { - $a = DI::app(); - - $uid = intval($a->profile['uid']); - - if (!$uid || !$a->profile['url']) { + if (empty($uid)) { return ''; } if (Feature::isEnabled($uid, 'tagadelic')) { - $owner_id = Contact::getIdForURL($a->profile['url'], 0, false); + $owner_id = Contact::getPublicIdByUserId($uid); if (!$owner_id) { return ''; @@ -463,7 +453,7 @@ class Widget $cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall; $dthen = DI::cache()->get($cachekey); - if (!empty($dthen)) { + if (empty($dthen)) { $dthen = Item::firstPostDate($uid, $wall); DI::cache()->set($cachekey, $dthen, Duration::HOUR); } @@ -519,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