]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Widget.php
The boot.php had been cleared of most functions
[friendica.git] / src / Content / Widget.php
index a899644c3ce5a80c27ad2de9e13667e0dce320e4..8ec57dce40f8316906ff9698c389b9bc4b9d572e 100644 (file)
@@ -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'] .= '<div class="side-link widget" id="side-invite-remain">'
                                        . DI::l10n()->tt('%d invitation available', '%d invitations available', $x)
                                        . '</div>';
@@ -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