]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Nav.php
Merge pull request #10575 from MrPetovan/bug/10019-peertube-embed
[friendica.git] / src / Content / Nav.php
index 335f81bf3d80f54216f7bb55618e371d324cff29..20b3a93258636582eb8db614b9cf6b9dacb37de7 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -27,6 +27,7 @@ use Friendica\Core\Renderer;
 use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
 
@@ -143,9 +144,9 @@ class Nav
         *    array 'userinfo' => Array of user information (name, icon)
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       private static function getInfo(App $a)
+       private static function getInfo(App $a): array
        {
-               $ssl_state = ((local_user()) ? true : false);
+               $ssl_state = (bool) local_user();
 
                /*
                 * Our network is distributed, and as you visit friends some of the
@@ -157,13 +158,27 @@ class Nav
 
                $sitelocation = $myident . substr(DI::baseUrl()->get($ssl_state), strpos(DI::baseUrl()->get($ssl_state), '//') + 2);
 
-               // nav links: array of array('href', 'text', 'extra css classes', 'title')
-               $nav = [];
+               $nav = [
+                       'admin'         => null,
+                       'apps'          => null,
+                       'community'     => null,
+                       'home'          => null,
+                       'events'        => null,
+                       'login'         => null,
+                       'logout'        => null,
+                       'langselector'  => null,
+                       'messages'      => null,
+                       'network'       => null,
+                       'notifications' => null,
+                       'remote'        => null,
+                       'search'        => null,
+                       'usermenu'      => [],
+               ];
 
                // Display login or logout
-               $nav['usermenu'] = [];
                $userinfo = null;
 
+               // nav links: array of array('href', 'text', 'extra css classes', 'title')
                if (Session::isAuthenticated()) {
                        $nav['logout'] = ['logout', DI::l10n()->t('Logout'), '', DI::l10n()->t('End this session')];
                } else {
@@ -183,7 +198,7 @@ class Nav
                                // user info
                                $contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
                                $userinfo = [
-                                       'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : 'images/person-48.jpg'),
+                                       'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : Contact::DEFAULT_AVATAR_MICRO),
                                        'name' => $a->user['username'],
                                ];
                        } else {
@@ -274,7 +289,7 @@ class Nav
                        $nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
                        $nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
 
-                       if (is_array($a->identities) && count($a->identities) > 1) {
+                       if (User::hasIdentities(DI::session()->get('submanage') ?: local_user())) {
                                $nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
                        }
 
@@ -296,13 +311,15 @@ class Nav
                        $banner = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
                }
 
-               Hook::callAll('nav_info', $nav);
-
-               return [
+               $nav_info = [
+                       'banner'       => $banner,
+                       'nav'          => $nav,
                        'sitelocation' => $sitelocation,
-                       'nav' => $nav,
-                       'banner' => $banner,
-                       'userinfo' => $userinfo,
+                       'userinfo'     => $userinfo,
                ];
+
+               Hook::callAll('nav_info', $nav_info);
+
+               return $nav_info;
        }
 }