$page->assign('xorg_title','Polytechnique.org - Envoyer un email');
// action si on recoit un formulaire
- if (Env::v('submit') == 'Envoyer')
- {
+ if (Post::has('save')) {
+ unset($_POST['save']);
+ if (trim(preg_replace('/-- .*/', '', Post::v('contenu'))) != "") {
+ $_POST['to_contacts'] = explode(';', @$_POST['to_contacts']);
+ $_POST['cc_contacts'] = explode(';', @$_POST['cc_contacts']);
+ $data = serialize($_POST);
+ XDB::execute("REPLACE INTO email_send_save
+ VALUES ({?}, {?})", S::i('uid'), $data);
+ }
+ exit;
+ } else if (Env::v('submit') == 'Envoyer') {
function getEmails($aliases)
{
if (!is_array($aliases)) {
}
}
+ XDB::execute("DELETE FROM email_send_save
+ WHERE uid = {?}", S::i('uid'));
+
$to2 = getEmails(Env::v('to_contacts'));
$cc2 = getEmails(Env::v('cc_contacts'));
$txt = str_replace('^M', '', Env::v('contenu'));
}
}
} else {
- PlUpload::clear(S::v('forlife'), 'emails.send');
- $_REQUEST['bcc'] = S::v('bestalias').'@'.$globals->mail->domain;
+ $res = XDB::query("SELECT data
+ FROM email_send_save
+ WHERE uid = {?}", S::i('uid'));
+ if ($res->numRows() == 0) {
+ PlUpload::clear(S::v('forlife'), 'emails.send');
+ $_REQUEST['bcc'] = S::v('bestalias').'@'.$globals->mail->domain;
+ } else {
+ $data = unserialize($res->fetchOneCell());
+ $_REQUEST = array_merge($_REQUEST, $data);
+ }
}
$res = XDB::query(
<h1>Envoyer un mail</h1>
+{javascript name="jquery"}
<script type="text/javascript">//<![CDATA[
{literal}
function _selectAll(id) {
}
}
+ var sent = false;
function check(form)
{
- var send = true;
_selectAll('to_contacts');
_selectAll('cc_contacts');
if(form.sujet.value == "" && !confirm("Le sujet du mail est vide, veux-tu continuer ?")) {
return false;
}
}
+ sent = true;
return true;
}
if (box.checked) {
document.getElementById("preview_bt").style.display = "none";
document.getElementById("preview").style.display = "none";
+ document.getElementById("preview_pv").style.display = "none";
} else {
document.getElementById("preview_bt").style.display = "";
+ document.getElementById("preview").style.display = "";
}
}
+
+ $(window).unload(
+ function() {
+ 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 });
+ return true;
+ });
{/literal}
//]]>
</script>
-<form action="emails/send" method="post" enctype="multipart/form-data" onsubmit="return check(this);">
+<form action="emails/send" method="post" enctype="multipart/form-data" id="form_mail" onsubmit="return check(this);">
<table class="bicol" cellpadding="2" cellspacing="0">
<tr>
<th colspan="2">Destinataires</th>
<small><input type="checkbox" name="nowiki" value="1" {if $smarty.request.nowiki}checked="checked"{/if} onchange="updateWikiView(this);" />
coche cette case pour envoyer le mail en texte brut, sans formattage</small>
</div>
- <div id="preview" style="display: none">
- <strong>Aperçu du mail :</strong>
- <div id="mail_preview">
+ <div id="preview">
+ <div id="preview_pv" style="display: none">
+ <strong>Aperçu du mail :</strong>
+ <div id="mail_preview">
+ </div>
+ <div class="center">
+ <input type="submit" name="submit" value="Envoyer" />
+ </div>
</div>
<div class="center">
- <input type="submit" name="submit" value="Envoyer" />
+ <input type="submit" name="preview" id="preview_bt_top" value="Aperçu"
+ onclick="previewWiki('mail_text', 'mail_preview', true, 'preview_pv'); return false;" />
</div>
</div>
<textarea name='contenu' rows="30" cols="75" id="mail_text" onkeyup="keepAuth()">
<input type="file" name="uploaded" />
</div>
<div class="center">
- <input type="submit" name="preview" id="preview_bt" value="Aperçu" onclick="previewWiki('mail_text', 'mail_preview', true, 'preview'); return false;" />
+ <input type="submit" name="preview" id="preview_bt" value="Aperçu"
+ onclick="previewWiki('mail_text', 'mail_preview', true, 'preview_pv'); return false;" />
<input type="submit" name="submit" value="Envoyer" />
</div>
</fieldset>