TYPO3 v15 dev-main snapshot ()

This commit is contained in:
2026-08-10 22:31:03 +02:00
commit 61d66df078
65 changed files with 8311 additions and 0 deletions
+240
View File
@@ -0,0 +1,240 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Beuser\Domain\Model;
use TYPO3\CMS\Backend\Authentication\PasswordReset;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Model for backend user
* @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
*/
class BackendUser extends AbstractEntity
{
#[Extbase\Validate(validator: 'NotEmpty')]
protected string $userName = '';
/**
* @var ObjectStorage<BackendUserGroup>
*/
protected ObjectStorage $backendUserGroups;
/**
* Comma separated list of uids in multi-select
* Might retrieve the labels from TCA/DataMapper
*/
protected string $allowedLanguages = '';
protected string $dbMountPoints = '';
protected string $description = '';
protected string $fileMountPoints = '';
protected bool $isAdministrator = false;
protected bool $isDisabled = false;
protected ?\DateTime $startDateAndTime = null;
protected ?\DateTime $endDateAndTime = null;
protected string $email = '';
protected string $realName = '';
protected ?\DateTime $lastLoginDateAndTime = null;
public function __construct()
{
$this->initializeObject();
}
public function initializeObject(): void
{
$this->backendUserGroups = new ObjectStorage();
}
public function setAllowedLanguages(string $allowedLanguages): void
{
$this->allowedLanguages = $allowedLanguages;
}
public function getAllowedLanguages(): string
{
return $this->allowedLanguages;
}
public function setDbMountPoints(string $dbMountPoints): void
{
$this->dbMountPoints = $dbMountPoints;
}
public function getDbMountPoints(): string
{
return $this->dbMountPoints;
}
public function setFileMountPoints(string $fileMountPoints): void
{
$this->fileMountPoints = $fileMountPoints;
}
public function getFileMountPoints(): string
{
return $this->fileMountPoints;
}
/**
* Check if user is active, not disabled
*/
public function isActive(): bool
{
if ($this->getIsDisabled()) {
return false;
}
$now = new \DateTime('now');
return (!$this->getStartDateAndTime() && !$this->getEndDateAndTime()) || ($this->getStartDateAndTime() <= $now && (!$this->getEndDateAndTime() || $this->getEndDateAndTime() > $now));
}
public function setBackendUserGroups(ObjectStorage $backendUserGroups): void
{
$this->backendUserGroups = $backendUserGroups;
}
/**
* @return ObjectStorage<BackendUserGroup>
*/
public function getBackendUserGroups(): ObjectStorage
{
return $this->backendUserGroups;
}
/**
* Check if user is currently logged in
*/
public function isCurrentlyLoggedIn(): bool
{
return $this->getUid() === (int)($this->getBackendUser()->user['uid'] ?? 0);
}
/**
* Check if the user is allowed to trigger a password reset
*
* Requirements:
* 1. The user for which the password reset should be triggered is not the currently logged in user
* 2. Password reset is enabled for the user (Email+Password are set)
* 3. The currently logged in user is allowed to reset passwords in the backend (Enabled in user TSconfig)
*/
public function isPasswordResetEnabled(): bool
{
return !$this->isCurrentlyLoggedIn()
&& GeneralUtility::makeInstance(PasswordReset::class)->isEnabledForUser((int)$this->getUid())
&& ($this->getBackendUser()->getTSConfig()['options.']['passwordReset'] ?? true);
}
public function getUserName(): string
{
return $this->userName;
}
public function setUserName(string $userName): void
{
$this->userName = $userName;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): void
{
$this->description = $description;
}
public function getIsAdministrator(): bool
{
return $this->isAdministrator;
}
public function setIsAdministrator(bool $isAdministrator): void
{
$this->isAdministrator = $isAdministrator;
}
public function getIsDisabled(): bool
{
return $this->isDisabled;
}
public function setIsDisabled(bool $isDisabled): void
{
$this->isDisabled = $isDisabled;
}
public function getStartDateAndTime(): ?\DateTime
{
return $this->startDateAndTime;
}
public function setStartDateAndTime(?\DateTime $dateAndTime = null): void
{
$this->startDateAndTime = $dateAndTime;
}
public function getEndDateAndTime(): ?\DateTime
{
return $this->endDateAndTime;
}
public function setEndDateAndTime(?\DateTime $dateAndTime = null): void
{
$this->endDateAndTime = $dateAndTime;
}
public function getEmail(): string
{
return $this->email;
}
public function setEmail(string $email): void
{
$this->email = $email;
}
public function getRealName(): string
{
return $this->realName;
}
public function setRealName(string $name): void
{
$this->realName = $name;
}
public function getLastLoginDateAndTime(): ?\DateTime
{
return $this->lastLoginDateAndTime;
}
public function setLastLoginDateAndTime(?\DateTime $dateAndTime = null): void
{
$this->lastLoginDateAndTime = $dateAndTime;
}
public function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Beuser\Domain\Model;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Model for backend user group
* @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
*/
class BackendUserGroup extends AbstractEntity
{
protected string $title = '';
protected string $description = '';
protected bool $hidden = false;
/**
* @var ObjectStorage<BackendUserGroup>
*/
#[Extbase\ORM\Lazy]
protected ObjectStorage $subGroups;
public function __construct()
{
$this->initializeObject();
}
public function initializeObject(): void
{
$this->subGroups = new ObjectStorage();
}
public function setTitle(string $title): void
{
$this->title = $title;
}
public function getTitle(): string
{
return $this->title;
}
public function getDescription(): string
{
return $this->description;
}
public function setDescription(string $description): void
{
$this->description = $description;
}
public function setHidden(bool $hidden): void
{
$this->hidden = $hidden;
}
public function getHidden(): bool
{
return $this->hidden;
}
public function setSubGroups(ObjectStorage $subGroups): void
{
$this->subGroups = $subGroups;
}
public function getSubGroups(): ObjectStorage
{
return $this->subGroups;
}
}
+115
View File
@@ -0,0 +1,115 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Beuser\Domain\Model;
/**
* Demand filter for listings
* @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
*/
class Demand
{
public const ALL = 0;
public const USERTYPE_ADMINONLY = 1;
public const USERTYPE_USERONLY = 2;
public const STATUS_ACTIVE = 1;
public const STATUS_INACTIVE = 2;
public const LOGIN_SOME = 1;
public const LOGIN_NONE = 2;
public const LOGIN_CURRENT = 3;
protected string $userName = '';
protected int $userType = self::ALL;
protected int $status = self::ALL;
protected int $logins = 0;
protected int $backendUserGroup = 0;
public static function fromUc(array $uc): self
{
$demand = new self();
$demand->userName = (string)($uc['userName'] ?? '');
$demand->userType = (int)($uc['userType'] ?? 0);
$demand->status = (int)($uc['status'] ?? 0);
$demand->logins = (int)($uc['logins'] ?? 0);
$demand->backendUserGroup = (int)($uc['backendUserGroup'] ?? 0);
return $demand;
}
public function forUc(): array
{
return [
'userName' => $this->getUserName(),
'userType' => $this->getUserType(),
'status' => $this->getStatus(),
'logins' => $this->getLogins(),
'backendUserGroup' => $this->getBackendUserGroup(),
];
}
public function setUserName(string $userName): void
{
$this->userName = $userName;
}
public function getUserName(): string
{
return $this->userName;
}
public function setUserType(int $userType): void
{
$this->userType = $userType;
}
public function getUserType(): int
{
return $this->userType;
}
public function setStatus(int $status): void
{
$this->status = $status;
}
public function getStatus(): int
{
return $this->status;
}
public function setLogins(int $logins): void
{
$this->logins = $logins;
}
public function getLogins(): int
{
return $this->logins;
}
public function setBackendUserGroup(int $backendUserGroup): void
{
$this->backendUserGroup = $backendUserGroup;
}
public function getBackendUserGroup(): int
{
return $this->backendUserGroup;
}
}
+140
View File
@@ -0,0 +1,140 @@
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Beuser\Domain\Model;
use TYPO3\CMS\Core\Resource\ResourceStorage;
use TYPO3\CMS\Core\Resource\StorageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Attribute as Extbase;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
*/
class FileMount extends AbstractEntity
{
/**
* Title of the file mount.
*/
#[Extbase\Validate(validator: 'NotEmpty')]
protected string $title = '';
/**
* Description of the file mount.
*/
protected string $description = '';
/**
* Identifier of the file mount
*/
protected string $identifier = '';
/**
* Status of the file mount
*/
protected bool $hidden = false;
/**
* Determines whether this file mount should be read only.
*/
protected bool $readOnly = false;
/**
* Getter for the title of the file mount.
*/
public function getTitle(): string
{
return $this->title;
}
/**
* Setter for the title of the file mount.
*/
public function setTitle(string $value): void
{
$this->title = $value;
}
/**
* Getter for the description of the file mount.
*/
public function getDescription(): string
{
return $this->description;
}
/**
* Setter for the description of the file mount.
*/
public function setDescription(string $description): void
{
$this->description = $description;
}
/**
* Setter for the readOnly property of the file mount.
*/
public function setReadOnly(bool $readOnly): void
{
$this->readOnly = $readOnly;
}
/**
* Getter for the readOnly property of the file mount.
*/
public function isReadOnly(): bool
{
return $this->readOnly;
}
public function getIdentifier(): string
{
return $this->identifier;
}
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
public function isHidden(): bool
{
return $this->hidden;
}
public function setHidden(bool $hidden): void
{
$this->hidden = $hidden;
}
/**
* returns the path segment of the file mount (without the storage id)
*/
public function getPath(): string
{
return explode(':/', $this->identifier)[1] ?? '';
}
/**
* @todo This should be part of the ORM not the model class
*/
public function getStorage(): ?ResourceStorage
{
return GeneralUtility::makeInstance(StorageRepository::class)->findByCombinedIdentifier($this->identifier);
}
}