Skip to content

Commit

Permalink
Merge pull request #1906 from Leantime/bugFixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
marcelfolaron committed Sep 25, 2023
2 parents fa5fa3c + 2836c3c commit be75f1e
Show file tree
Hide file tree
Showing 70 changed files with 551 additions and 540 deletions.
4 changes: 2 additions & 2 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/symfony2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/Core/AppSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/
class AppSettings
{
public $appVersion = "2.4-beta-3";
public $appVersion = "2.4-beta-4";

public $dbVersion = "2.1.21";
public $dbVersion = "2.1.22";

protected Environment $config;

Expand Down
18 changes: 12 additions & 6 deletions app/Core/Bootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,17 @@ public function boot(): void
}

if (! defined('CURRENT_URL')) {
define('CURRENT_URL', !empty($config->appUrl)
? $config->appUrl . $request->getPathInfo()
: $request->getFullUrl());
define('CURRENT_URL', BASE_URL . $request->getRequestUri());
}

$this->loadHeaders();

$this->checkIfInstalled();

$this->checkIfUpdated();

Events::discover_listeners();

$this->checkIfUpdated();

/**
* The beginning of the application
*
Expand Down Expand Up @@ -188,10 +186,13 @@ public function getApplication(): Application
$this->bindRequest();

// Setup Configuration
$this->app->singleton(Environment::class, Environment::class);
//$this->app->singleton(Environment::class, Environment::class);
$this->app->singleton(Environment::class, fn ($app) => $_SESSION['configclass'] ??= new Environment($app->make(DefaultConfig::class)));
$this->app->alias(Environment::class, \Illuminate\Contracts\Config\Repository::class);
$this->app->alias(Environment::class, alias: "config");



// specify singletons/instances
$this->app->singleton(Db::class, Db::class);
$this->app->singleton(Frontcontroller::class, Frontcontroller::class);
Expand Down Expand Up @@ -351,6 +352,8 @@ private function handleRequest(): void
$frontController = $this->app->make(Frontcontroller::class);
$incomingRequest = $this->app->make(IncomingRequest::class);

$this->publicActions = self::dispatch_filter("publicActions", $this->publicActions, ['bootloader' => $this]);

// handle public request
if (in_array($frontController::getCurrentRoute(), $this->publicActions)) {
$frontController::dispatch();
Expand All @@ -359,6 +362,9 @@ private function handleRequest(): void

// handle API request
if ($incomingRequest instanceof ApiRequest) {

self::dispatch_event("before_api_request", ['application' => $this]);

$apiKey = $incomingRequest->getAPIKey();
$apiUser = $this->app->make(ApiService::class)->getAPIKeyUser($apiKey);

Expand Down
5 changes: 4 additions & 1 deletion app/Core/DefaultConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ class DefaultConfig
"email":"mail",
"firstname":"displayname",
"lastname":"",
"phonenumber":""
"phone":"",
"jobTitle":"title",
"jobLevel":"level",
"department":"department"
}';
//For AD use
/*
Expand Down
4 changes: 2 additions & 2 deletions app/Core/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Environment implements ArrayAccess, ConfigContract
/**
* @var string S3 End Point
*/
public string $s3EndPoint;
public ?string $s3EndPoint;

/**
* @var string S3 Key
Expand Down Expand Up @@ -503,7 +503,7 @@ public function __construct(DefaultConfig $defaultConfiguration)
}

/* Plugins */
$this->plugins = $this->getString('LEAN_PLUGINS', '');
$this->plugins = $this->environmentHelper("LEAN_PLUGINS", $defaultConfiguration->plugins ?? '', "string");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Core/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static function discover_listeners(): void
$pluginPath = APP_ROOT . "/app/Plugins/";

$enabledPlugins = [];
if ($_SESSION['isInstalled'] === true && $_SESSION['isUpdated'] === true) {
if ($_SESSION['isInstalled'] === true) {
$pluginService = app()->make(\Leantime\Domain\Plugins\Services\Plugins::class);
$enabledPlugins = $pluginService->getEnabledPlugins();
}
Expand Down
5 changes: 5 additions & 0 deletions app/Core/Fileupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ public function displayImageFile($imageName, $fullPath = '')
);

if ($this->config->useS3 == true && $fullPath == '') {

$s3Client = new S3Client([
'version' => 'latest',
'region' => $this->config->s3Region,
Expand Down Expand Up @@ -394,6 +395,10 @@ public function displayImageFile($imageName, $fullPath = '')
if ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'gif' || $ext == 'png') {
header('Content-type: ' . $mimes[$ext]);
header('Content-disposition: inline; filename="' . $imageName . '";');
header('Pragma: public');
header('Cache-Control: max-age=900');
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 900));


readfile($fullPath);
}
Expand Down
30 changes: 9 additions & 21 deletions app/Core/Frontcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct(IncomingRequest $incomingRequest)
* @param integer $httpResponseCode
* @return void
*/
public static function dispatch($action = '', $httpResponseCode = 200): void
public static function dispatch(string $action = '', int $httpResponseCode = 200): void
{
self::$fullAction = empty($action) ? self::getCurrentRoute() : $action;

Expand All @@ -69,11 +69,7 @@ public static function dispatch($action = '', $httpResponseCode = 200): void
}

//execute action
try {
self::executeAction(self::$fullAction, array(), $httpResponseCode);
} catch (Exception $e) {
echo $e->getMessage();
}
self::executeAction(self::$fullAction, array(), $httpResponseCode);
}

/**
Expand All @@ -96,25 +92,17 @@ private static function executeAction($completeName, $params = array()): void
$incomingRequest = app()->make(IncomingRequest::class);
$controllerType = $incomingRequest instanceof HtmxRequest ? 'Hxcontrollers' : 'Controllers';

// Execute The Route
try {
//Setting default response code to 200, can be changed in controller
self::setResponseCode(200);

$classname = "$namespace\\$controllerNs\\$moduleName\\$controllerType\\$actionName";
//Setting default response code to 200, can be changed in controller
self::setResponseCode(200);

if (! class_exists($classname)) {
self::redirect(BASE_URL . "/errors/error404", 404);
}
$classname = "$namespace\\$controllerNs\\$moduleName\\$controllerType\\$actionName";

app()->make($classname);
} catch (Exception $e) {
error_log($e, 0);
self::redirect(BASE_URL . "/errors/error500", 500);

return;
if (! class_exists($classname)) {
self::redirect(BASE_URL . "/errors/error404", 404);
}

app()->make($classname);

self::$lastAction = $completeName;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Core/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Mailer
* @access public
* @return void
*/
public function __construct(\Leantime\Core\Environment $config, language $language)
public function __construct(\Leantime\Core\Environment $config, Language $language)
{
if ($config->email != '') {
$this->emailDomain = $config->email;
Expand Down
10 changes: 10 additions & 0 deletions app/Core/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,16 @@ public function setupDirectives()
'endspaceless',
fn ($args) => "<?php echo preg_replace('/>\\s+</', '><', ob_get_clean()); ?>",
);

$this->bladeCompiler->directive(
'formatDate',
fn ($args) => "<?php echo \$tpl->getFormattedDateString($args); ?>",
);

$this->bladeCompiler->directive(
'formatTime',
fn ($args) => "<?php echo \$tpl->getFormattedTimeString($args); ?>",
);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions app/Domain/Api/Controllers/ApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public function init(
UserRepository $userRepo,
ClientRepository $clientsRepo
) {

self::dispatch_event('api_key_init', $this);

$this->projectsRepo = $projectsRepo;
$this->userRepo = $userRepo;
$this->clientsRepo = $clientsRepo;
Expand Down
3 changes: 3 additions & 0 deletions app/Domain/Api/Controllers/NewApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function init(
UserService $userService,
ApiService $APIService
) {

self::dispatch_event('api_key_init', $this);

$this->userRepo = $userRepo;
$this->projectsRepo = $projectsRepo;
$this->userService = $userService;
Expand Down
89 changes: 0 additions & 89 deletions app/Domain/Auth/Controllers/LoginInfo.php

This file was deleted.

1 change: 1 addition & 0 deletions app/Domain/Auth/Services/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ public function setUserSession($user, $isLdap = false)
'twoFASecret' => $this->twoFASecret,
'isLdap' => $isLdap,
'createdOn' => $user['createdOn'] ?? '',
'modified' => $user['modified'] ?? date("Y-m-d H:i:s"),
]);

$this->updateUserSessionDB($this->userId, $this->session);
Expand Down
Loading

0 comments on commit be75f1e

Please sign in to comment.