mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-05 12:34:08 +01:00
@@ -82,14 +82,17 @@ function compose_loader(event) {
|
|||||||
current_anchor.baseurl("compose").update();
|
current_anchor.baseurl("compose").update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resize_window_callback(event) {
|
||||||
|
setDivHeight("id_body", $("mailheader").getSize().y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callback of the 'compose' action
|
* Callback of the 'compose' action
|
||||||
*/
|
*/
|
||||||
function compose_callback(resp) {
|
function compose_callback(resp) {
|
||||||
wm_updatelisting(resp);
|
wm_updatelisting(resp);
|
||||||
window.addEvent("resize", function(evt) {
|
|
||||||
setDivHeight("id_body", $("mailheader").getSize().y, 0);
|
window.addEvent("resize", resize_window_callback);
|
||||||
});
|
|
||||||
window.fireEvent("resize");
|
window.fireEvent("resize");
|
||||||
|
|
||||||
var editormode = resp.editor;
|
var editormode = resp.editor;
|
||||||
@@ -105,15 +108,19 @@ function compose_callback(resp) {
|
|||||||
height: $(editorid).getSize().y
|
height: $(editorid).getSize().y
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$$("a[name=back]").addEvent("click", loadFolder);
|
$$("a[name=back]")
|
||||||
$$("a[name=sendmail]").addEvent("click", function(evt) {
|
.removeEvents("click")
|
||||||
|
.addEvent("click", loadFolder);
|
||||||
|
$$("a[name=sendmail]")
|
||||||
|
.removeEvents("click")
|
||||||
|
.addEvent("click", function(evt) {
|
||||||
evt.stop();
|
evt.stop();
|
||||||
$("composemail").set("send", {
|
$("composemail").set("send", {
|
||||||
onSuccess: function(resp) {
|
onSuccess: function(resp) {
|
||||||
resp = JSON.decode(resp);
|
resp = JSON.decode(resp);
|
||||||
if (resp.status == "ko") {
|
if (resp.status == "ko") {
|
||||||
wm_updatelisting(resp);
|
get_callback("compose")(resp);
|
||||||
window.fireEvent("resize");
|
|
||||||
if ($defined(resp.error)) {
|
if ($defined(resp.error)) {
|
||||||
infobox.error(resp.error);
|
infobox.error(resp.error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,30 +308,30 @@ def send_mail(request, withctx=False, origmsg=None, posturl=None):
|
|||||||
form = ComposeMailForm(request.POST)
|
form = ComposeMailForm(request.POST)
|
||||||
error = None
|
error = None
|
||||||
ctx = None
|
ctx = None
|
||||||
|
editormode = parameters.get_user(request.user, "EDITOR")
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import make_msgid, formatdate
|
from email.utils import make_msgid, formatdate
|
||||||
import smtplib
|
import smtplib
|
||||||
|
|
||||||
subtype = parameters.get_user(request.user, "EDITOR")
|
|
||||||
body = request.POST["id_body"]
|
body = request.POST["id_body"]
|
||||||
charset = "utf-8"
|
charset = "utf-8"
|
||||||
if subtype == "html":
|
if editormode == "html":
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
|
|
||||||
msg = MIMEMultipart(_subtype="related")
|
msg = MIMEMultipart(_subtype="related")
|
||||||
submsg = MIMEMultipart(_subtype="alternative")
|
submsg = MIMEMultipart(_subtype="alternative")
|
||||||
textbody = __html2plaintext(body)
|
textbody = __html2plaintext(body)
|
||||||
submsg.attach(MIMEText(textbody.encode(charset),
|
submsg.attach(MIMEText(textbody.encode(charset),
|
||||||
_subtype="plain", _charset=charset))
|
_subtype="plain", _charset=charset))
|
||||||
body, images = find_images_in_body(body)
|
body, images = find_images_in_body(body)
|
||||||
submsg.attach(MIMEText(body.encode(charset), _subtype=subtype,
|
submsg.attach(MIMEText(body.encode(charset), _subtype=editormode,
|
||||||
_charset=charset))
|
_charset=charset))
|
||||||
msg.attach(submsg)
|
msg.attach(submsg)
|
||||||
for img in images:
|
for img in images:
|
||||||
msg.attach(img)
|
msg.attach(img)
|
||||||
else:
|
else:
|
||||||
msg = MIMEText(body.encode(charset), _subtype=subtype)
|
msg = MIMEText(body.encode(charset), _subtype=editormode)
|
||||||
|
|
||||||
msg["Subject"] = request.POST["subject"]
|
msg["Subject"] = request.POST["subject"]
|
||||||
address, domain = split_mailbox(request.POST["from_"])
|
address, domain = split_mailbox(request.POST["from_"])
|
||||||
@@ -378,7 +378,7 @@ def send_mail(request, withctx=False, origmsg=None, posturl=None):
|
|||||||
{"form" : form,
|
{"form" : form,
|
||||||
"body" : request.POST["id_body"].strip(),
|
"body" : request.POST["id_body"].strip(),
|
||||||
"posturl" : posturl})
|
"posturl" : posturl})
|
||||||
ctx = getctx("ko", level=2, error=error, listing=listing)
|
ctx = getctx("ko", level=2, error=error, listing=listing, editor=editormode)
|
||||||
if not withctx:
|
if not withctx:
|
||||||
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
||||||
return ctx, HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
return ctx, HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
||||||
|
|||||||
Reference in New Issue
Block a user