summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/l10n/gl.js1
-rw-r--r--lib/l10n/gl.json1
-rw-r--r--lib/private/Share20/Manager.php66
-rw-r--r--lib/private/Template/JSConfigHelper.php10
4 files changed, 69 insertions, 9 deletions
diff --git a/lib/l10n/gl.js b/lib/l10n/gl.js
index 6fad756f0f5..0a226a0e5c1 100644
--- a/lib/l10n/gl.js
+++ b/lib/l10n/gl.js
@@ -72,6 +72,7 @@ OC.L10N.register(
"Empty file" : "Ficheiro baleiro",
"Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator." : "Non existe o módulo co ID: %s. Actíveo nos axustes das aplicacións ou contacte co administrador.",
"File already exists" : "O ficheiro xa existe",
+ "Invalid path" : "Ruta incorrecta.",
"Failed to create file from template" : "Produciuse un fallo ao crear un ficheiro a partir do modelo",
"Templates" : "Modelos",
"File name is a reserved word" : "O nome de ficheiro é unha palabra reservada",
diff --git a/lib/l10n/gl.json b/lib/l10n/gl.json
index 56181c627c1..8cca60bd407 100644
--- a/lib/l10n/gl.json
+++ b/lib/l10n/gl.json
@@ -70,6 +70,7 @@
"Empty file" : "Ficheiro baleiro",
"Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator." : "Non existe o módulo co ID: %s. Actíveo nos axustes das aplicacións ou contacte co administrador.",
"File already exists" : "O ficheiro xa existe",
+ "Invalid path" : "Ruta incorrecta.",
"Failed to create file from template" : "Produciuse un fallo ao crear un ficheiro a partir do modelo",
"Templates" : "Modelos",
"File name is a reserved word" : "O nome de ficheiro é unha palabra reservada",
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 49a716e3216..7211a4eb1e8 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -385,6 +385,8 @@ class Manager implements IManager {
* @throws \Exception
*/
protected function validateExpirationDateInternal(IShare $share) {
+ $isRemote = $share->getShareType() === IShare::TYPE_REMOTE || $share->getShareType() === IShare::TYPE_REMOTE_GROUP;
+
$expirationDate = $share->getExpirationDate();
if ($expirationDate !== null) {
@@ -407,28 +409,39 @@ class Manager implements IManager {
// This is a new share
}
- if ($fullId === null && $expirationDate === null && $this->shareApiInternalDefaultExpireDate()) {
+ if ($isRemote) {
+ $defaultExpireDate = $this->shareApiRemoteDefaultExpireDate();
+ $defaultExpireDays = $this->shareApiRemoteDefaultExpireDays();
+ $configProp = 'remote_defaultExpDays';
+ $isEnforced = $this->shareApiRemoteDefaultExpireDateEnforced();
+ } else {
+ $defaultExpireDate = $this->shareApiInternalDefaultExpireDate();
+ $defaultExpireDays = $this->shareApiInternalDefaultExpireDays();
+ $configProp = 'internal_defaultExpDays';
+ $isEnforced = $this->shareApiInternalDefaultExpireDateEnforced();
+ }
+ if ($fullId === null && $expirationDate === null && $defaultExpireDate) {
$expirationDate = new \DateTime();
$expirationDate->setTime(0,0,0);
- $days = (int)$this->config->getAppValue('core', 'internal_defaultExpDays', (string)$this->shareApiInternalDefaultExpireDays());
- if ($days > $this->shareApiInternalDefaultExpireDays()) {
- $days = $this->shareApiInternalDefaultExpireDays();
+ $days = (int)$this->config->getAppValue('core', $configProp, (string)$defaultExpireDays);
+ if ($days > $defaultExpireDays) {
+ $days = $defaultExpireDays;
}
$expirationDate->add(new \DateInterval('P'.$days.'D'));
}
// If we enforce the expiration date check that is does not exceed
- if ($this->shareApiInternalDefaultExpireDateEnforced()) {
+ if ($isEnforced) {
if ($expirationDate === null) {
throw new \InvalidArgumentException('Expiration date is enforced');
}
$date = new \DateTime();
$date->setTime(0, 0, 0);
- $date->add(new \DateInterval('P' . $this->shareApiInternalDefaultExpireDays() . 'D'));
+ $date->add(new \DateInterval('P' . $defaultExpireDays . 'D'));
if ($date < $expirationDate) {
- $message = $this->l->t('Can’t set expiration date more than %s days in the future', [$this->shareApiInternalDefaultExpireDays()]);
+ $message = $this->l->t('Can’t set expiration date more than %s days in the future', [$defaultExpireDays]);
throw new GenericShareException($message, $message, 404);
}
}
@@ -751,6 +764,9 @@ class Manager implements IManager {
// Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
+ } elseif ($share->getShareType() === IShare::TYPE_REMOTE || $share->getShareType() === IShare::TYPE_REMOTE_GROUP) {
+ //Verify the expiration date
+ $share = $this->validateExpirationDateInternal($share);
} elseif ($share->getShareType() === IShare::TYPE_LINK
|| $share->getShareType() === IShare::TYPE_EMAIL) {
$this->linkCreateChecks($share);
@@ -999,7 +1015,7 @@ class Manager implements IManager {
if (empty($plainTextPassword) && $share->getSendPasswordByTalk()) {
throw new \InvalidArgumentException('Can’t enable sending the password by Talk with an empty password');
}
-
+
/**
* If we're in a mail share, we need to force a password change
* as either the user is not aware of the password or is already (received by mail)
@@ -1019,6 +1035,12 @@ class Manager implements IManager {
$this->validateExpirationDateLink($share);
$expirationDateUpdated = true;
}
+ } elseif ($share->getShareType() === IShare::TYPE_REMOTE || $share->getShareType() === IShare::TYPE_REMOTE_GROUP) {
+ if ($share->getExpirationDate() != $originalShare->getExpirationDate()) {
+ //Verify the expiration date
+ $this->validateExpirationDateInternal($share);
+ $expirationDateUpdated = true;
+ }
}
$this->pathCreateChecks($share->getNode());
@@ -1784,8 +1806,17 @@ class Manager implements IManager {
}
/**
+ * Is default remote expire date enabled
+ *
+ * @return bool
+ */
+ public function shareApiRemoteDefaultExpireDate(): bool {
+ return $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes';
+ }
+
+ /**
* Is default expire date enforced
- *`
+ *
* @return bool
*/
public function shareApiInternalDefaultExpireDateEnforced(): bool {
@@ -1793,6 +1824,15 @@ class Manager implements IManager {
$this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes';
}
+ /**
+ * Is default expire date enforced for remote shares
+ *
+ * @return bool
+ */
+ public function shareApiRemoteDefaultExpireDateEnforced(): bool {
+ return $this->shareApiRemoteDefaultExpireDate() &&
+ $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes';
+ }
/**
* Number of default expire days
@@ -1803,6 +1843,14 @@ class Manager implements IManager {
}
/**
+ * Number of default expire days for remote shares
+ * @return int
+ */
+ public function shareApiRemoteDefaultExpireDays(): int {
+ return (int)$this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7');
+ }
+
+ /**
* Allow public upload on link shares
*
* @return bool
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index cd466575601..c8f5fc63b70 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -165,6 +165,13 @@ class JSConfigHelper {
$defaultInternalExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no') === 'yes';
}
+ $defaultRemoteExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_remote_expire_date', 'no') === 'yes';
+ $defaultRemoteExpireDate = $defaultRemoteExpireDateEnforced = null;
+ if ($defaultRemoteExpireDateEnabled) {
+ $defaultRemoteExpireDate = (int)$this->config->getAppValue('core', 'shareapi_remote_expire_after_n_days', '7');
+ $defaultRemoteExpireDateEnforced = $this->config->getAppValue('core', 'shareapi_enforce_remote_expire_date', 'no') === 'yes';
+ }
+
$countOfDataLocation = 0;
$dataLocation = str_replace(\OC::$SERVERROOT . '/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation);
if ($countOfDataLocation !== 1 || $uid === null || !$this->groupManager->isAdmin($uid)) {
@@ -278,6 +285,9 @@ class JSConfigHelper {
'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled,
'defaultInternalExpireDate' => $defaultInternalExpireDate,
'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced,
+ 'defaultRemoteExpireDateEnabled' => $defaultRemoteExpireDateEnabled,
+ 'defaultRemoteExpireDate' => $defaultRemoteExpireDate,
+ 'defaultRemoteExpireDateEnforced' => $defaultRemoteExpireDateEnforced,
]
]),
"_theme" => json_encode([