mirror of
https://github.com/friendica/friendica
synced 2025-04-26 21:50:11 +00:00
Get rid of App->user completely
This commit is contained in:
parent
fc283ab928
commit
28090bd793
39 changed files with 158 additions and 234 deletions
|
@ -23,6 +23,7 @@ namespace Friendica\Content;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -185,25 +186,21 @@ class Nav
|
|||
$nav['login'] = ['login', DI::l10n()->t('Login'), (DI::module()->getName() == 'login' ? 'selected' : ''), DI::l10n()->t('Sign in')];
|
||||
}
|
||||
|
||||
if (local_user()) {
|
||||
if (!empty($a->user)) {
|
||||
// user menu
|
||||
$nav['usermenu'][] = ['profile/' . $a->getNickname(), DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
|
||||
$nav['usermenu'][] = ['profile/' . $a->getNickname() . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
|
||||
$nav['usermenu'][] = ['photos/' . $a->getNickname(), DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
|
||||
$nav['usermenu'][] = ['videos/' . $a->getNickname(), DI::l10n()->t('Videos'), '', DI::l10n()->t('Your videos')];
|
||||
$nav['usermenu'][] = ['events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
|
||||
$nav['usermenu'][] = ['notes/', DI::l10n()->t('Personal notes'), '', DI::l10n()->t('Your personal notes')];
|
||||
if ($a->isLoggedIn()) {
|
||||
// user menu
|
||||
$nav['usermenu'][] = ['profile/' . $a->getNickname(), DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
|
||||
$nav['usermenu'][] = ['profile/' . $a->getNickname() . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
|
||||
$nav['usermenu'][] = ['photos/' . $a->getNickname(), DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
|
||||
$nav['usermenu'][] = ['videos/' . $a->getNickname(), DI::l10n()->t('Videos'), '', DI::l10n()->t('Your videos')];
|
||||
$nav['usermenu'][] = ['events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
|
||||
$nav['usermenu'][] = ['notes/', DI::l10n()->t('Personal notes'), '', DI::l10n()->t('Your personal notes')];
|
||||
|
||||
// user info
|
||||
$contact = DBA::selectFirst('contact', ['micro'], ['uid' => $a->getUserId(), 'self' => true]);
|
||||
$userinfo = [
|
||||
'icon' => (DBA::isResult($contact) ? DI::baseUrl()->remove($contact['micro']) : Contact::DEFAULT_AVATAR_MICRO),
|
||||
'name' => $a->getUserValue('username'),
|
||||
];
|
||||
} else {
|
||||
DI::logger()->warning('Empty $a->user for local user', ['local_user' => local_user(), '$a' => $a]);
|
||||
}
|
||||
// user info
|
||||
$contact = DBA::selectFirst('contact', ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'], ['uid' => $a->getUserId(), 'self' => true]);
|
||||
$userinfo = [
|
||||
'icon' => Contact::getMicro($contact),
|
||||
'name' => $contact['name'],
|
||||
];
|
||||
}
|
||||
|
||||
// "Home" should also take you home from an authenticated remote profile connection
|
||||
|
@ -271,7 +268,7 @@ class Nav
|
|||
}
|
||||
|
||||
// The following nav links are only show to logged in users
|
||||
if (local_user() && !empty($a->user)) {
|
||||
if (local_user() && !empty($a->getNickname())) {
|
||||
$nav['network'] = ['network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
|
||||
|
||||
$nav['home'] = ['profile/' . $a->getNickname(), DI::l10n()->t('Home'), '', DI::l10n()->t('Your posts and conversations')];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue