diff --git a/core/src/plugins/action.share/class.ShareCenter.php b/core/src/plugins/action.share/class.ShareCenter.php index d6cbc01e09..e3af1b7d91 100644 --- a/core/src/plugins/action.share/class.ShareCenter.php +++ b/core/src/plugins/action.share/class.ShareCenter.php @@ -415,8 +415,8 @@ public function switchAction($action, $httpVars, $fileVars) throw new Exception("Cannot share a non-existing file: ".$ajxpNode->getUrl()); } - $this->updateToMaxAllowedValue($httpVars, "FILE_MAX_DOWNLOAD", "downloadlimit"); - $this->updateToMaxAllowedValue($httpVars, "FILE_MAX_EXPIRATION", "expiration"); + $this->updateToMaxAllowedValue($httpVars, "downloadlimit", "FILE_MAX_DOWNLOAD"); + $this->updateToMaxAllowedValue($httpVars, "expiration", "FILE_MAX_EXPIRATION"); $newMeta = null; $httpHash = null; diff --git a/core/src/plugins/action.share/class.ShareRightsManager.php b/core/src/plugins/action.share/class.ShareRightsManager.php index 14d678f9b1..00695018c7 100644 --- a/core/src/plugins/action.share/class.ShareRightsManager.php +++ b/core/src/plugins/action.share/class.ShareRightsManager.php @@ -86,13 +86,16 @@ public function prepareSharedUserEntry($httpVars, &$shareObject, $update, $guest $this->store->testUserCanEditShare($existingRepo->getOwner(), $existingRepo->options); } $uniqueUser = $shareObject->getUniqueUser(); - if($guestUserPass !== null && strlen($guestUserPass)) { $userPass = $guestUserPass; $shareObject->setUniqueUser($uniqueUser, true); }else if(!$shareObject->shouldRequirePassword() || ($guestUserPass !== null && $guestUserPass == "")){ $shareObject->setUniqueUser($uniqueUser, false); } + if($update && $forcePassword && !($shareObject instanceof \Pydio\OCS\Model\TargettedLink) && !$shareObject->shouldRequirePassword() && empty($guestUserPass)){ + $mess = ConfService::getMessages(); + throw new Exception($mess["share_center.175"]); + } } else { diff --git a/core/src/plugins/action.share/res/i18n/ca.php b/core/src/plugins/action.share/res/i18n/ca.php index 626b449a9e..95e47a56b4 100644 --- a/core/src/plugins/action.share/res/i18n/ca.php +++ b/core/src/plugins/action.share/res/i18n/ca.php @@ -228,4 +228,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); \ No newline at end of file diff --git a/core/src/plugins/action.share/res/i18n/de.php b/core/src/plugins/action.share/res/i18n/de.php index ecaa16931b..f7b59b5cfe 100644 --- a/core/src/plugins/action.share/res/i18n/de.php +++ b/core/src/plugins/action.share/res/i18n/de.php @@ -227,4 +227,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); diff --git a/core/src/plugins/action.share/res/i18n/en.php b/core/src/plugins/action.share/res/i18n/en.php index 0850813ecd..d2eac18ac3 100644 --- a/core/src/plugins/action.share/res/i18n/en.php +++ b/core/src/plugins/action.share/res/i18n/en.php @@ -23,7 +23,7 @@ "18"=> "Folder is shared as a new workspace", "19"=> "Shared workspace options were successfully modified", "20"=> "Ooops, the file you required could not be found! Maybe it was deleted or it is not shared with you anymore.", - "21"=> "Expire in (days)", + "21"=> "Will expire on", "22"=> "Allowed Downloads", "23"=> "Password", "24"=> "Set expiration limits or define a password to access this share.", @@ -98,7 +98,7 @@ "89"=> "Number of downloads / authorized downloads. Click to reset download counter.", "90"=> "Link URL", "91"=> "Tags (Enter to save)", - "92"=> "New link", + "92"=> "Create link", "93"=> "Existing links", "94"=> "QR Code", "95"=> "QR code", @@ -227,4 +227,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); diff --git a/core/src/plugins/action.share/res/i18n/es.php b/core/src/plugins/action.share/res/i18n/es.php index b6830c824d..24ee4cc4a0 100644 --- a/core/src/plugins/action.share/res/i18n/es.php +++ b/core/src/plugins/action.share/res/i18n/es.php @@ -226,5 +226,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", - + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); \ No newline at end of file diff --git a/core/src/plugins/action.share/res/i18n/fr.php b/core/src/plugins/action.share/res/i18n/fr.php index 7c884be3c6..edf41106ad 100644 --- a/core/src/plugins/action.share/res/i18n/fr.php +++ b/core/src/plugins/action.share/res/i18n/fr.php @@ -22,7 +22,7 @@ "18"=> "Le répertoire a été partagé comme un nouveau dépôt", "19"=> "Les options de partage ont été modifiées avec succès", "20"=> "Désolé, le fichier que vous avez demandé ne peut pas être trouvé ! Peut-être a-t-il été supprimé, ou il n'est plus partagé avec vous.", -"21"=> "Expire dans (jours)", +"21"=> "Expirera le", "22"=> "Téléchargements autorisés", "23"=> "Mot de passe", "24"=> "Définissez des limites d'expiration ou un mot de passe pour accèder au partage", @@ -97,7 +97,7 @@ "89"=> "Nombre de téléchargements / nombre autorisés. Cliquer pour remettre à zéro.", "90"=> "URL du lien", "91"=> "Tags (Entrez pour sauver)", -"92"=> "Nouveau lien", +"92"=> "Créer le lien", "93"=> "Liens existants", "94"=> "QRCode", "95"=> "QRcode", @@ -226,4 +226,5 @@ "212" => "accepté", "213" => "rejeté", "214" => "pas envoyé", + "215" => "Pour activer un lien public sur un fichier ou un répertoire, vous devez lui assigner un mot de passe.", ); \ No newline at end of file diff --git a/core/src/plugins/action.share/res/i18n/it.php b/core/src/plugins/action.share/res/i18n/it.php index 1ea2dcecd3..826bb16c46 100644 --- a/core/src/plugins/action.share/res/i18n/it.php +++ b/core/src/plugins/action.share/res/i18n/it.php @@ -225,4 +225,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); diff --git a/core/src/plugins/action.share/res/i18n/pt.php b/core/src/plugins/action.share/res/i18n/pt.php index e3af4b8360..4e0cf36612 100644 --- a/core/src/plugins/action.share/res/i18n/pt.php +++ b/core/src/plugins/action.share/res/i18n/pt.php @@ -226,4 +226,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); \ No newline at end of file diff --git a/core/src/plugins/action.share/res/i18n/ru.php b/core/src/plugins/action.share/res/i18n/ru.php index 7aedb1a94a..767a7a86cf 100644 --- a/core/src/plugins/action.share/res/i18n/ru.php +++ b/core/src/plugins/action.share/res/i18n/ru.php @@ -222,4 +222,5 @@ "212" => "accepted", "213" => "rejected", "214" => "not sent", + "215" => "To enable a public link on a file or a folder, you first need to set up a password.", ); diff --git a/core/src/plugins/action.share/res/react/ShareDialog.js b/core/src/plugins/action.share/res/react/ShareDialog.js index e863060184..f585d158de 100644 --- a/core/src/plugins/action.share/res/react/ShareDialog.js +++ b/core/src/plugins/action.share/res/react/ShareDialog.js @@ -723,14 +723,35 @@ showMailer:React.PropTypes.func }, - toggleLink: function(event){ - this.props.shareModel.togglePublicLink(); + toggleLink: function(){ + var publicLinks = this.props.shareModel.getPublicLinks(); + if(this.state.showTemporaryPassword){ + this.setState({showTemporaryPassword: false, temporaryPassword: null}); + }else if(!publicLinks.length && ReactModel.Share.getAuthorizations(this.props.pydio).password_mandatory){ + this.setState({showTemporaryPassword: true, temporaryPassword: ''}); + }else{ + this.props.shareModel.togglePublicLink(); + } + }, + + getInitialState: function(){ + return {showTemporaryPassword: false, temporaryPassword: null}; + }, + + updateTemporaryPassword: function(value, event){ + if(value == undefined) value = event.currentTarget.getValue(); + this.setState({temporaryPassword:value}); + }, + + enableLinkWithPassword:function(){ + this.props.shareModel.enablePublicLinkWithPassword(this.state.temporaryPassword); + this.setState({showTemporaryPassword:false, temporaryPassword:null}); }, render: function(){ var publicLinkPanes; - if(this.props.linkData){ + if(this.props.linkData) { publicLinkPanes = [ , + key="public-perm"/>, ]; + }else if(this.state.showTemporaryPassword){ + publicLinkPanes = [ +
+
{this.context.getMessage('215')}
+
+
+ +
+
+ +
+
+
+ ]; + }else{ publicLinkPanes = [
{this.context.getMessage('190')}
@@ -764,7 +805,7 @@ {publicLinkPanes} @@ -1048,6 +1089,14 @@ } }, + formatDate : function(dateObject){ + var dateFormatDay = this.context.getMessage('date_format', '').split(' ').shift(); + return dateFormatDay + .replace('Y', dateObject.getFullYear()) + .replace('m', dateObject.getMonth() + 1) + .replace('d', dateObject.getDate()); + }, + render: function(){ var linkId = this.props.linkData.hash; var passContainer = this.renderPasswordContainer(); @@ -1056,8 +1105,18 @@ var expirationDateValue = this.props.shareModel.getExpirationFor(linkId, 'days') === 0 ? "" : this.props.shareModel.getExpirationFor(linkId, 'days'); var calIcon = ; var expDate = null; + var maxDate = null, maxDownloads = null; + var auth = ReactModel.Share.getAuthorizations(this.props.pydio); + var today = new Date(); + if(parseInt(auth.max_expiration) > 0){ + maxDate = new Date(); + maxDate.setDate(today.getDate() + parseInt(auth.max_expiration)); + } + if(parseInt(auth.max_downloads) > 0){ + // todo: limit the field values by default? + maxDownloads = parseInt(auth.max_downloads); + } if(expirationDateValue){ - var today = new Date(); expDate = new Date(); expDate.setDate(today.getDate() + parseInt(expirationDateValue)); var clearValue = function(){ @@ -1096,15 +1155,18 @@ hintText={this.context.getMessage('21')} autoOk={true} minDate={new Date()} + maxDate={maxDate} defaultDate={expDate} showYearSelector={true} onShow={null} onDismiss={null} + formatDate={this.formatDate} />