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

Commit 0a85ae8

Browse files
committed
Fix sharing / Mailer / autocomplete
1 parent f8b01ac commit 0a85ae8

File tree

7 files changed

+103
-34
lines changed

7 files changed

+103
-34
lines changed

core/src/plugins/action.share/class.ShareCenter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,10 +1096,12 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
10961096
return 102;
10971097
}
10981098
} else {
1099-
if ( !ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf") || AuthService::isReservedUserId($userName)) {
1099+
if ( ($httpVars["create_guest_user"] != "true" && !ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf")) || AuthService::isReservedUserId($userName)) {
11001100
return 102;
11011101
}
1102-
if(!isSet($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") return 100;
1102+
if (!isSet($httpVars["shared_pass"]) || $httpVars["shared_pass"] == "") {
1103+
return 100;
1104+
}
11031105
}
11041106
}
11051107

core/src/plugins/action.share/manifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@
325325
<div class="dialogLegend" style="margin:0 5px;" ajxp_message_id="share_center.26">AJXP_MESSAGE[share_center.26]</div>
326326
</div>
327327
<div id="target_user" style="margin:0 5px;position:relative;display:none;" class="mode-ws mode-minipriv">
328+
<div style="clear: both; margin-top:20px;" class="mode-minipriv">&nbsp;</div>
328329
<div class="editable_users_header">
329330
<span id="header_read" ajxp_message_id="share_center.31">AJXP_MESSAGE[share_center.31]</span>
330331
<span id="header_write" ajxp_message_id="share_center.32">AJXP_MESSAGE[share_center.32]</span>

core/src/plugins/core.conf/class.AbstractConfDriver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ public function switchAction($action, $httpVars, $fileVars)
814814
$loggedUser = AuthService::getLoggedUser();
815815
$crtValue = $httpVars["value"];
816816
$usersOnly = isSet($httpVars["users_only"]) && $httpVars["users_only"] == "true";
817+
$existingOnly = isSet($httpVars["existing_only"]) && $httpVars["existing_only"] == "true";
817818
if(!empty($crtValue)) $regexp = '^'.preg_quote($crtValue);
818819
else $regexp = null;
819820
$limit = min(ConfService::getCoreConf("USERS_LIST_COMPLETE_LIMIT", "conf"), 20);
@@ -823,11 +824,15 @@ public function switchAction($action, $httpVars, $fileVars)
823824
}
824825
$users = "";
825826
$index = 0;
826-
if ($regexp != null && !count($allUsers) && ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf")) {
827+
if ($regexp != null && !count($allUsers) && ConfService::getCoreConf("ALLOW_NEWUSERS_SHARING", "conf") && !$existingOnly) {
827828
$users .= "<li class='complete_user_entry_temp' data-temporary='true' data-label='$crtValue'><span class='user_entry_label'>$crtValue (".$mess["448"].")</span></li>";
829+
} else if ($existingOnly && !empty($crtValue)) {
830+
$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>";
828831
}
829832
$mess = ConfService::getMessages();
830-
if($regexp == null) $users .= "<li class='complete_group_entry' data-group='/' data-label='".$mess["447"]."'><span class='user_entry_label'>".$mess["447"]."</span></li>";
833+
if ($regexp == null && !$usersOnly) {
834+
$users .= "<li class='complete_group_entry' data-group='/' data-label='".$mess["447"]."'><span class='user_entry_label'>".$mess["447"]."</span></li>";
835+
}
831836
if (!$usersOnly && count($allGroups)) {
832837
foreach ($allGroups as $groupId => $groupLabel) {
833838
if ($regexp == null || preg_match("/$regexp/i", $groupLabel)) {

core/src/plugins/core.mailer/AjxpMailer.css

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#mailer_message{
2-
2+
border: 0 !important;
3+
width: 380px;
34
}
45

56
#mailer_message div.message_body input{
@@ -8,8 +9,8 @@
89
}
910

1011
#mailer_message div.message_body textarea{
11-
width: 250px;
12-
height: 150px;
12+
width: 374px;
13+
height: 120px;
1314
padding: 2px;
1415
}
1516

@@ -22,7 +23,7 @@
2223
.mailer_input_label{
2324
display: inline-block;
2425
width: 17%;
25-
padding: 7px 4px;
26+
padding: 7px 3px;
2627
background-color: #E2E2E2;
2728
text-align: right;
2829
font-weight: bold;
@@ -50,6 +51,37 @@
5051
margin: 0;
5152
}
5253

53-
#emails_autocomplete li.complete_user_entry.selected {
54-
color: black;
54+
#emails_autocomplete li.selected {
55+
color: black ;
56+
}
57+
58+
.mailer_input_line span.user{
59+
display: inline-block;
60+
padding: 4px;
61+
background-color: #aaa;
62+
border-radius: 4px;
63+
color: white;
64+
margin: 1px 3px;
65+
}
66+
67+
.mailer_input_line span.user span.icon-remove{
68+
display: inline-block;
69+
margin-left: 3px;
70+
cursor: pointer;
71+
}
72+
73+
.mailer_tofield_line{
74+
overflow-y: auto;
75+
position: relative;
76+
height: 25px;
77+
}
78+
79+
.mailer_tofield_line span.mailer_input_label{
80+
height: 90px;
81+
}
82+
83+
.mailer_input_line.mailer_tofield_line input#tofield{
84+
85+
width: 120px !important;
86+
5587
}

core/src/plugins/core.mailer/class.AjxpMailer.js

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,71 @@ Class.create("AjxpMailer", {
2727
res.loadCSSResource("plugins/core.mailer/AjxpMailer.css");
2828
},
2929

30+
selectedLoginToSpan: function(loginLabel, entryId, isGroup){
31+
var field = this._mailerPane.down('#tofield');
32+
var fieldParent = this._mailerPane.down('.mailer_tofield_line');
33+
var el = new Element('span', {
34+
className:'user',
35+
'data-entry_id':entryId,
36+
'data-is_group':isGroup
37+
}).update(loginLabel+'<span class="icon-remove"></span>');
38+
39+
field.insert({before: el});
40+
el.down('.icon-remove').observe('click', el.remove.bind(el));
41+
field.setValue('');
42+
var offset = Element.positionedOffset(field);
43+
var height = fieldParent.getHeight() - parseInt(fieldParent.getStyle('marginBottom')) - parseInt(fieldParent.getStyle('marginTop')) - 5;
44+
if(!fieldParent.ORIGINAL_HEIGHT) fieldParent.ORIGINAL_HEIGHT = fieldParent.getHeight();
45+
if(offset.top >= height ){
46+
fieldParent.setStyle({height: (parseInt(fieldParent.getHeight()) + fieldParent.ORIGINAL_HEIGHT ) + 'px'});
47+
}else if(offset.top < (height - fieldParent.ORIGINAL_HEIGHT) ){
48+
fieldParent.setStyle({height: (parseInt(fieldParent.getHeight()) - fieldParent.ORIGINAL_HEIGHT ) + 'px'});
49+
}
50+
field.focus();
51+
},
52+
3053
buildMailPane:function(subject, body, recipientsList, paneTitle){
3154
if(!$("mailer_message")){
3255
$(document.body).insert("<div id='mailer_message'></div>");
3356
}
34-
var recipientString = '';
35-
var hiddenRecipientString = [];
36-
var hiddenGroupsString = [];
37-
if(recipientsList){
38-
recipientsList.select("div.user_entry").each(function(el){
39-
recipientString += el.down("span.user_entry_label").innerHTML + ", ";
40-
if(el.hasClassName("group_entry")){
41-
hiddenGroupsString.push(el.getAttribute("data-entry_id"));
42-
}else{
43-
hiddenRecipientString.push(el.getAttribute("data-entry_id"));
44-
}
45-
});
46-
recipientString = recipientString.substring(0, recipientString.length-2);
47-
hiddenGroupsString = hiddenGroupsString.join(",");
48-
hiddenRecipientString = hiddenRecipientString.join(",");
49-
}
5057
var fromString = ajaxplorer.user.id;
51-
$("mailer_message").update("<div id='mailer_message' style='position: relative;'><div id='emails_autocomplete' style='position:absolute'></div><div class='message_body'><form>" +
58+
$("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>" +
5259
"<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>" +
53-
"<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>" +
60+
"<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>" +
5461
"<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>" +
5562
"<textarea name='message' class='grey_gradient_light_inputs'>"+body+"</textarea>" +
56-
"<input type='hidden' name='users_ids' value='"+ hiddenRecipientString +"'/> " +
57-
"<input type='hidden' name='groups_ids' value='"+ hiddenGroupsString +"'/> " +
5863
"</form></div></div>");
5964
if(paneTitle){
6065
$("mailer_message").insert({top:new Element("div", {className:"dialogContentMainTitle"}).update(paneTitle)});
6166
}
6267

6368
this._mailerPane = $("mailer_message");
6469

70+
if(recipientsList){
71+
recipientsList.select("div.user_entry").each(function(el){
72+
var loginLabel = el.down("span.user_entry_label").innerHTML;
73+
this.selectedLoginToSpan(loginLabel, el.getAttribute("data-entry_id"), el.hasClassName("group_entry"));
74+
}.bind(this));
75+
}
76+
6577
this._autocompleter = new AjxpUsersCompleter(
6678
this._mailerPane.down('#tofield'),
6779
null,
6880
this._mailerPane.down('#emails_autocomplete'),
6981
{
7082
tmpUsersPrefix:'',
7183
usersOnly: true,
84+
existingOnly: true,
7285
updateUserEntryAfterCreate:null,
7386
createUserPanel:null,
7487
indicator: null,
75-
minChars:parseInt(ajaxplorer.getPluginConfigs("conf").get("USERS_LIST_COMPLETE_MIN_CHARS"))
88+
minChars:parseInt(ajaxplorer.getPluginConfigs("conf").get("USERS_LIST_COMPLETE_MIN_CHARS")),
89+
afterUpdateElement: function(elem, selectedLi){
90+
this.selectedLoginToSpan(
91+
selectedLi.readAttribute('data-label'),
92+
selectedLi.readAttribute('data-entry_id'),
93+
selectedLi.hasClassName('group_entry'));
94+
}.bind(this)
7695
}
7796
);
7897

@@ -85,6 +104,11 @@ Class.create("AjxpMailer", {
85104
this._mailerPane.down("form").getElements().each(function(el){
86105
params.set(el.name, el.getValue());
87106
});
107+
var aa = [];
108+
this._mailerPane.down(".mailer_tofield_line").select('span.user').each(function(el){
109+
aa.push(el.readAttribute('data-entry_id'));
110+
});
111+
params.set('emails[]', aa);
88112
var connexion = new Connexion();
89113
connexion.setMethod("post");
90114
connexion.setParameters(params);

core/src/plugins/core.mailer/class.AjxpMailer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ public function sendMailAction($actionName, $httpVars, $fileVars)
9292

9393
$mailer = array_pop($mailers);
9494

95-
$toUsers = array_merge(explode(",", $httpVars["users_ids"]), explode(",", $httpVars["to"]));
96-
$toGroups = explode(",", $httpVars["groups_ids"]);
95+
//$toUsers = array_merge(explode(",", $httpVars["users_ids"]), explode(",", $httpVars["to"]));
96+
//$toGroups = explode(",", $httpVars["groups_ids"]);
97+
$toUsers = $httpVars["emails"];
9798

9899
$emails = $this->resolveAdresses($toUsers);
99100
$from = $this->resolveFrom($httpVars["from"]);

core/src/plugins/gui.ajax/res/js/ajaxplorer/class.AjxpUsersCompleter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ Class.create("AjxpUsersCompleter", Ajax.Autocompleter, {
7474
{
7575
paramName:'value',
7676
tokens:[',', '\n'],
77-
frequency:0.1,
77+
frequency:0.25,
7878
tmpUsersPrefix:'',
7979
updateUserEntryAfterCreate:null,
8080
createUserPanel:null,
8181
usersOnly: false,
82+
existingOnly: false,
8283
afterUpdateElement: function(element, selectedLi){
8384
if(listElement){
8485

@@ -143,6 +144,9 @@ Class.create("AjxpUsersCompleter", Ajax.Autocompleter, {
143144
if(this.options.usersOnly){
144145
this.url += '&users_only=true';
145146
}
147+
if(this.options.existingOnly){
148+
this.url += '&existing_only=true';
149+
}
146150

147151
if(listElement){
148152
this.options.onComplete = function(transport){

0 commit comments

Comments
 (0)