Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix various usability issues around password-protected minisites.
  • Loading branch information
cdujeu committed Nov 13, 2014
1 parent ef9aeaa commit 5eed38a
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 15 deletions.
31 changes: 28 additions & 3 deletions core/src/plugins/action.share/class.ShareCenter.js
Expand Up @@ -124,6 +124,10 @@ Class.create("ShareCenter", {
var conn = new Connexion(publicUrl);
conn.setMethod("POST");
var params = modal.getForm().serialize(true);
var passwordField = modal.getForm().down('input[name="guest_user_pass"]');
if(passwordField.readAttribute('data-password-set') === 'true' && !passwordField.getValue()){
delete params['guest_user_pass'];
}
conn.setParameters(params);
if(this._currentRepositoryId){
conn.addParameter("repository_id", this._currentRepositoryId);
Expand Down Expand Up @@ -421,6 +425,19 @@ Class.create("ShareCenter", {
if(json['password']){
oForm.down('input[name="guest_user_pass"]').setValue(json['password']);
}
if(json['has_password']){
oForm.down('input[name="guest_user_pass"]').writeAttribute('placeholder', '***********');
oForm.down('input[name="guest_user_pass"]').writeAttribute('data-password-set', 'true');
oForm.down('#remove_user_pass').show();
oForm.down('#remove_user_pass').observeOnce('click', function(){
oForm.down('input[name="guest_user_pass"]').writeAttribute('data-password-set', 'false');
oForm.down('input[name="guest_user_pass"]').writeAttribute('placeholder', MessageHash['share_center.148']);
oForm.down('#remove_user_pass').hide();
});
}else{
oForm.down('input[name="guest_user_pass"]').writeAttribute('data-password-set', 'false');
oForm.down('#remove_user_pass').hide();
}
if(json['expire_time']){
oForm.down('input[name="expiration"]').setValue(json['expire_after']);
}
Expand Down Expand Up @@ -839,10 +856,13 @@ Class.create("ShareCenter", {
$A(jsonData.entries).each(function(entry){
entries.push(entry.LABEL + ' ('+ entry.RIGHT +')');
});

var pwdProtected = '';
if(jsonData['has_password']){
pwdProtected = ' ' + MessageHash['share_center.170'];
}
if(node.isLeaf()){
// LEAF SHARE
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.140"+(jsonData['is_expired']?'b':'')]+'</div>');
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.140"+(jsonData['is_expired']?'b':'')]+ pwdProtected + '</div>');
mainCont.insert('<div class="infoPanelRow">\
<div class="infoPanelLabel">'+MessageHash['share_center.121']+'</div>\
<div class="infoPanelValue"><input type="text" class="share_info_panel_link'+(jsonData['is_expired']?' share_info_panel_link_expired':'')+'" readonly="true" value="'+ jsonData.minisite.public_link +'"></div>\
Expand All @@ -851,7 +871,7 @@ Class.create("ShareCenter", {

}else if(jsonData.minisite){
// MINISITE FOLDER SHARE
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.138"+(jsonData['is_expired']?'b':'')]+'</div>');
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.138"+(jsonData['is_expired']?'b':'')]+ pwdProtected + '</div>');
// Links textearea
mainCont.insert('\
<div class="infoPanelRow">\
Expand Down Expand Up @@ -1185,6 +1205,11 @@ Class.create("ShareCenter", {

}

// PASSWORD BUTTON
if(jsonData['has_password']){
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({top:new Element('span', {className:'simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.85"]}).update('<span class="icon-key"></span> '+MessageHash["share_center.84"])});
}

// EXPIRATION TIME
if(jsonData && jsonData["expire_time"]){
if(jsonData['is_expired'] && jsonData['expire_after'] === 0 && (jsonData['download_limit'] && jsonData['download_limit'] != jsonData['download_counter'])){
Expand Down
12 changes: 10 additions & 2 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -1363,10 +1363,14 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
if(isSet($existingData["PRELOG_USER"])) $existingU = $existingData["PRELOG_USER"];
else if(isSet($existingData["PRESET_LOGIN"])) $existingU = $existingData["PRESET_LOGIN"];
$uniqueUser = $httpVars["guest_user_id"];
if(!empty($httpVars["guest_user_pass"]) && $uniqueUser == $existingU){
if(isset($httpVars["guest_user_pass"]) && strlen($httpVars["guest_user_pass"]) && $uniqueUser == $existingU){
//$userPass = $httpVars["guest_user_pass"];
// UPDATE GUEST USER PASS HERE
AuthService::updatePassword($uniqueUser, $httpVars["guest_user_pass"]);
}else if(isSet($httpVars["guest_user_pass"]) && $httpVars["guest_user_pass"] == ""){

}else if(isSet($existingData["PRESET_LOGIN"])){
$httpVars["KEEP_PRESET_LOGIN"] = true;
}

}else if (isSet($httpVars["create_guest_user"])) {
Expand Down Expand Up @@ -1439,7 +1443,7 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
if(isSet($data["PRESET_LOGIN"]))unset($data["PRESET_LOGIN"]);
if((isSet($httpVars["create_guest_user"]) && isSet($userId)) || (isSet($httpVars["guest_user_id"]))){
if(!isset($userId)) $userId = $httpVars["guest_user_id"];
if(empty($httpVars["guest_user_pass"])){
if(empty($httpVars["guest_user_pass"]) && !isSet($httpVars["KEEP_PRESET_LOGIN"])){
$data["PRELOG_USER"] = $userId;
}else{
$data["PRESET_LOGIN"] = $userId;
Expand Down Expand Up @@ -2244,6 +2248,7 @@ public function shareToJson($shareId, $shareData, $node = null){
$shareData["type"] = "repository";
}
$minisite = ($shareData["type"] == "minisite");
$minisiteIsPublic = false;
if ($minisite) {
$minisiteData = $this->getShareStore()->loadShare($shareId);
$repoId = $minisiteData["REPOSITORY"];
Expand Down Expand Up @@ -2316,6 +2321,9 @@ public function shareToJson($shareId, $shareData, $node = null){
if(isSet($minisiteData["AJXP_TEMPLATE_NAME"])){
$jsonData["minisite_layout"] = $minisiteData["AJXP_TEMPLATE_NAME"];
}
if(!$minisiteIsPublic){
$jsonData["has_password"] = true;
}
$jsonData["minisite"] = array(
"public" => $minisiteIsPublic?"true":"false",
"public_link" => $minisiteLink,
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/action.share/manifest.xml
Expand Up @@ -134,7 +134,7 @@
<div class="dialogContentMainTitle">AJXP_MESSAGE[share_center.147]</div>
<div class="SF_element">
<div class="SF_label" ajxp_message_id="share_center.23" style="width:130px;" title="AJXP_MESSAGE[share_center.23]">AJXP_MESSAGE[share_center.23]</div>
<input type="text" name="guest_user_pass" value="" placeholder="AJXP_MESSAGE[share_center.148]" autocomplete="off" class="SF_input" style="width:40% !important;">
<input type="text" name="guest_user_pass" value="" placeholder="AJXP_MESSAGE[share_center.148]" autocomplete="off" class="SF_input" style="width:40% !important;"> <span style="display:none;" id="remove_user_pass">Disable Password</span>
<div class="SF_horizontal_labelRow">
<div class="SF_label" ajxp_message_id="share_center.21" style="width:40% !important;" title="AJXP_MESSAGE[share_center.21]">AJXP_MESSAGE[share_center.21]</div>
<div class="SF_label" ajxp_message_id="share_center.22" style="width:40% !important;" title="AJXP_MESSAGE[share_center.22]">AJXP_MESSAGE[share_center.22]</div>
Expand Down Expand Up @@ -426,7 +426,7 @@
<clientCallback dialogOpenForm="share_current_url" dialogSkipButtons="true" prepareModal="true">
<dialogOnOpen><![CDATA[
modal.getForm().down("#crt-page-url").setValue(document.location.href);
if(!ajaxplorer.getContextHolder().isEmpty() && ajaxplorer.getActionBar().getActionByName("download")){
if(ajxpBootstrap.parameters.get('PRESET_LOGIN') === 'ajxp_preloged_user' && !ajaxplorer.getContextHolder().isEmpty() && ajaxplorer.getActionBar().getActionByName("download")){
var tpl = new Template('<div style="font-size: 16px; padding-top:15px; text-align:left;">#{title} <a href="#{link}" target="_blank" class="icon-link" style="font-size: 0.8em;"></a></div><input type="text" value="#{link}" style="width: 98%;">');
var node = ajaxplorer.getContextHolder().getUniqueNode();
var editors = ajaxplorer.findEditorsForMime(node.getAjxpMime(), true);
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/ca.php
Expand Up @@ -181,5 +181,6 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",
"170" => "This is link is secured with a password.",

);
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/de.php
Expand Up @@ -180,5 +180,6 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",
"170" => "This is link is secured with a password.",

);
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/en.php
Expand Up @@ -182,4 +182,5 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",
"170" => "This is link is secured with a password.",
);
2 changes: 1 addition & 1 deletion core/src/plugins/action.share/res/i18n/es.php
Expand Up @@ -181,6 +181,6 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",

"170" => "This is link is secured with a password.",

);
2 changes: 1 addition & 1 deletion core/src/plugins/action.share/res/i18n/fr.php
Expand Up @@ -181,5 +181,5 @@
"167" => "Le lien est expiré!",
"168" => "Le nombre de téléchargements autorisés a été atteint. Cliquer pour remettre à zéro et réactiver le lien.",
"169" => "La date d'expiration est passée. Changez les paramètres du lien pour le réactiver.",

"170" => "Ce lien est sécurisé par un mot de passe.",
);
2 changes: 1 addition & 1 deletion core/src/plugins/action.share/res/i18n/it.php
Expand Up @@ -178,6 +178,6 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",

"170" => "This is link is secured with a password.",

);
3 changes: 1 addition & 2 deletions core/src/plugins/action.share/res/i18n/pt.php
Expand Up @@ -181,6 +181,5 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",

// will be replaced by the filename to download
"170" => "This is link is secured with a password.",
);
1 change: 1 addition & 0 deletions core/src/plugins/action.share/res/i18n/ru.php
Expand Up @@ -177,4 +177,5 @@
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",
"170" => "This is link is secured with a password.",
);
18 changes: 16 additions & 2 deletions core/src/plugins/gui.ajax/res/themes/orbit/css/ajaxplorer.css
Expand Up @@ -4682,8 +4682,13 @@ div#target_repository_toggle{
display: block !important;
}

.share_edit div#target_repository_toggle span{
display: inline;
.share_edit div#target_repository_toggle span.simple_tooltip_observer{
display: inline-block;
padding: 2px 7px;
border: 1px solid;
color: #888;
border-radius: 8px;
margin: 2px;
}

.share_edit div#target_repository_toggle div.SF_horizontal_actions{
Expand Down Expand Up @@ -4810,6 +4815,15 @@ form.share_expired div#mailer_button{
div.user_entry span.cbContainer{

}

#target_repository span#remove_user_pass{
border-bottom: 1px solid;
font-size: 13px;
display: inline-block;
margin-left: 5px;
cursor: pointer;
}

/***********************/
/* EDITORS & DIAPORAMA */
/***********************/
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/themes/orbit/css/allz.css

Large diffs are not rendered by default.

0 comments on commit 5eed38a

Please sign in to comment.