From 0ce02b4f068f73e41c84cdc2e983d6bef6be05d1 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Thu, 8 Oct 2020 17:17:21 +0200 Subject: [PATCH] some arbitrary improvements (#2032) * show version in doctor * added flag to import activities as global --- src/Command/KimaiImporterCommand.php | 17 +++++++++++++++-- templates/doctor/index.html.twig | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Command/KimaiImporterCommand.php b/src/Command/KimaiImporterCommand.php index 3bbabfe9..e966a75d 100755 --- a/src/Command/KimaiImporterCommand.php +++ b/src/Command/KimaiImporterCommand.php @@ -113,6 +113,13 @@ final class KimaiImporterCommand extends Command * @var array */ private $oldActivities = []; + /** + * If true, unknown Activities will be created globally. + * Default behavior: create project specific activities + * + * @var bool + */ + private $unknownAsGlobal = false; public function __construct(UserPasswordEncoderInterface $encoder, ManagerRegistry $registry, ValidatorInterface $validator) { @@ -143,6 +150,7 @@ final class KimaiImporterCommand extends Command ->addArgument('currency', InputArgument::OPTIONAL, 'The default currency for customer (code like EUR, CHF, GBP or USD)', 'EUR') ->addOption('timezone', null, InputOption::VALUE_OPTIONAL, 'Default timezone for imported users', date_default_timezone_get()) ->addOption('language', null, InputOption::VALUE_OPTIONAL, 'Default language for imported users', User::DEFAULT_LANGUAGE) + ->addOption('global', null, InputOption::VALUE_NONE, 'If set, activities without mapping will be created globally instead of project-specific (default behavior)') ; } @@ -164,6 +172,7 @@ final class KimaiImporterCommand extends Command $this->connection = DriverManager::getConnection($connectionParams, $config); $this->dbPrefix = $input->getArgument('prefix'); + $this->unknownAsGlobal = $input->getOption('global'); $password = $input->getArgument('password'); if (null === $password || \strlen($password = trim($password)) < 8) { @@ -906,8 +915,12 @@ final class KimaiImporterCommand extends Command // remember which activity has at least one assigned project $oldActivityMapping = []; - foreach ($activityToProject as $mapping) { - $oldActivityMapping[$mapping['activityID']][] = $mapping['projectID']; + if ($this->unknownAsGlobal) { + $oldActivityMapping['___GLOBAL___'][] = PHP_INT_MAX; + } else { + foreach ($activityToProject as $mapping) { + $oldActivityMapping[$mapping['activityID']][] = $mapping['projectID']; + } } // create global activities diff --git a/templates/doctor/index.html.twig b/templates/doctor/index.html.twig index 882cfac3..ee7cfcab 100644 --- a/templates/doctor/index.html.twig +++ b/templates/doctor/index.html.twig @@ -2,7 +2,7 @@ {% import "doctor/actions.html.twig" as actions %} {% block page_title %}{{ 'menu.doctor'|trans }}{% endblock %} -{% block page_subtitle %}Environment: {{ environment }}{% endblock %} +{% block page_subtitle %}Environment: {{ environment }} – Version: {{ constant('App\\Constants::VERSION') }} {{ constant('App\\Constants::STATUS') }}{% endblock %} {% block page_actions %}{{ actions.doctor('index') }}{% endblock %} {% block main %}