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 sharing / Mailer / autocomplete
  • Loading branch information
cdujeu committed Oct 18, 2013
1 parent f8b01ac commit 0a85ae8
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 34 deletions.
6 changes: 4 additions & 2 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -1096,10 +1096,12 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
return 102;
}
} else {
if ( !ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf") || AuthService::isReservedUserId($userName)) {
if ( ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf")) || AuthService::isReservedUserId($userName)) {
return 102;
}
if(!isSet($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") return 100;
if (!isSet($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
return 100;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/manifest.xml
Expand Up @@ -325,6 +325,7 @@
<div class="dialogLegend" style="margin:0 5px;" ajxp_message_id="share_center.26">AJXP_MESSAGE[share_center.26]</div>
</div>
<div id="target_user" style="margin:0 5px;position:relative;display:none;" class="mode-ws mode-minipriv">
<div style="clear: both; margin-top:20px;" class="mode-minipriv">&nbsp;</div>
<div class="editable_users_header">
<span id="header_read" ajxp_message_id="share_center.31">AJXP_MESSAGE[share_center.31]</span>
<span id="header_write" ajxp_message_id="share_center.32">AJXP_MESSAGE[share_center.32]</span>
Expand Down
9 changes: 7 additions & 2 deletions core/src/plugins/core.conf/class.AbstractConfDriver.php
Expand Up @@ -814,6 +814,7 @@ public function switchAction($action, $httpVars, $fileVars)
$loggedUser = AuthService::getLoggedUser();
$crtValue = $httpVars["value"];
$usersOnly = isSet($httpVars["users_only"]) && $httpVars["users_only"] == "true";
$existingOnly = isSet($httpVars["existing_only"]) && $httpVars["existing_only"] == "true";
if(!empty($crtValue)) $regexp = '^'.preg_quote($crtValue);
else $regexp = null;
$limit = min(ConfService::getCoreConf("USERS_LIST_COMPLETE_LIMIT", "conf"), 20);
Expand All @@ -823,11 +824,15 @@ public function switchAction($action, $httpVars, $fileVars)
}
$users = "";
$index = 0;
if ($regexp != null && !count($allUsers) && ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf")) {
if ($regexp != null && !count($allUsers) && ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf") && !$existingOnly) {
$users .= "<li class='complete_user_entry_temp' data-temporary='true' data-label='$crtValue'><span class='user_entry_label'>$crtValue (".$mess["448"].")</span></li>";
} else if ($existingOnly && !empty($crtValue)) {
$users .= "<li class='complete_user_entry_temp' data-temporary='true' data-label='$crtValue' data-entry_id='$crtValue'><span class='user_entry_label'>$crtValue</span></li>";
}
$mess = ConfService::getMessages();
if($regexp == null) $users .= "<li class='complete_group_entry' data-group='/' data-label='".$mess["447"]."'><span class='user_entry_label'>".$mess["447"]."</span></li>";
if ($regexp == null && !$usersOnly) {
$users .= "<li class='complete_group_entry' data-group='/' data-label='".$mess["447"]."'><span class='user_entry_label'>".$mess["447"]."</span></li>";
}
if (!$usersOnly && count($allGroups)) {
foreach ($allGroups as $groupId => $groupLabel) {
if ($regexp == null || preg_match("/$regexp/i", $groupLabel)) {
Expand Down
44 changes: 38 additions & 6 deletions core/src/plugins/core.mailer/AjxpMailer.css
@@ -1,5 +1,6 @@
#mailer_message{

border: 0 !important;
width: 380px;
}

#mailer_message div.message_body input{
Expand All @@ -8,8 +9,8 @@
}

#mailer_message div.message_body textarea{
width: 250px;
height: 150px;
width: 374px;
height: 120px;
padding: 2px;
}

Expand All @@ -22,7 +23,7 @@
.mailer_input_label{
display: inline-block;
width: 17%;
padding: 7px 4px;
padding: 7px 3px;
background-color: #E2E2E2;
text-align: right;
font-weight: bold;
Expand Down Expand Up @@ -50,6 +51,37 @@
margin: 0;
}

#emails_autocomplete li.complete_user_entry.selected {
color: black;
#emails_autocomplete li.selected {
color: black ;
}

.mailer_input_line span.user{
display: inline-block;
padding: 4px;
background-color: #aaa;
border-radius: 4px;
color: white;
margin: 1px 3px;
}

.mailer_input_line span.user span.icon-remove{
display: inline-block;
margin-left: 3px;
cursor: pointer;
}

.mailer_tofield_line{
overflow-y: auto;
position: relative;
height: 25px;
}

.mailer_tofield_line span.mailer_input_label{
height: 90px;
}

.mailer_input_line.mailer_tofield_line input#tofield{

width: 120px !important;

}
66 changes: 45 additions & 21 deletions core/src/plugins/core.mailer/class.AjxpMailer.js
Expand Up @@ -27,52 +27,71 @@ Class.create("AjxpMailer", {
res.loadCSSResource("plugins/core.mailer/AjxpMailer.css");
},

selectedLoginToSpan: function(loginLabel, entryId, isGroup){
var field = this._mailerPane.down('#tofield');
var fieldParent = this._mailerPane.down('.mailer_tofield_line');
var el = new Element('span', {
className:'user',
'data-entry_id':entryId,
'data-is_group':isGroup
}).update(loginLabel+'<span class="icon-remove"></span>');

field.insert({before: el});
el.down('.icon-remove').observe('click', el.remove.bind(el));
field.setValue('');
var offset = Element.positionedOffset(field);
var height = fieldParent.getHeight() - parseInt(fieldParent.getStyle('marginBottom')) - parseInt(fieldParent.getStyle('marginTop')) - 5;
if(!fieldParent.ORIGINAL_HEIGHT) fieldParent.ORIGINAL_HEIGHT = fieldParent.getHeight();
if(offset.top >= height ){
fieldParent.setStyle({height: (parseInt(fieldParent.getHeight()) + fieldParent.ORIGINAL_HEIGHT ) + 'px'});
}else if(offset.top < (height - fieldParent.ORIGINAL_HEIGHT) ){
fieldParent.setStyle({height: (parseInt(fieldParent.getHeight()) - fieldParent.ORIGINAL_HEIGHT ) + 'px'});
}
field.focus();
},

buildMailPane:function(subject, body, recipientsList, paneTitle){
if(!$("mailer_message")){
$(document.body).insert("<div id='mailer_message'></div>");
}
var recipientString = '';
var hiddenRecipientString = [];
var hiddenGroupsString = [];
if(recipientsList){
recipientsList.select("div.user_entry").each(function(el){
recipientString += el.down("span.user_entry_label").innerHTML + ", ";
if(el.hasClassName("group_entry")){
hiddenGroupsString.push(el.getAttribute("data-entry_id"));
}else{
hiddenRecipientString.push(el.getAttribute("data-entry_id"));
}
});
recipientString = recipientString.substring(0, recipientString.length-2);
hiddenGroupsString = hiddenGroupsString.join(",");
hiddenRecipientString = hiddenRecipientString.join(",");
}
var fromString = ajaxplorer.user.id;
$("mailer_message").update("<div id='mailer_message' style='position: relative;'><div id='emails_autocomplete' style='position:absolute'></div><div class='message_body'><form>" +
$("mailer_message").update("<div id='mailer_message' style='position: relative;'><div id='emails_autocomplete' style='position:absolute;z-index:1200;'></div><div class='message_body'><form>" +
"<div class='grey_gradient_light_inputs mailer_input_line'><span class='mailer_input_label'>From:</span><input class='mailer_input_field' type='text' name='from' value='"+fromString+"'/></div>" +
"<div class='grey_gradient_light_inputs mailer_input_line'><span class='mailer_input_label'>To:</span><input class='mailer_input_field' type='text' name='to' id='tofield' value='"+recipientString+"'/></div>" +
"<div class='grey_gradient_light_inputs mailer_input_line mailer_tofield_line'><span class='mailer_input_label' style='float: left;'>To:</span><input class='mailer_input_field' type='text' name='to' id='tofield' value=''/></div>" +
"<div class='grey_gradient_light_inputs mailer_input_line'><span class='mailer_input_label'>Subject:</span><input class='mailer_input_field' type='text' name='subject' value='"+subject+"'/></div>" +
"<textarea name='message' class='grey_gradient_light_inputs'>"+body+"</textarea>" +
"<input type='hidden' name='users_ids' value='"+ hiddenRecipientString +"'/> " +
"<input type='hidden' name='groups_ids' value='"+ hiddenGroupsString +"'/> " +
"</form></div></div>");
if(paneTitle){
$("mailer_message").insert({top:new Element("div", {className:"dialogContentMainTitle"}).update(paneTitle)});
}

this._mailerPane = $("mailer_message");

if(recipientsList){
recipientsList.select("div.user_entry").each(function(el){
var loginLabel = el.down("span.user_entry_label").innerHTML;
this.selectedLoginToSpan(loginLabel, el.getAttribute("data-entry_id"), el.hasClassName("group_entry"));
}.bind(this));
}

this._autocompleter = new AjxpUsersCompleter(
this._mailerPane.down('#tofield'),
null,
this._mailerPane.down('#emails_autocomplete'),
{
tmpUsersPrefix:'',
usersOnly: true,
existingOnly: true,
updateUserEntryAfterCreate:null,
createUserPanel:null,
indicator: null,
minChars:parseInt(ajaxplorer.getPluginConfigs("conf").get("USERS_LIST_COMPLETE_MIN_CHARS"))
minChars:parseInt(ajaxplorer.getPluginConfigs("conf").get("USERS_LIST_COMPLETE_MIN_CHARS")),
afterUpdateElement: function(elem, selectedLi){
this.selectedLoginToSpan(
selectedLi.readAttribute('data-label'),
selectedLi.readAttribute('data-entry_id'),
selectedLi.hasClassName('group_entry'));
}.bind(this)
}
);

Expand All @@ -85,6 +104,11 @@ Class.create("AjxpMailer", {
this._mailerPane.down("form").getElements().each(function(el){
params.set(el.name, el.getValue());
});
var aa = [];
this._mailerPane.down(".mailer_tofield_line").select('span.user').each(function(el){
aa.push(el.readAttribute('data-entry_id'));
});
params.set('emails[]', aa);
var connexion = new Connexion();
connexion.setMethod("post");
connexion.setParameters(params);
Expand Down
5 changes: 3 additions & 2 deletions core/src/plugins/core.mailer/class.AjxpMailer.php
Expand Up @@ -92,8 +92,9 @@ public function sendMailAction($actionName, $httpVars, $fileVars)

$mailer = array_pop($mailers);

$toUsers = array_merge(explode(",", $httpVars["users_ids"]), explode(",", $httpVars["to"]));
$toGroups = explode(",", $httpVars["groups_ids"]);
//$toUsers = array_merge(explode(",", $httpVars["users_ids"]), explode(",", $httpVars["to"]));
//$toGroups = explode(",", $httpVars["groups_ids"]);
$toUsers = $httpVars["emails"];

$emails = $this->resolveAdresses($toUsers);
$from = $this->resolveFrom($httpVars["from"]);
Expand Down
Expand Up @@ -74,11 +74,12 @@ Class.create("AjxpUsersCompleter", Ajax.Autocompleter, {
{
paramName:'value',
tokens:[',', '\n'],
frequency:0.1,
frequency:0.25,
tmpUsersPrefix:'',
updateUserEntryAfterCreate:null,
createUserPanel:null,
usersOnly: false,
existingOnly: false,
afterUpdateElement: function(element, selectedLi){
if(listElement){

Expand Down Expand Up @@ -143,6 +144,9 @@ Class.create("AjxpUsersCompleter", Ajax.Autocompleter, {
if(this.options.usersOnly){
this.url += '&users_only=true';
}
if(this.options.existingOnly){
this.url += '&existing_only=true';
}

if(listElement){
this.options.onComplete = function(transport){
Expand Down

0 comments on commit 0a85ae8

Please sign in to comment.