Release 2.5.0 (#4454)
- added command to list users - corrected wrong german translation - work contract validations - prevent error with missing params - use collapsible, minor UI improvement - added classes to target menu buttons in custom rules - disable webpack notifier, incompatible with mac arm - use explicit menu service to generate menu - bump to fontawesome 6 and replace restart icon - change repeat icon for recent activities - moved user bookmarks (favorites) to top nav - fix totp seconds window (leeway) - new migration to fix remaining user preferences with dots in name - remove duplicate named column in user screen - unify and added translations - added missing filter and tags to InvoiceSecurity
This commit is contained in:
49
src/Command/ListUserCommand.php
Normal file
49
src/Command/ListUserCommand.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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\Command;
|
||||
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
#[AsCommand(name: 'kimai:user:list', description: 'List all users')]
|
||||
final class ListUserCommand extends Command
|
||||
{
|
||||
public function __construct(private UserRepository $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
$users = $this->repository->findAll();
|
||||
|
||||
$data = [];
|
||||
foreach ($users as $user) {
|
||||
$data[] = [
|
||||
$user->getUserIdentifier(),
|
||||
$user->getEmail(),
|
||||
implode(', ', $user->getRoles()),
|
||||
$user->isEnabled() ? 'X' : '',
|
||||
$user->getPasswordRequestedAt()?->format('Y-m-d H:i:s')
|
||||
];
|
||||
}
|
||||
|
||||
$header = ['Username', 'Email', 'Roles', 'Active', 'PW Reset'];
|
||||
|
||||
$output->table($header, $data);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ class Constants
|
||||
/**
|
||||
* The current release version
|
||||
*/
|
||||
public const VERSION = '2.4.1';
|
||||
public const VERSION = '2.5.0';
|
||||
/**
|
||||
* The current release: major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
public const VERSION_ID = 20401;
|
||||
public const VERSION_ID = 20500;
|
||||
/**
|
||||
* The software name
|
||||
*/
|
||||
|
||||
@@ -70,8 +70,8 @@ final class UserController extends AbstractController
|
||||
$table->setReloadEvents('kimai.userUpdate');
|
||||
|
||||
$table->addColumn('avatar', ['class' => 'alwaysVisible w-avatar', 'title' => null, 'orderBy' => false]);
|
||||
$table->addColumn('user', ['class' => 'alwaysVisible', 'orderBy' => 'user']);
|
||||
$table->addColumn('username', ['class' => 'd-none']);
|
||||
//$table->addColumn('user', ['class' => 'alwaysVisible', 'orderBy' => 'user']);
|
||||
$table->addColumn('username', ['class' => 'alwaysVisible']);
|
||||
$table->addColumn('alias', ['class' => 'd-none']);
|
||||
$table->addColumn('account_number', ['class' => 'd-none']);
|
||||
$table->addColumn('title', ['class' => 'd-none']);
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Event\ConfigureMainMenuEvent;
|
||||
use App\Utils\MenuItemModel;
|
||||
use App\Utils\MenuService;
|
||||
use KevinPapst\TablerBundle\Event\MenuEvent;
|
||||
use KevinPapst\TablerBundle\Model\MenuItemInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
@@ -24,7 +21,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
*/
|
||||
final class MenuBuilderSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private EventDispatcherInterface $eventDispatcher, private Security $security)
|
||||
public function __construct(private MenuService $menuService)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,15 +34,7 @@ final class MenuBuilderSubscriber implements EventSubscriberInterface
|
||||
|
||||
public function onSetupNavbar(MenuEvent $event): void
|
||||
{
|
||||
$menuEvent = new ConfigureMainMenuEvent();
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->security->getUser();
|
||||
|
||||
// error pages don't have a user and will fail when is_granted() is called
|
||||
if (null !== $user) {
|
||||
$this->eventDispatcher->dispatch($menuEvent);
|
||||
}
|
||||
$menuEvent = $this->menuService->getKimaiMenu();
|
||||
|
||||
foreach ($menuEvent->getMenu()->getChildren() as $child) {
|
||||
if ($child->getRoute() === null && !$child->hasChildren()) {
|
||||
|
||||
@@ -1,61 +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 App\Event\ConfigureMainMenuEvent;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
final class MenuFavoritesSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
ConfigureMainMenuEvent::class => ['onMainMenuConfigure', 90], // see MenuSubscriber
|
||||
];
|
||||
}
|
||||
|
||||
public function onMainMenuConfigure(ConfigureMainMenuEvent $menuEvent): void
|
||||
{
|
||||
/** @var User|null $user */
|
||||
$user = $this->security->getUser();
|
||||
if (null === $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userFavorites = $user->getPreferenceValue('favorite_routes');
|
||||
if (!\is_string($userFavorites) || trim($userFavorites) === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$favMenu = $menuEvent->findById('favorites');
|
||||
if ($favMenu === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$userFavorites = explode(',', $userFavorites);
|
||||
foreach ($userFavorites as $fav) {
|
||||
$tmp = $menuEvent->findById($fav);
|
||||
if ($tmp !== null && !$tmp->hasChildren()) {
|
||||
$favMenu->addChild(clone $tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if ($favMenu->hasChildren()) {
|
||||
$favMenu->setExpanded(true);
|
||||
$menuEvent->getTimesheetMenu()?->setExpanded(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/Twig/Runtime/MenuExtension.php
Normal file
46
src/Twig/Runtime/MenuExtension.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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\Twig\Runtime;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Utils\MenuItemModel;
|
||||
use App\Utils\MenuService;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
|
||||
final class MenuExtension implements RuntimeExtensionInterface
|
||||
{
|
||||
public function __construct(private MenuService $menuService)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<MenuItemModel>
|
||||
*/
|
||||
public function getUserShortcuts(User $user): array
|
||||
{
|
||||
$shortcuts = $user->getPreferenceValue('favorite_routes');
|
||||
if (!\is_string($shortcuts) || trim($shortcuts) === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$favMenu = [];
|
||||
|
||||
$shortcuts = explode(',', $shortcuts);
|
||||
$menu = $this->menuService->getKimaiMenu();
|
||||
foreach ($shortcuts as $fav) {
|
||||
$tmp = $menu->findById($fav);
|
||||
if ($tmp !== null && !$tmp->hasChildren()) {
|
||||
$favMenu[] = clone $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return $favMenu;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace App\Twig;
|
||||
|
||||
use App\Twig\Runtime\EncoreExtension;
|
||||
use App\Twig\Runtime\MarkdownExtension;
|
||||
use App\Twig\Runtime\MenuExtension;
|
||||
use App\Twig\Runtime\QrCodeExtension;
|
||||
use App\Twig\Runtime\ThemeExtension;
|
||||
use App\Twig\Runtime\TimesheetExtension;
|
||||
@@ -37,6 +38,7 @@ final class RuntimeExtensions extends AbstractExtension
|
||||
new TwigFunction('render_widget', [WidgetExtension::class, 'renderWidget'], ['is_safe' => ['html'], 'needs_environment' => true]),
|
||||
new TwigFunction('icon', [RuntimeExtension::class, 'createIcon'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('qr_code_data_uri', [QrCodeExtension::class, 'qrCodeDataUriFunction']),
|
||||
new TwigFunction('user_shortcuts', [MenuExtension::class, 'getUserShortcuts']),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ final class InvoicePolicy implements SecurityPolicyInterface
|
||||
$this->policy = new ChainPolicy();
|
||||
$this->policy->addPolicy(new DefaultPolicy());
|
||||
$this->policy->addPolicy(new SecurityPolicy(
|
||||
['block', 'if', 'for', 'set', 'extends'],
|
||||
['block', 'if', 'for', 'set', 'extends', 'import'],
|
||||
[
|
||||
// =================================================================
|
||||
// vendor/twig/twig/src/Extension/CoreExtension.php
|
||||
@@ -102,9 +102,16 @@ final class InvoicePolicy implements SecurityPolicyInterface
|
||||
'currency_symbol',
|
||||
'language_name',
|
||||
'locale_name',
|
||||
'timezone_name',
|
||||
'format_currency',
|
||||
'format_number',
|
||||
'format_*_number',
|
||||
'format_decimal_number',
|
||||
'format_currency_number',
|
||||
'format_percent_number',
|
||||
'format_scientific_number',
|
||||
'format_spellout_number',
|
||||
'format_ordinal_number',
|
||||
'format_duration_number',
|
||||
'format_datetime',
|
||||
'format_date',
|
||||
'format_time',
|
||||
|
||||
40
src/Utils/MenuService.php
Normal file
40
src/Utils/MenuService.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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\Utils;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Event\ConfigureMainMenuEvent;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
|
||||
final class MenuService
|
||||
{
|
||||
private ?ConfigureMainMenuEvent $menuEvent = null;
|
||||
|
||||
public function __construct(private EventDispatcherInterface $eventDispatcher, private Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
public function getKimaiMenu(): ConfigureMainMenuEvent
|
||||
{
|
||||
if (null === $this->menuEvent) {
|
||||
$this->menuEvent = new ConfigureMainMenuEvent();
|
||||
/** @var User $user */
|
||||
$user = $this->security->getUser();
|
||||
|
||||
// error pages don't have a user and will fail when is_granted() is called
|
||||
if (null !== $user) {
|
||||
$this->eventDispatcher->dispatch($this->menuEvent);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->menuEvent;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user