Improves my previous commit by saving the mail during edition
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 20 Sep 2007 12:06:56 +0000 (14:06 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 20 Sep 2007 12:06:56 +0000 (14:06 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
ChangeLog
templates/emails/send.tpl

index a540d5b..d41f469 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,7 +38,7 @@ Bug/Wish:
         - #687: Don't lose authentication when editing a long mail         -FRU
         - #688: From name in the sending form                              -FRU
         - #703: Fix management of mail adresses containing '+'             -ALK
-        - #720: Save not sent mail at exit                                 -FRU
+        - #720: Save not sent mail                                         -FRU
 
     * Lists:
         - #700: Fix several encoding issues                                -FRU
index cca3488..1e81a6b 100644 (file)
     return true;
   }
 
+  function saveMessage() {
+    var form = document.forms.form_mail;
+    var toc = "";
+    var ccc = "";
+    for (var i = 0 ; i < form['to_contacts[]'].length ; ++i) {
+      toc += form['to_contacts[]'].options[i].value + ";";
+    }
+    for (var i = 0 ; i < form['cc_contacts[]'].length ; ++i) {
+      ccc += form['cc_contacts[]'].options[i].value + ";";
+    }
+    $.post(platal_baseurl + "emails/send",
+           { save: true,
+             from: form.from.value,
+             to_contacts: toc,
+             cc_contacts: ccc,
+             contenu: form.contenu.value,
+             to: form.to.value,
+             sujet: form.sujet.value,
+             cc: form.cc.value,
+             bcc: form.bcc.value });
+  }
+
   var doAuth = true;
   function _keepAuth() {
     doAuth = true;
@@ -63,7 +85,7 @@
 
   function keepAuth() {
     if (doAuth) {
-      Ajax.update_html(null, "login", null);
+      saveMessage();
       doAuth = false;
       setTimeout("_keepAuth()", 10000);
     }
       if (sent) {
         return true;
       }
-      var form = document.forms.form_mail;
-      var toc = "";
-      var ccc = "";
-      for (var i = 0 ; i < form['to_contacts[]'].length ; ++i) {
-        toc += form['to_contacts[]'].options[i].value + ";";
-      }
-      for (var i = 0 ; i < form['cc_contacts[]'].length ; ++i) {
-        ccc += form['cc_contacts[]'].options[i].value + ";";
-      }
-      $.post(platal_baseurl + "emails/send",
-             { save: true,
-               from: form.from.value,
-               to_contacts: toc,
-               cc_contacts: ccc,
-               contenu: form.contenu.value,
-               to: form.to.value,
-               sujet: form.sujet.value,
-               cc: form.cc.value,
-               bcc: form.bcc.value });
+      saveMessage();
       return true;
     });
   {/literal}