Release 2.12 (#4609)

This commit is contained in:
Kevin Papst
2024-02-07 23:47:25 +01:00
committed by GitHub
parent 7abe787778
commit 85a16a9363
394 changed files with 1189 additions and 6735 deletions

View File

@@ -51,7 +51,7 @@ final class LocaleService
public function isKnownLocale(string $language): bool
{
return \in_array($language, $this->getAllLocales());
return \in_array($language, $this->getAllLocales(), true);
}
/**

View File

@@ -17,11 +17,11 @@ class Constants
/**
* The current release version
*/
public const VERSION = '2.11.0';
public const VERSION = '2.12.0';
/**
* The current release: major * 10000 + minor * 100 + patch
*/
public const VERSION_ID = 21100;
public const VERSION_ID = 21200;
/**
* The software name
*/

View File

@@ -15,12 +15,16 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\SecurityRequestAttributes;
#[Route(path: '/saml')]
final class SamlController extends AbstractController
{
public function __construct(private SamlAuthFactory $authFactory, private SamlConfigurationInterface $samlConfiguration)
public function __construct(
private readonly SamlAuthFactory $authFactory,
private readonly SamlConfigurationInterface $samlConfiguration
)
{
}
@@ -51,7 +55,12 @@ final class SamlController extends AbstractController
}
// this does set headers and exit as $stay is not set to true
$url = $this->authFactory->create()->login($session->get('_security.main.target_path'));
$redirectTarget = $session->get('_security.main.target_path');
if ($redirectTarget === null || $redirectTarget === '') {
$redirectTarget = $this->generateUrl('homepage', [], UrlGeneratorInterface::ABSOLUTE_URL);
}
$url = $this->authFactory->create()->login($redirectTarget);
if ($url === null) {
throw new \RuntimeException('SAML login failed');

View File

@@ -209,8 +209,9 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
private array $roles = [];
/**
* If not empty two-factor authentication is enabled.
* TODO reduce the length, which was initially forgotten and set to 255, as this is the default for MySQL with Doctrine (see migration Version20230126002049)
*/
#[ORM\Column(name: 'totp_secret', type: 'string', nullable: true)]
#[ORM\Column(name: 'totp_secret', type: 'string', length: 255, nullable: true)]
private ?string $totpSecret = null;
#[ORM\Column(name: 'totp_enabled', type: 'boolean', nullable: false, options: ['default' => false])]
private bool $totpEnabled = false;
@@ -1287,9 +1288,11 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
return $group === null ? $group : (string) $group;
}
public function getHolidaysPerYear(): int
public function getHolidaysPerYear(): float
{
return (int) $this->getPreferenceValue(UserPreference::HOLIDAYS_PER_YEAR, 0);
$holidays = $this->getPreferenceValue(UserPreference::HOLIDAYS_PER_YEAR, 0.0);
return $this->getFormattedHoliday(is_numeric($holidays) ? $holidays : 0.0);
}
public function setWorkHoursMonday(int $seconds): void
@@ -1332,14 +1335,28 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
$this->setPreferenceValue(UserPreference::PUBLIC_HOLIDAY_GROUP, $group);
}
public function setHolidaysPerYear(?int $holidays): void
public function setHolidaysPerYear(?float $holidays): void
{
$this->setPreferenceValue(UserPreference::HOLIDAYS_PER_YEAR, $holidays ?? 0);
if ($holidays !== null) {
// makes sure that the number is a multiple of 0.5
$holidays = $this->getFormattedHoliday($holidays);
}
$this->setPreferenceValue(UserPreference::HOLIDAYS_PER_YEAR, $holidays ?? 0.0);
}
private function getFormattedHoliday(int|float|string|null $holidays): float
{
if (!is_numeric($holidays)) {
$holidays = 0.0;
}
return (float) number_format((round($holidays * 2) / 2), 1);
}
public function hasContractSettings(): bool
{
return $this->hasWorkHourConfiguration() || $this->getHolidaysPerYear() !== 0;
return $this->hasWorkHourConfiguration() || $this->getHolidaysPerYear() !== 0.0;
}
public function hasWorkHourConfiguration(): bool