diff --git a/.idea/leantime-oss.iml b/.idea/leantime-oss.iml index 43734fc7a..098015702 100644 --- a/.idea/leantime-oss.iml +++ b/.idea/leantime-oss.iml @@ -2,6 +2,9 @@ + + + @@ -115,7 +118,6 @@ - @@ -151,10 +153,6 @@ - - - - @@ -164,6 +162,7 @@ + diff --git a/.idea/php.xml b/.idea/php.xml index 651818565..a8aa7ba55 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -178,13 +178,9 @@ - - - - @@ -213,7 +209,6 @@ - @@ -226,6 +221,7 @@ + diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml index 8645fe9c5..1ff09a14a 100644 --- a/.idea/phpspec.xml +++ b/.idea/phpspec.xml @@ -41,6 +41,9 @@ + + \ No newline at end of file diff --git a/app/Core/Application.php b/app/Core/Application.php index b89ac652f..9525102eb 100644 --- a/app/Core/Application.php +++ b/app/Core/Application.php @@ -2,7 +2,18 @@ namespace Leantime\Core; +use Illuminate\Cache\MemcachedConnector; use Illuminate\Container\Container; +use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract; +use Illuminate\Contracts\Container\Container as IlluminateContainerContract; +use Illuminate\Contracts\Http\Kernel as HttpKernelContract; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Facade; +use Leantime\Domain\Auth\Services\Auth as AuthService; +use Leantime\Domain\Modulemanager\Services\Modulemanager as ModulemanagerService; +use Leantime\Domain\Oidc\Services\Oidc as OidcService; +use Leantime\Domain\Setting\Services\Setting as SettingsService; +use Psr\Container\ContainerInterface as PsrContainerContract; /** * Application Class - IoC Container for the application @@ -19,6 +30,16 @@ class Application extends Container */ private static bool $bootstrapped = false; + + public function __construct(){ + + $this->registerCoreBindings(); + $this->registerCoreAliases(); + $this->bindRequest(); + + Facade::setFacadeApplication($this); + + } /** * Check if application has been bootstrapped * @@ -89,4 +110,202 @@ public function basePath() { return APP_ROOT; } + + protected function registerCoreBindings(): void + { + static::setInstance($this); + + $this->singleton(Application::class, fn() => Application::getInstance()); + + $this->singleton(Environment::class, Environment::class); + + $this->singleton(AppSettings::class, AppSettings::class); + $this->singleton(Db::class, Db::class); + $this->singleton(Frontcontroller::class, Frontcontroller::class); + $this->singleton(Language::class, Language::class); + $this->singleton(AuthService::class, AuthService::class); + $this->singleton(OidcService::class, OidcService::class); + $this->singleton(ModulemanagerService::class, ModulemanagerService::class); + $this->singleton(\Illuminate\Filesystem\Filesystem::class, fn () => new \Illuminate\Filesystem\Filesystem()); + $this->singleton(\Illuminate\Encryption\Encrypter::class, function ($app) { + $configKey = $app['config']->sessionPassword; + + if (strlen($configKey) > 32) { + $configKey = substr($configKey, 0, 32); + } + + if (strlen($configKey) < 32) { + $configKey = str_pad($configKey, 32, "x", STR_PAD_BOTH); + } + + $app['config']['app_key'] = $configKey; + + $encrypter = new \Illuminate\Encryption\Encrypter($app['config']['app_key'], "AES-256-CBC"); + return $encrypter; + }); + + $this->singleton(\Illuminate\Session\SessionManager::class, function ($app) { + + $app['config']['session'] = array( + 'driver' => "file", + 'lifetime' => $app['config']->sessionExpiration, + 'expire_on_close' => false, + 'encrypt' => false, + 'files' => APP_ROOT . '/cache/sessions', + 'lottery' => [2, 100], + 'cookie' => "ltid", + 'path' => '/', + 'domain' => is_array(parse_url(BASE_URL)) ? parse_url(BASE_URL)['host'] : null, + 'secure' => true, + 'http_only' => true, + 'same_site' => "Strict", + ); + + $sessionManager = new \Illuminate\Session\SessionManager($app); + + return $sessionManager; + }); + + $this->singleton('session.store', fn($app) => $app['session']->driver()); + + + /** + * @todo the following should eventually automatically turn caches into redis if available, + * then memcached if available, + * then fileStore + */ + $this->singleton(\Illuminate\Cache\CacheManager::class, function ($app) { + + //installation cache is per server + $app['config']['cache.stores.installation'] = [ + 'driver' => 'file', + 'connection' => 'default', + 'path' => APP_ROOT . '/cache/installation', + ]; + + //Instance is per company id + $instanceStore = fn () => + $app['config']['cache.stores.instance'] = [ + 'driver' => 'file', + 'connection' => 'default', + 'path' => APP_ROOT . "/cache/" . $app->make(SettingsService::class)->getCompanyId(), + ]; + + if ($app->make(IncomingRequest::class) instanceof CliRequest) { + if (empty($app->make(SettingsService::class)->getCompanyId())) { + throw new \RuntimeException('You can\'t run this CLI command until you have installed Leantime.'); + } + + $instanceStore(); + } else { + //Initialize instance cache store only after install was successfull + Events::add_event_listener( + 'leantime.core.middleware.installed.handle.after_install', + function () use ($instanceStore) { + if (! session("isInstalled")) { + return; + } + $instanceStore(); + } + ); + } + + $cacheManager = new \Illuminate\Cache\CacheManager($app); + //Setting the default does not mean that is exists already. + //Installation store is always available + //Instance store is only available post after_install event + $cacheManager->setDefaultDriver('instance'); + + return $cacheManager; + }); + $this->singleton('cache.store', fn ($app) => $app['cache']->driver()); + $this->singleton('cache.psr6', fn ($app) => new \Symfony\Component\Cache\Adapter\Psr16Adapter($app['cache.store'])); + $this->singleton('memcached.connector', fn () => new MemcachedConnector()); + + } + + /** + * Configure the real-time facade namespace. + * + * @param string $namespace + * @return void + */ + public function provideFacades($namespace) + { + + } + + private function registerCoreAliases(): void + { + + $this->alias(Application::class, 'app'); + $this->alias(Application::class, IlluminateContainerContract::class); + $this->alias(Application::class, PsrContainerContract::class); + $this->alias(Application::class, Container::class); + + $this->alias(Environment::class, 'config'); + $this->alias(Environment::class, \Illuminate\Contracts\Config\Repository::class); + + $this->alias(\Illuminate\Filesystem\Filesystem::class, 'files'); + $this->alias(ConsoleKernel::class, ConsoleKernelContract::class); + $this->alias(HttpKernel::class, HttpKernelContract::class); + + $this->alias(\Illuminate\Cache\CacheManager::class, 'cache'); + $this->alias(\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class); + + $this->alias(\Illuminate\Session\SessionManager::class, 'session'); + + + $this->alias(\Illuminate\Encryption\Encrypter::class, "encrypter"); + + } + + + public function clearCache(): void + { + + $currentVersion = $this->app->make(AppSettings::class)->appVersion; + $cachedVersion = Cache::store('installation')->rememberForever('version', fn () => $currentVersion); + + if ($currentVersion == $cachedVersion) { + return; + } + + Cache::store('installation')->flush(); + + } + + /** + * Bind request + * + * @return void + */ + private function bindRequest(): void + { + + $headers = collect(getallheaders()) + ->mapWithKeys(fn ($val, $key) => [ + strtolower($key) => match (true) { + in_array($val, ['false', 'true']) => filter_var($val, FILTER_VALIDATE_BOOLEAN), + preg_match('/^[0-9]+$/', $val) => filter_var($val, FILTER_VALIDATE_INT), + default => $val, + }, + ]) + ->all(); + + $this->singleton(IncomingRequest::class, function () use ($headers) { + + $request = match (true) { + isset($headers['hx-request']) => HtmxRequest::createFromGlobals(), + isset($headers['x-api-key']) => ApiRequest::createFromGlobals(), + defined('LEAN_CLI') && LEAN_CLI => CliRequest::createFromGlobals(), + default => IncomingRequest::createFromGlobals(), + }; + + do_once('overrideGlobals', fn () => $request->overrideGlobals()); + + return $request; + }); + + } } diff --git a/app/Core/Bootloader.php b/app/Core/Bootloader.php index 7f56165b4..1ccc1350c 100644 --- a/app/Core/Bootloader.php +++ b/app/Core/Bootloader.php @@ -37,7 +37,7 @@ class Bootloader * * @var static */ - protected static Bootloader $instance; + protected static ?Bootloader $instance = null; /** * Application instance @@ -75,17 +75,6 @@ class Bootloader */ private bool|PromiseInterface $telemetryResponse; - /** - * Set the Bootloader instance - * - * @param Bootloader|null $instance - * @return void - */ - public static function setInstance(?self $instance): void - { - static::$instance = $instance; - } - /** * Get the Bootloader instance * @@ -94,7 +83,12 @@ public static function setInstance(?self $instance): void */ public static function getInstance(?PsrContainerContract $app = null): self { - return static::$instance ??= new self($app); + + if (is_null(static::$instance)) { + static::$instance = new self($app); + } + + return static::$instance; } /** @@ -102,11 +96,9 @@ public static function getInstance(?PsrContainerContract $app = null): self * * @param PsrContainerContract|null $app */ - public function __construct(?PsrContainerContract $app = null) + private function __construct(?PsrContainerContract $app = null) { $this->app = $app; - - static::$instance ??= $this; } /** @@ -117,7 +109,7 @@ public function __construct(?PsrContainerContract $app = null) */ public function __invoke(): void { - $this->boot(); + //$this->boot(); } /** @@ -132,24 +124,25 @@ public function boot(): void define('LEANTIME_START', microtime(true)); } - $app = $this->getApplication(); + $this->app = new Application(); - $app->make(AppSettings::class)->loadSettings(); + $test = 1; - $this->clearCache(); + $this->app->make(AppSettings::class)->loadSettings(); + + $this->app->clearCache(); Events::discover_listeners(); - $app = self::dispatch_filter("initialized", $app, ['bootloader' => $this]); + $this->app = self::dispatch_filter("initialized", $this->app, ['bootloader' => $this]); - $config = $app->make(Environment::class); + $config = $this->app['config']; $this->setErrorHandler($config->debug ?? 0); self::dispatch_event('config_initialized'); - - $request = $app->make(IncomingRequest::class); + $request = $this->app->make(IncomingRequest::class); if (! defined('BASE_URL')) { if (isset($config->appUrl) && !empty($config->appUrl)) { @@ -165,7 +158,7 @@ public function boot(): void self::dispatch_event("beginning", ['bootloader' => $this]); - if ($app::hasBeenBootstrapped()) { + if ($this->app::hasBeenBootstrapped()) { return; } @@ -173,177 +166,13 @@ public function boot(): void $this->handleRequest(); - $app::setHasBeenBootstrapped(); + $this->app::setHasBeenBootstrapped(); self::dispatch_event("end", ['bootloader' => $this]); } - /** - * Get the Application instance and bind important services - * - * @return Application - * @throws BindingResolutionException - * @todo Break this up into Service Providers - */ - public function getApplication(): Application - { - $this->app ??= Application::getInstance(); - - $this->registerCoreBindings(); - $this->registerCoreAliases(); - $this->bindRequest(); - - Facade::setFacadeApplication($this->app); - - Application::setInstance($this->app); - - return $this->app; - } - - private function registerCoreBindings(): void - { - $this->app->bind(Application::class, fn () => Application::getInstance()); - $this->app->singleton(Environment::class, Environment::class); - $this->app->singleton(AppSettings::class, AppSettings::class); - $this->app->singleton(Db::class, Db::class); - $this->app->singleton(Frontcontroller::class, Frontcontroller::class); - $this->app->singleton(Language::class, Language::class); - $this->app->singleton(AuthService::class, AuthService::class); - $this->app->singleton(OidcService::class, OidcService::class); - $this->app->singleton(ModulemanagerService::class, ModulemanagerService::class); - $this->app->singleton(\Illuminate\Filesystem\Filesystem::class, fn () => new \Illuminate\Filesystem\Filesystem()); - $this->app->singleton(\Illuminate\Encryption\Encrypter::class, function ($app) { - $configKey = app()->make(Environment::class)->sessionPassword; - - if (strlen($configKey) > 32) { - $configKey = substr($configKey, 0, 32); - } - - if (strlen($configKey) < 32) { - $configKey = str_pad($configKey, 32, "x", STR_PAD_BOTH); - } - - $app['config']['app_key'] = $configKey; - - $encrypter = new \Illuminate\Encryption\Encrypter($app['config']['app_key'], "AES-256-CBC"); - return $encrypter; - }); - - $this->app->singleton(\Illuminate\Session\SessionManager::class, function ($app) { - - $app['config']['session'] = array( - 'driver' => "file", - 'connection' => 'default', - 'lifetime' => $app['config']->sessionExpiration, - 'expire_on_close' => false, - 'encrypt' => true, - 'files' => APP_ROOT . '/cache/sessions', - 'store' => null, - 'lottery' => [2, 100], - 'cookie' => "ltid", - 'path' => '/', - 'domain' => is_array(parse_url(BASE_URL)) ? parse_url(BASE_URL)['host'] : null, - 'secure' => true, - 'http_only' => true, - 'same_site' => "Strict", - ); - - $sessionManager = new \Illuminate\Session\SessionManager($app); - - return $sessionManager; - }); - - $this->app->singleton('session.store', fn($app) => $app['session']->driver()); - - /** - * @todo the following should eventually automatically turn caches into redis if available, - * then memcached if available, - * then fileStore - **/ - $this->app->singleton(\Illuminate\Cache\CacheManager::class, function ($app) { - - //installation cache is per server - $app['config']['cache.stores.installation'] = [ - 'driver' => 'file', - 'connection' => 'default', - 'path' => APP_ROOT . '/cache/installation', - ]; - - //Instance is per company id - $instanceStore = fn () => - $app['config']['cache.stores.instance'] = [ - 'driver' => 'file', - 'connection' => 'default', - 'path' => APP_ROOT . "/cache/" . $app->make(SettingsService::class)->getCompanyId(), - ]; - - if ($app->make(IncomingRequest::class) instanceof CliRequest) { - if (empty($app->make(SettingsService::class)->getCompanyId())) { - throw new \RuntimeException('You can\'t run this CLI command until you have installed Leantime.'); - } - - $instanceStore(); - } else { - //Initialize instance cache store only after install was successfull - Events::add_event_listener( - 'leantime.core.middleware.installed.handle.after_install', - function () use ($instanceStore) { - if (! session("isInstalled")) { - return; - } - $instanceStore(); - } - ); - } - - $cacheManager = new \Illuminate\Cache\CacheManager($app); - //Setting the default does not mean that is exists already. - //Installation store is always available - //Instance store is only available post after_install event - $cacheManager->setDefaultDriver('instance'); - - return $cacheManager; - }); - $this->app->singleton('cache.store', fn ($app) => $app['cache']->driver()); - $this->app->singleton('cache.psr6', fn ($app) => new \Symfony\Component\Cache\Adapter\Psr16Adapter($app['cache.store'])); - $this->app->singleton('memcached.connector', fn () => new MemcachedConnector()); - } - - private function registerCoreAliases(): void - { - $this->app->alias(Application::class, 'app'); - $this->app->alias(Application::class, IlluminateContainerContract::class); - $this->app->alias(Application::class, PsrContainerContract::class); - $this->app->alias(Environment::class, 'config'); - $this->app->alias(Environment::class, \Illuminate\Contracts\Config\Repository::class); - $this->app->alias(\Illuminate\Filesystem\Filesystem::class, 'files'); - $this->app->alias(ConsoleKernel::class, ConsoleKernelContract::class); - $this->app->alias(HttpKernel::class, HttpKernelContract::class); - - $this->app->alias(\Illuminate\Cache\CacheManager::class, 'cache'); - $this->app->alias(\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class); - - $this->app->alias(\Illuminate\Session\SessionManager::class, 'session'); - - $this->app->alias(\Illuminate\Encryption\Encrypter::class, "encrypter"); - - } - - - private function clearCache(): void - { - $currentVersion = app()->make(AppSettings::class)->appVersion; - $cachedVersion = Cache::store('installation')->rememberForever('version', fn () => $currentVersion); - - if ($currentVersion == $cachedVersion) { - return; - } - - Cache::store('installation')->flush(); - } - /** * Handle the request * @@ -395,34 +224,5 @@ private function setErrorHandler(int $debug): void Debug::enable(); } - /** - * Bind request - * - * @return void - */ - private function bindRequest(): void - { - $headers = collect(getallheaders()) - ->mapWithKeys(fn ($val, $key) => [ - strtolower($key) => match (true) { - in_array($val, ['false', 'true']) => filter_var($val, FILTER_VALIDATE_BOOLEAN), - preg_match('/^[0-9]+$/', $val) => filter_var($val, FILTER_VALIDATE_INT), - default => $val, - }, - ]) - ->all(); - - $this->app->singleton(IncomingRequest::class, function () use ($headers) { - $request = match (true) { - isset($headers['hx-request']) => HtmxRequest::createFromGlobals(), - isset($headers['x-api-key']) => ApiRequest::createFromGlobals(), - defined('LEAN_CLI') && LEAN_CLI => CliRequest::createFromGlobals(), - default => IncomingRequest::createFromGlobals(), - }; - - do_once('overrideGlobals', fn () => $request->overrideGlobals()); - - return $request; - }); - } + } diff --git a/app/Core/Environment.php b/app/Core/Environment.php index 22a89640e..7b2e613f6 100644 --- a/app/Core/Environment.php +++ b/app/Core/Environment.php @@ -9,7 +9,6 @@ use Illuminate\Support\Arr; use Illuminate\Support\Str; use Leantime\Config\Config; -use Illuminate\Support\Facades\Cache; use Symfony\Component\Yaml\Yaml; /** @@ -42,11 +41,6 @@ class Environment implements ArrayAccess, ConfigContract */ public array $config = []; - /** - * @var bool $configCached - */ - public bool $configCached = false; - /** * @var array list of legacy mappings * @todo remove this after deprecating configuration.php @@ -88,6 +82,7 @@ class Environment implements ArrayAccess, ConfigContract public function __construct(DefaultConfig $defaultConfiguration) { + /* PHP */ $this->phpConfig = null; if (file_exists($phpConfigFile = APP_ROOT . "/config/configuration.php")) { @@ -123,17 +118,21 @@ public function __construct(DefaultConfig $defaultConfiguration) ); } + $end = microtime(true); + //Cache is not available until after install. Events::add_event_listener( 'leantime.core.middleware.installed.handle.after_install', function () { - Cache::set("mainconfig", $this->config); - $this->configCached = true; + // }, 20 ); } + public function updateCache() { + file_put_contents(APP_ROOT . "/cache/configCache", serialize($this->config)); + } /** * getBool - get a boolean value from the environment * @@ -243,7 +242,7 @@ private function tryGetFromYaml(string $envVar, mixed $currentValue): mixed */ public function has($key): bool { - return Cache::has($key) || Arr::has($this->config, $key); + return Arr::has($this->config, $key); } /** @@ -259,11 +258,11 @@ public function get($key, $default = null): mixed return $this->getMany($key); } - return Arr::get([], $key, Arr::get( + return Arr::get( $this->config, $key, $default - )); + ); } /** @@ -300,12 +299,8 @@ public function set($key, $value = null): void foreach ($keys as $key => $value) { Arr::set($this->config, $key, $value); - - if($this->configCached === true && Cache::has("mainconfig")){ - Cache::set("mainconfig.".$key, $value); - } - } + } /** diff --git a/app/Core/HttpKernel.php b/app/Core/HttpKernel.php index 368d89d60..d6fd311e4 100644 --- a/app/Core/HttpKernel.php +++ b/app/Core/HttpKernel.php @@ -21,6 +21,12 @@ class HttpKernel implements HttpKernelContract */ protected $requestStartedAt = null; + protected Application $app; + + public function __construct(Application $app) { + $this->app = $app; + } + /** * Bootstrap the application if it has not been previously bootstrapped. * @@ -28,11 +34,11 @@ class HttpKernel implements HttpKernelContract */ public function bootstrap() { - if ($this->getApplication()->hasBeenBootstrapped()) { + if ($this->app->hasBeenBootstrapped()) { return; } - $this->getApplication()->boot(); + $this->app->boot(); } /** @@ -50,18 +56,20 @@ public function handle($request) try { - $response = (new Pipeline($this->getApplication())) + //Main Pipeline + $response = (new Pipeline($this->app)) ->send($request) ->through($this->getMiddleware()) ->then(fn ($request) => - (new Pipeline($this->getApplication())) - ->send($request) - ->through(self::dispatch_filter( - hook: 'plugins_middleware', - payload: [], - function: 'handle', - )) - ->then(fn () => Frontcontroller::dispatch()) + //Then run through plugin pipeline + (new Pipeline($this->app)) + ->send($request) + ->through(self::dispatch_filter( + hook: 'plugins_middleware', + payload: [], + function: 'handle', + )) + ->then(fn () => Frontcontroller::dispatch_request($request)) ); return self::dispatch_filter('beforeSendResponse', $response); @@ -102,8 +110,8 @@ function: 'handle', public function terminate($request, $response) { - if (method_exists($this->getApplication(), 'terminate')) { - $this->getApplication()->terminate(); + if (method_exists($this->app, 'terminate')) { + $this->app->terminate(); } if (is_null($this->requestStartedAt)) { @@ -136,7 +144,7 @@ public function terminate($request, $response) */ public function getApplication(): \Leantime\Core\Application { - return app(); + return $this->app; } /** @@ -152,7 +160,7 @@ public function getMiddleware(): array Middleware\Installed::class, Middleware\Updated::class, Middleware\RequestRateLimiter::class, - app()->make(IncomingRequest::class) instanceof ApiRequest + $this->app->make(IncomingRequest::class) instanceof ApiRequest ? Middleware\ApiAuth::class : Middleware\Auth::class, Middleware\Localization::class, diff --git a/app/Core/Middleware/StartSession.php b/app/Core/Middleware/StartSession.php index 07659057e..8d0b09d70 100644 --- a/app/Core/Middleware/StartSession.php +++ b/app/Core/Middleware/StartSession.php @@ -62,14 +62,15 @@ public function handle(IncomingRequest $request, Closure $next) $session = $this->getSession($request); self::dispatch_event('session_initialized'); + /* Handle blocking sessions if ( $this->manager->shouldBlock() || ($request->route() instanceof Route && $request->route()->locksFor()) ) { return $this->handleRequestWhileBlocking($request, $session, $next); - }*/ - + } +*/ return $this->handleStatefulRequest($request, $session, $next); } diff --git a/app/Core/Template.php b/app/Core/Template.php index f805d504d..0f397fd28 100644 --- a/app/Core/Template.php +++ b/app/Core/Template.php @@ -699,8 +699,8 @@ public function displayNotification(): string */ public function getToggleState(string $name): string { - if (session()->exists("submenuToggle".$name)) { - return session("submenuToggle".$name); + if (session()->exists("usersettings.submenuToggle.".$name)) { + return session("usersettings.submenuToggle.".$name); } return false; diff --git a/app/Domain/Auth/Services/Auth.php b/app/Domain/Auth/Services/Auth.php index 800cd4938..8ee587be4 100644 --- a/app/Domain/Auth/Services/Auth.php +++ b/app/Domain/Auth/Services/Auth.php @@ -331,9 +331,9 @@ public function setUsersession(mixed $user, bool $isLdap = false) $currentUser = self::dispatch_filter('user_session_vars', $currentUser); - $this->session->put('userdata', $currentUser); + session(['userdata' => $currentUser]); - $this->updateUserSessionDB($currentUser['id'], $this->session->getId()); + $this->updateUserSessionDB($currentUser['id'], session()->getId()); //Clear user theme cache on login Theme::clearCache(); @@ -361,7 +361,7 @@ public function updateUserSessionDB(int $userId, string $sessionID): bool public function loggedIn(): bool { // Check if we actually have a php session available - if ($this->session->exists("userdata")) { + if (session()->exists("userdata")) { return true; // If the session doesn't have any session data we are out of sync. Start again } else { @@ -390,7 +390,7 @@ public static function isLoggedIn(): bool */ public function getSessionId(): ?string { - return $this->session->getSid(); + return session()->getSid(); } /** diff --git a/app/Domain/Calendar/Templates/showMyCalendar.tpl.php b/app/Domain/Calendar/Templates/showMyCalendar.tpl.php index 9631cdbf4..4eaa419e3 100644 --- a/app/Domain/Calendar/Templates/showMyCalendar.tpl.php +++ b/app/Domain/Calendar/Templates/showMyCalendar.tpl.php @@ -3,8 +3,8 @@ foreach ($__data as $var => $val) { $$var = $val; // necessary for blade refactor } -if (!session()->exists("submenuToggle.myCalendarView")) { - session(["submenuToggle.myCalendarView" => "dayGridMonth"]); +if (!session()->exists("usersettings.submenuToggle.myCalendarView")) { + session(["usersettings.submenuToggle.myCalendarView" => "dayGridMonth"]); } ?> @@ -84,10 +84,10 @@ @@ -169,7 +169,7 @@ const calendar = new FullCalendar.Calendar(calendarEl, { timeZone: leantime.i18n.__("usersettings.timezone"), height:heightWindow, - initialView: '', + initialView: '', eventSources:eventSources, editable: true, headerToolbar: false, diff --git a/app/Domain/Dashboard/Templates/home.blade.php b/app/Domain/Dashboard/Templates/home.blade.php index 87edb8f36..e462c9b10 100644 --- a/app/Domain/Dashboard/Templates/home.blade.php +++ b/app/Domain/Dashboard/Templates/home.blade.php @@ -44,7 +44,7 @@ leantime.helperController.firstLoginModal(); @endif - @php(session(["userdata.settings.modals.homeDashboardTour" => 1])); + @php(session(["usersettings.modals.homeDashboardTour" => 1])); }); diff --git a/app/Domain/Dashboard/Templates/show.blade.php b/app/Domain/Dashboard/Templates/show.blade.php index ae55560d9..f38ed6790 100644 --- a/app/Domain/Dashboard/Templates/show.blade.php +++ b/app/Domain/Dashboard/Templates/show.blade.php @@ -582,7 +582,7 @@ function() { leantime.helperController.firstLoginModal(); @endif - @php(session(["userdata.settings.modals.projectDashboardTour" => 1])); + @php(session(["usersettings.modals.projectDashboardTour" => 1])); }); @dispatchEvent('scripts.beforeClose') diff --git a/app/Domain/Help/Composers/Helpermodal.php b/app/Domain/Help/Composers/Helpermodal.php index 9910a5243..6e1c13d02 100644 --- a/app/Domain/Help/Composers/Helpermodal.php +++ b/app/Domain/Help/Composers/Helpermodal.php @@ -49,15 +49,15 @@ public function with(): array $completedOnboarding == "1" && $currentModal !== 'notfound' && ( - session()->exists("userdata.settings.modals.".$currentModal) === false - || session("userdata.settings.modals.".$currentModal) == 0) + session()->exists("usersettings.modals.".$currentModal) === false + || session("usersettings.modals.".$currentModal) == 0) ) { - if (!session()->exists("userdata.settings.modals")) { - session(["userdata.settings.modals" => [] ]); + if (!session()->exists("usersettings.modals")) { + session(["usersettings.modals" => [] ]); } - if (!session()->exists("userdata.settings.modals.".$currentModal)) { - session(["userdata.settings.modals".$currentModal => 1]); + if (!session()->exists("usersettings.modals.".$currentModal)) { + session(["usersettings.modals.".$currentModal => 1]); $showHelperModal = true; } } diff --git a/app/Domain/Help/Controllers/ShowOnboardingDialog.php b/app/Domain/Help/Controllers/ShowOnboardingDialog.php index c902796cd..f999b06e2 100644 --- a/app/Domain/Help/Controllers/ShowOnboardingDialog.php +++ b/app/Domain/Help/Controllers/ShowOnboardingDialog.php @@ -19,15 +19,15 @@ public function get($params) { //show modals only once per session - if (!session()->exists("userdata")->settings["modals"]) { - session(["userdata.settings.modals" => array()]); + if (!session()->exists("usersettings.modals")) { + session(["usersettings.modals" => array()]); } if (isset($params['module']) && $params['module'] != "") { $filteredInput = htmlspecialchars($params['module']); - if (!session()->exists("userdata.settings.modals." . $filteredInput)) { - session(["userdata.settings.modals." . $filteredInput => 1]); + if (!session()->exists("usersettings.modals." . $filteredInput)) { + session(["usersettings.modals." . $filteredInput => 1]); } return $this->tpl->displayPartial('help.' . $filteredInput); diff --git a/app/Domain/Menu/Composers/Menu.php b/app/Domain/Menu/Composers/Menu.php index e88ba7c6c..1f92b8e1c 100644 --- a/app/Domain/Menu/Composers/Menu.php +++ b/app/Domain/Menu/Composers/Menu.php @@ -57,7 +57,7 @@ public function with(): array $projectType = ''; $menuType = 'default'; - $projectSelectFilter = session("userdata.projectSelectFilter") ?? array( + $projectSelectFilter = session("usersettings.projectSelectFilter") ?? array( "groupBy" => "structure", "client" => null, ); diff --git a/app/Domain/Menu/Composers/ProjectSelector.php b/app/Domain/Menu/Composers/ProjectSelector.php index 05b9171fe..928eb07fb 100644 --- a/app/Domain/Menu/Composers/ProjectSelector.php +++ b/app/Domain/Menu/Composers/ProjectSelector.php @@ -61,7 +61,7 @@ public function with(): array $projectType = ''; $menuType = 'default'; - $projectSelectFilter = session("userdata.projectSelectFilter", array( + $projectSelectFilter = session("usersettings.projectSelectFilter", array( "groupBy" => "structure", "client" => null, )); diff --git a/app/Domain/Menu/Hxcontrollers/ProjectSelector.php b/app/Domain/Menu/Hxcontrollers/ProjectSelector.php index 9d8d5bfdc..dd9e94de7 100644 --- a/app/Domain/Menu/Hxcontrollers/ProjectSelector.php +++ b/app/Domain/Menu/Hxcontrollers/ProjectSelector.php @@ -66,7 +66,7 @@ public function updateMenu(): void "client" => (int)$_POST['client'] ?? null, ); - session(["userdata.projectSelectFilter"=> $projectSelectFilter]); + session(["usersettings.projectSelectFilter"=> $projectSelectFilter]); if (session()->exists("userdata")) { //Getting all projects (ignoring client filter, clients are filtered on the frontend) diff --git a/app/Domain/Menu/Repositories/Menu.php b/app/Domain/Menu/Repositories/Menu.php index 4f24255ce..234f1af31 100644 --- a/app/Domain/Menu/Repositories/Menu.php +++ b/app/Domain/Menu/Repositories/Menu.php @@ -153,10 +153,10 @@ public function __construct( /** @var AuthService */ private AuthService $authService, ) { - if (session()->exists("submenuToggle") === false && session()->exists("userdata") === true) { + if (session()->exists("usersettings.submenuToggle") === false && session()->exists("userdata") === true) { $setting = $this->settingsRepo; session([ - "submenuToggle" => unserialize( + "usersettings.submenuToggle" => unserialize( $setting->getSetting("usersetting." . session("userdata.id") . ".submenuToggle") ), ]); @@ -197,12 +197,12 @@ public function getMenuTypes(): array public function setSubmenuState(string $submenu, string $state): void { - if (session()->exists("submenuToggle") && is_array(session("submenuToggle")) && $submenu !== false) { - session(["submenuToggle." . $submenu => $state]); + if (session()->exists("usersettings.submenuToggle") && is_array(session("usersettings.submenuToggle")) && $submenu !== false) { + session(["usersettings.submenuToggle." . $submenu => $state]); } $setting = $this->settingsRepo; - $setting->saveSetting("usersetting." . session("userdata.id") . ".submenuToggle", serialize(session("submenuToggle"))); + $setting->saveSetting("usersetting." . session("userdata.id") . ".submenuToggle", serialize(session("usersettings.submenuToggle"))); } /** @@ -216,9 +216,9 @@ public function getSubmenuState(string $submenu) $setting = $this->settingsRepo; $subStructure = $setting->getSetting("usersetting." . session("userdata.id") . ".submenuToggle"); - session(["submenuToggle" => unserialize($subStructure)]); + session(["usersettings.submenuToggle" => unserialize($subStructure)]); - return session("submenuToggle." . $submenu) ?? false; + return session("usersettings.submenuToggle." . $submenu) ?? false; } protected function buildMenuStructure(array $menuStructure, string $filter): array @@ -274,8 +274,8 @@ function ($menu) use ($menuType, $filter) { $menuStructure = $this->menuStructures[$menuType]; - if (session()->exists("submenuToggle") === false || is_array(session("submenuToggle")) === false) { - session(["submenuToggle" => array()]); + if (session()->exists("usersettings.submenuToggle") === false || is_array(session("usersettings.submenuToggle")) === false) { + session(["usersettings.submenuToggle" => array()]); } ksort($menuStructure); @@ -306,8 +306,8 @@ function ($menu) use ($menuType, $filter) { if ($element['visual'] == 'always') { $menuStructure[$key]['visual'] = 'open'; } else { - $submenuState = session("submenuToggle." . $element['id']) ?? $element['visual']; - session(["submenuToggle." . $element['id'] => $submenuState]); + $submenuState = session("usersettings.submenuToggle." . $element['id']) ?? $element['visual']; + session(["usersettings.submenuToggle." . $element['id'] => $submenuState]); } $menuStructure[$key]['visual'] = $submenuState; diff --git a/app/Domain/Menu/Templates/partials/clientGroup.blade.php b/app/Domain/Menu/Templates/partials/clientGroup.blade.php index b4d06a000..e5f9f7a20 100644 --- a/app/Domain/Menu/Templates/partials/clientGroup.blade.php +++ b/app/Domain/Menu/Templates/partials/clientGroup.blade.php @@ -7,14 +7,14 @@ @foreach($projects as $project) @php - $parentState = session("submenuToggle.".$prefix.'-projectSelectorlist-group-'.$project['clientId'], 'closed'); + $parentState = session("usersettings.submenuToggle.".$prefix.'-projectSelectorlist-group-'.$project['clientId'], 'closed'); @endphp @if( - !session()->exists("userdata.projectSelectFilter.client") - || session("userdata.projectSelectFilter.client") == $project["clientId"] - || session("userdata.projectSelectFilter.client") == 0 - || session("userdata.projectSelectFilter.client") == "" + !session()->exists("usersettings.projectSelectFilter.client") + || session("usersettings.projectSelectFilter.client") == $project["clientId"] + || session("usersettings.projectSelectFilter.client") == 0 + || session("usersettings.projectSelectFilter.client") == "" ) @if ($lastClient != $project['clientName']) diff --git a/app/Domain/Menu/Templates/partials/noGroup.blade.php b/app/Domain/Menu/Templates/partials/noGroup.blade.php index 5b1dbcb93..45faa3f38 100644 --- a/app/Domain/Menu/Templates/partials/noGroup.blade.php +++ b/app/Domain/Menu/Templates/partials/noGroup.blade.php @@ -2,10 +2,10 @@ @foreach($projects as $project) @if( - !session()->exists("userdata.projectSelectFilter.client") - || session("userdata.projectSelectFilter.client") == $project["clientId"] - || session("userdata.projectSelectFilter.client") == 0 - || session("userdata.projectSelectFilter.client") == "" + !session()->exists("usersettings.projectSelectFilter.client") + || session("usersettings.projectSelectFilter.client") == $project["clientId"] + || session("usersettings.projectSelectFilter.client") == 0 + || session("usersettings.projectSelectFilter.client") == "" )
  • diff --git a/app/Domain/Menu/Templates/partials/projectGroup.blade.php b/app/Domain/Menu/Templates/partials/projectGroup.blade.php index 817ec98aa..e6af2e3e3 100644 --- a/app/Domain/Menu/Templates/partials/projectGroup.blade.php +++ b/app/Domain/Menu/Templates/partials/projectGroup.blade.php @@ -1,20 +1,20 @@ @php - $groupState = session("submenuToggle.".$prefix.'-projectSelectorlist-group-'.$parent, 'closed'); + $groupState = session("usersettings.submenuToggle.".$prefix.'-projectSelectorlist-group-'.$parent, 'closed'); @endphp