diff --git a/apps/files/lib/Sharing/Property/NodeGridViewSharePropertyType.php b/apps/files/lib/Sharing/Property/NodeGridViewSharePropertyType.php index 86a2c79121ef2..d801d9cf130cd 100644 --- a/apps/files/lib/Sharing/Property/NodeGridViewSharePropertyType.php +++ b/apps/files/lib/Sharing/Property/NodeGridViewSharePropertyType.php @@ -21,7 +21,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { return null; } diff --git a/core/Sharing/Property/ExpirationDateSharePropertyType.php b/core/Sharing/Property/ExpirationDateSharePropertyType.php index 7def2d4b7eae5..0bd213c607539 100644 --- a/core/Sharing/Property/ExpirationDateSharePropertyType.php +++ b/core/Sharing/Property/ExpirationDateSharePropertyType.php @@ -39,7 +39,11 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { + if ($this->isRequired($share)) { + return $l10nFactory->get(Application::APP_ID)->t('Your administrator has enforced a %d days expiration policy.', [$this->getMaxExpirationDays($share)]); + } + return null; } @@ -62,6 +66,7 @@ public function isRequired(Share $share): bool { if ($this->hasRemoteRecipient($share) && $this->legacyManager->shareApiRemoteDefaultExpireDateEnforced()) { return true; } + return $this->hasLocalNonTokenAndEmailRecipient($share) && $this->legacyManager->shareApiInternalDefaultExpireDateEnforced(); } @@ -86,7 +91,7 @@ public function getMaxDate(Share $share): ?DateTimeImmutable { return null; } - private function getMaxExpirationDate(Share $share): ?DateTimeImmutable { + private function getMaxExpirationDays(Share $share): ?int { $days = INF; if ($this->hasTokenOrEmailRecipient($share) && $this->legacyManager->shareApiLinkDefaultExpireDate()) { @@ -102,6 +107,15 @@ private function getMaxExpirationDate(Share $share): ?DateTimeImmutable { } if ($days !== INF) { + return $days; + } + + return null; + } + + private function getMaxExpirationDate(Share $share): ?DateTimeImmutable { + $days = $this->getMaxExpirationDays($share); + if ($days !== null) { return $this->now->add(new DateInterval('P' . $days . 'D')); } diff --git a/core/Sharing/Property/LabelSharePropertyType.php b/core/Sharing/Property/LabelSharePropertyType.php index d270d73cf06a3..b3cb93beb551e 100644 --- a/core/Sharing/Property/LabelSharePropertyType.php +++ b/core/Sharing/Property/LabelSharePropertyType.php @@ -21,7 +21,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { return null; } diff --git a/core/Sharing/Property/NoteSharePropertyType.php b/core/Sharing/Property/NoteSharePropertyType.php index e93b0c8cdceaf..04735a90562bd 100644 --- a/core/Sharing/Property/NoteSharePropertyType.php +++ b/core/Sharing/Property/NoteSharePropertyType.php @@ -21,7 +21,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { return null; } diff --git a/core/Sharing/Property/PasswordSharePropertyType.php b/core/Sharing/Property/PasswordSharePropertyType.php index 5651c4e8e8265..190d4cde6e2c9 100644 --- a/core/Sharing/Property/PasswordSharePropertyType.php +++ b/core/Sharing/Property/PasswordSharePropertyType.php @@ -41,7 +41,11 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { + if ($this->isRequired($share)) { + return $l10nFactory->get(Application::APP_ID)->t('Your administrator has enforced a password protection.'); + } + return null; } diff --git a/lib/public/Sharing/Property/ISharePropertyType.php b/lib/public/Sharing/Property/ISharePropertyType.php index 9a06a82bf7a1a..1eb05c8bec3cd 100644 --- a/lib/public/Sharing/Property/ISharePropertyType.php +++ b/lib/public/Sharing/Property/ISharePropertyType.php @@ -43,7 +43,7 @@ public function getDisplayName(IFactory $l10nFactory): string; * @return ?non-empty-string * @since 35.0.0 */ - public function getHint(IFactory $l10nFactory): ?string; + public function getHint(IFactory $l10nFactory, Share $share): ?string; /** * Returns a priority used for sorting the properties for the user interface. diff --git a/lib/public/Sharing/Property/ShareProperty.php b/lib/public/Sharing/Property/ShareProperty.php index 4acdc5a11feea..37eed802b82d8 100644 --- a/lib/public/Sharing/Property/ShareProperty.php +++ b/lib/public/Sharing/Property/ShareProperty.php @@ -47,7 +47,7 @@ public function format(ISharingRegistry $registry, IFactory $l10nFactory, Share return $propertyType->format($share, [ 'class' => $this->class, 'display_name' => $propertyType->getDisplayName($l10nFactory), - 'hint' => $propertyType->getHint($l10nFactory), + 'hint' => $propertyType->getHint($l10nFactory, $share), 'priority' => $propertyType->getPriority(), 'advanced' => $propertyType->isAdvanced(), 'required' => $propertyType->isRequired($share), diff --git a/tests/lib/Sharing/Property/ABooleanSharePropertyTypeTest.php b/tests/lib/Sharing/Property/ABooleanSharePropertyTypeTest.php index 7be79c2f8016f..a6ff9b858f43b 100644 --- a/tests/lib/Sharing/Property/ABooleanSharePropertyTypeTest.php +++ b/tests/lib/Sharing/Property/ABooleanSharePropertyTypeTest.php @@ -24,7 +24,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { throw new \RuntimeException(); } diff --git a/tests/lib/Sharing/Property/ADateSharePropertyTypeTest.php b/tests/lib/Sharing/Property/ADateSharePropertyTypeTest.php index 2151e3cc8f123..4d9d88b3e7d2f 100644 --- a/tests/lib/Sharing/Property/ADateSharePropertyTypeTest.php +++ b/tests/lib/Sharing/Property/ADateSharePropertyTypeTest.php @@ -43,7 +43,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { throw new \RuntimeException(); } diff --git a/tests/lib/Sharing/Property/AEnumSharePropertyTypeTest.php b/tests/lib/Sharing/Property/AEnumSharePropertyTypeTest.php index 3e59588ffc907..93e03b8e1d747 100644 --- a/tests/lib/Sharing/Property/AEnumSharePropertyTypeTest.php +++ b/tests/lib/Sharing/Property/AEnumSharePropertyTypeTest.php @@ -38,7 +38,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { throw new \RuntimeException(); } diff --git a/tests/lib/Sharing/Property/APasswordSharePropertyTypeTest.php b/tests/lib/Sharing/Property/APasswordSharePropertyTypeTest.php index d0d3d59c041e6..737e26bfa5a10 100644 --- a/tests/lib/Sharing/Property/APasswordSharePropertyTypeTest.php +++ b/tests/lib/Sharing/Property/APasswordSharePropertyTypeTest.php @@ -29,7 +29,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { throw new RuntimeException(); } diff --git a/tests/lib/Sharing/Property/AStringSharePropertyTypeTest.php b/tests/lib/Sharing/Property/AStringSharePropertyTypeTest.php index 6838fd2c93337..31b691bed1431 100644 --- a/tests/lib/Sharing/Property/AStringSharePropertyTypeTest.php +++ b/tests/lib/Sharing/Property/AStringSharePropertyTypeTest.php @@ -42,7 +42,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): ?string { + public function getHint(IFactory $l10nFactory, Share $share): ?string { throw new \RuntimeException(); } diff --git a/tests/lib/Sharing/TestSharePropertyType1.php b/tests/lib/Sharing/TestSharePropertyType1.php index 3e9fb15e81908..771ed72ef8096 100644 --- a/tests/lib/Sharing/TestSharePropertyType1.php +++ b/tests/lib/Sharing/TestSharePropertyType1.php @@ -28,7 +28,7 @@ public function getDisplayName(IFactory $l10nFactory): string { } #[\Override] - public function getHint(IFactory $l10nFactory): string { + public function getHint(IFactory $l10nFactory, Share $share): string { return 'hint ' . $this->getDisplayName($l10nFactory); }