1 {**************************************************************************}
3 {* Copyright (C) 2003-2011 Polytechnique.org *}
4 {* http://opensource.polytechnique.org/ *}
6 {* This program is free software; you can redistribute it and/or modify *}
7 {* it under the terms of the GNU General Public License as published by *}
8 {* the Free Software Foundation; either version 2 of the License, or *}
9 {* (at your option) any later version. *}
11 {* This program is distributed in the hope that it will be useful, *}
12 {* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
13 {* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
14 {* GNU General Public License for more details. *}
16 {* You should have received a copy of the GNU General Public License *}
17 {* along with this program; if not, write to the Free Software *}
18 {* Foundation, Inc., *}
19 {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
21 {**************************************************************************}
23 <h1>Envoyer un email</h1>
25 <script type="text/javascript">//<![CDATA[
27 function _selectAll(id) {
28 var list = document.getElementById(id);
29 for (i = 0 ; i < list.length ; i++) {
30 list.options[i].selected = true;
37 _selectAll('to_contacts');
38 _selectAll('cc_contacts');
39 if(form.sujet.value == "" && !confirm("Le sujet de l'email est vide, veux-tu continuer ?")) {
43 if (form.to.value == "" && form.cc.value == ""
44 && document.getElementById('to_contacts').length == 0 && document.getElementById('cc_contacts').length == 0) {
45 if (form.bcc.value == "") {
46 alert("Il faut définir au moins un destinataire.");
49 if (!confirm("Tous les destinataires sont en copie cachée, veux-tu continuer ?")) {
58 function saveMessage() {
59 var form = document.forms.form_mail;
62 for (var i = 0 ; i < form['to_contacts[]'].length ; ++i) {
63 toc += form['to_contacts[]'].options[i].value + ";";
65 for (var i = 0 ; i < form['cc_contacts[]'].length ; ++i) {
66 ccc += form['cc_contacts[]'].options[i].value + ";";
68 $.xpost("emails/send",
70 token: '{xsrf_token}',
71 from: form.from.value,
74 contenu: form.contenu.value,
76 sujet: form.sujet.value,
78 bcc: form.bcc.value });
82 function _keepAuth() {
90 setTimeout("_keepAuth()", 10000);
94 function _move(idFrom, idTo) {
95 var from = document.getElementById(idFrom);
96 var to = document.getElementById(idTo);
98 var index = new Array();
100 for (i = 0 ; i < from.length ; i++) {
101 if (from.options[i].selected) {
102 var option = document.createElement('option');
103 option.value = from.options[i].value;
104 option.text = from.options[i].text;
106 to.add(option, null);
113 for (i = index.length - 1 ; i >= 0 ; i--) {
114 from.remove(index[i]);
119 _move('contacts', 'to_contacts');
122 function removeTo() {
123 _move('to_contacts', 'contacts');
127 _move('contacts', 'cc_contacts');
130 function removeCc() {
131 _move('cc_contacts', 'contacts');
134 function updateWikiView(box) {
136 document.getElementById("preview_bt").style.display = "none";
137 document.getElementById("preview").style.display = "none";
138 document.getElementById("preview_pv").style.display = "none";
140 document.getElementById("preview_bt").style.display = "";
141 document.getElementById("preview").style.display = "";
145 function toggleWiki()
147 if ($('[name="wiki"]').val() == 'text') {
148 $('[name="wiki"]').val('wiki');
150 $('[name="wiki"]').val('text');
164 // Remove empty options in select (they were added only for HTML
166 $('#to_contacts option[value=""]').remove();
167 $('#cc_contacts option[value=""]').remove();
171 $("[name='to']").focus();
178 <small>{icon name=information title="Envoi d'email"} Pour envoyer un email, tu peux soit le faire depuis l'interface
179 ci-dessous, soit utiliser <a href="Xorg/SMTPSecurise">notre serveur d'envoi SMTP</a>.</small>
182 <form action="emails/send" method="post" enctype="multipart/form-data" id="form_mail" onsubmit="return check(this);">
184 <table class="bicol" cellpadding="2" cellspacing="0">
186 <th colspan="2">Destinataires</th>
189 <td class="titre">de :</td>
191 <input type='hidden' name='signature' value='1' />
192 <input type='text' name='from' size='60'
193 value="{if $smarty.request.from}{$smarty.request.from}{else}{$preferences.from_email}{/if}" />
197 <td class="titre">à :</td>
199 <input type='text' name='to' size='60' value="{$smarty.request.to}" />
203 <td class="titre">copie :</td>
205 <input type='text' name='cc' size='60' value="{$smarty.request.cc}" />
209 <td class="titre">copie cachée :</td>
211 <input type='text' name='bcc' size='60' value="{$smarty.request.bcc}" />
215 <td colspan="2" class="smaller">
216 • Les destinataires sont simplement séparés par des virgules.<br />
217 • Pense à te mettre en copie cachée de l'email pour en avoir une trace.
220 {if $contacts|@count}
223 Destinataires parmi tes contacts
227 <td colspan="2" style="padding: 4px">
228 <div style="float: right; width: 40%;">
229 <select id="to_contacts" name="to_contacts[]" multiple="multiple" style="width: 100%; height: 5em">
230 {foreach key=key item=contact from=$contacts}
231 {if t($smarty.request.to_contacts) && in_array($contact->hrpid,$smarty.request.to_contacts)}
232 <option value="{$contact->hrpid}">
233 {$contact->full_name}
235 {assign var="to_not_empty" value="true"}
239 {* HTML compatibility *}
240 <option value=""> </option>
246 <select id="cc_contacts" name="cc_contacts[]" multiple="multiple" style="width: 100%; height: 5em">
247 {foreach key=key item=contact from=$contacts}
248 {if t($smarty.request.cc_contacts) && in_array($contact->hrpid,$smarty.request.cc_contacts)}
249 <option value="{$contact->hrpid}">
250 {$contact->full_name}
252 {assign var="cc_not_empty" value="true"}
256 {* HTML compatibility *}
257 <option value=""> </option>
261 <div style="width: 19%; text-align: center; height: 8em; float: right;">
262 <div style="height: 4em">
264 <a href="emails/send/addTo" onclick="addTo(); return false" style="text-decoration: none">>> >></a><br />
265 <a href="emails/send/removeTo" onclick="removeTo(); return false" style="text-decoration: none"><< <<</a>
267 <div style="height: 4em">
269 <a href="emails/send/addCc" onclick="addCc(); return false" style="text-decoration: none">>> >></a><br />
270 <a href="emails/send/removeCc" onclick="removeCc(); return false" style="text-decoration: none"><< <<</a>
273 <div style="float: right; width: 40%">
274 <select id="contacts" name="all_contacts[]" multiple="multiple" style="height: 10em; width: 100%">
275 {foreach item=contact from=$contacts}
276 {if !(isset($smarty.request.to_contacts|smarty:nodefaults) && isset($smarty.request.cc_contacts|smarty:nodefaults)) ||
277 (!in_array($contact->hrpid,$smarty.request.to_contacts) && !in_array($contact->hrpid,$smarty.request.cc_contacts))}
278 <option value="{$contact->hrpid}">
279 {$contact->full_name}
290 <legend>Sujet : <input type='text' name='sujet' size='60' value="{$smarty.request.sujet}" /></legend>
292 Tu peux utiliser des <a href="wiki_help" class="popup3">{icon name=information title="Syntaxe wiki"} marqueurs wiki</a> pour formatter ton texte.<br />
294 <input type="hidden" name="wiki" value="{$smarty.request.wiki|default:$preferences.from_format}" />
295 <input type="checkbox" {if $smarty.request.wiki eq "text" || (!$smarty.request.wiki && $preferences.from_format eq "text")}checked="checked"{/if}
296 onchange="updateWikiView(this); toggleWiki();" />
297 coche cette case pour envoyer l'email en texte brut, sans formattage
301 <div id="preview_pv" style="display: none">
302 <strong>Aperçu de l'email :</strong>
303 <div id="mail_preview">
306 <input type="submit" name="submit" value="Envoyer" />
310 <input type="submit" name="preview" id="preview_bt_top" value="Aperçu"
311 onclick="previewWiki('mail_text', 'mail_preview', true, 'preview_pv'); return false;" />
314 <textarea name='contenu' rows="30" cols="75" id="mail_text" onkeyup="keepAuth()">
315 {$smarty.request.contenu}
316 {if !$smarty.request.contenu}
318 {$smarty.session.user->full_name}
320 <script type="text/javascript">//<![CDATA[
322 function removeAttachments()
324 $.xget('email/send');
325 $('#att_already').hide();
326 $('#att_form').show();
330 {if $uploaded_f|@count}
331 <div id="att_already">
332 <strong>{icon name=email_attach} Pièce jointe : </strong>
334 <a href="javascript:removeAttachments()">
335 {icon name=cross alt="Supprimer" title="Supprimer la pièce jointe"}
339 <div id="att_form" {if $uploaded_f|@count neq 0}style="display: none"{/if}>
340 <strong>{icon name=email_attach} Ajouter une pièce jointe (max. {$maxsize}) : </strong>
341 <input type="file" name="uploaded" />
344 <input type="submit" name="preview" id="preview_bt" value="Aperçu"
345 onclick="previewWiki('mail_text', 'mail_preview', true, 'preview_pv'); return false;" />
346 <input type="submit" name="submit" value="Envoyer" />
352 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}