navbar block cleanup (#742)
This commit is contained in:
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Kimai time-tracking app.
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\EventSubscriber;
|
|
||||||
|
|
||||||
use App\Entity\User;
|
|
||||||
use KevinPapst\AdminLTEBundle\Event\ShowUserEvent;
|
|
||||||
use KevinPapst\AdminLTEBundle\Event\ThemeEvents;
|
|
||||||
use KevinPapst\AdminLTEBundle\Model\UserModel;
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
|
|
||||||
class NavbarShowUserSubscriber implements EventSubscriberInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var TokenStorageInterface
|
|
||||||
*/
|
|
||||||
protected $storage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TokenStorageInterface $tokenStorage
|
|
||||||
*/
|
|
||||||
public function __construct(TokenStorageInterface $tokenStorage)
|
|
||||||
{
|
|
||||||
$this->storage = $tokenStorage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
ThemeEvents::THEME_NAVBAR_USER => ['onShowUser', 100],
|
|
||||||
ThemeEvents::THEME_SIDEBAR_USER => ['onShowUser', 100],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ShowUserEvent $event
|
|
||||||
*/
|
|
||||||
public function onShowUser(ShowUserEvent $event)
|
|
||||||
{
|
|
||||||
if (null === $this->storage->getToken()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @var $myUser User */
|
|
||||||
$myUser = $this->storage->getToken()->getUser();
|
|
||||||
|
|
||||||
$user = new UserModel();
|
|
||||||
$user->setName($myUser->getAlias() ?: $myUser->getUsername())
|
|
||||||
->setUsername($myUser->getUsername())
|
|
||||||
->setIsOnline(true)
|
|
||||||
->setTitle($myUser->getTitle())
|
|
||||||
->setAvatar($myUser->getAvatar())
|
|
||||||
->setMemberSince($myUser->getRegisteredAt());
|
|
||||||
|
|
||||||
$event->setUser($user);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
<!-- Page rendered on {{ 'now'|localizeddate('long', 'long', null, 'UTC') }} -->
|
<!-- Page rendered on {{ 'now'|localizeddate('long', 'long', null, 'UTC') }} -->
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block navbar_messages %}
|
{% block navbar_start %}
|
||||||
{% if app.user is not null and is_granted('IS_AUTHENTICATED_REMEMBERED') %}
|
{% if app.user is not null and is_granted('IS_AUTHENTICATED_REMEMBERED') %}
|
||||||
{% if is_granted('view_own_timesheet') %}
|
{% if is_granted('view_own_timesheet') %}
|
||||||
<li class="visible-xs-inline-block">
|
<li class="visible-xs-inline-block">
|
||||||
@@ -77,18 +77,23 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block navbar_notifications %}
|
|
||||||
{% if app.user is not null and is_granted('IS_AUTHENTICATED_REMEMBERED') %}
|
|
||||||
{{ render(controller('App\\Controller\\NavbarController::recentActivitiesAction')) }}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{# deactivated blocks #}
|
{# these blocks and the hook-in logic by the AdminTheme could be re-used by Kimai or an extension at some point #}
|
||||||
|
{#
|
||||||
|
{% block navbar_messages %}{% endblock %}
|
||||||
|
{% block navbar_notifications %}{% endblock %}
|
||||||
{% block navbar_tasks %}{% endblock %}
|
{% block navbar_tasks %}{% endblock %}
|
||||||
|
{% block navbar_end %}{% endblock %}
|
||||||
|
#}
|
||||||
|
|
||||||
|
{# deactivated blocks, as Kimai does not ship the sidebar for UX reasons #}
|
||||||
{% block sidebar_user %}{% endblock %}
|
{% block sidebar_user %}{% endblock %}
|
||||||
{% block sidebar_search %}{% endblock %}
|
{% block sidebar_search %}{% endblock %}
|
||||||
|
|
||||||
{% block navbar_user %}
|
{% block navbar_user %}
|
||||||
|
{% if app.user is not null and is_granted('IS_AUTHENTICATED_REMEMBERED') %}
|
||||||
|
{{ render(controller('App\\Controller\\NavbarController::recentActivitiesAction')) }}
|
||||||
|
{% endif %}
|
||||||
{% import "macros/widgets.html.twig" as widgets %}
|
{% import "macros/widgets.html.twig" as widgets %}
|
||||||
<li class="dropdown user-menu">
|
<li class="dropdown user-menu">
|
||||||
<a href="#" class="dropdown-toggle ddt-large" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle ddt-large" data-toggle="dropdown">
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
{# User Account: style can be found in dropdown.less #}
|
|
||||||
{% import "@AdminLTE/Macros/default.html.twig" as macro %}
|
|
||||||
<li class="dropdown user user-menu">
|
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
|
||||||
{{ macro.avatar(user.avatar, user.username, 'user-image') }}
|
|
||||||
<span class="hidden-xs">{{ user.name }}</span>
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
<!-- User image -->
|
|
||||||
<li class="user-header">
|
|
||||||
{{ macro.avatar(user.avatar, user.username) }}
|
|
||||||
<p>
|
|
||||||
{{user.name}}
|
|
||||||
<small>{{user.title}}</small>
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
<li class="user-footer">
|
|
||||||
<div class="pull-left">
|
|
||||||
<a href="{{ path('user_profile', {'username' : user.username}) }}" class="btn btn-default btn-flat">{{ 'label.user_profile'|trans }}</a>
|
|
||||||
</div>
|
|
||||||
<div class="pull-right">
|
|
||||||
<a href="{{ logout_path() }}" class="btn btn-default btn-flat">{{ 'label.logout'|trans }}</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
Reference in New Issue
Block a user