From: x2003bruneau Date: Wed, 6 Dec 2006 00:17:56 +0000 (+0000) Subject: #512, #589: Can attach a file to the emails X-Git-Tag: xorg/0.9.13~217 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=91a14f73f85c6a062976f722361b282c47e05a4c;p=platal.git #512, #589: Can attach a file to the emails Relook X.org 'send a mail' page git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1245 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/ChangeLog b/ChangeLog index b6a6a6e..86ec30f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,9 @@ New: Bug/Wish: + * Emails: + - #512: Can attach a file -FRU + * Lists: - #588: Auto-select mail to moderate -FRU @@ -33,6 +36,7 @@ Bug/Wish: * Xnet: - #570: Fix geoloc skin. -FRU + - #589: Can attach a file when sending an email -FRU From 0.9.12 branch: diff --git a/modules/email.php b/modules/email.php index a1dc2e3..6d690eb 100644 --- a/modules/email.php +++ b/modules/email.php @@ -274,7 +274,21 @@ class EmailModule extends PLModule // action si on recoit un formulaire if (Env::v('submit') == 'Envoyer') { - $to2 = join(', ', Env::v('contacts', Array())); + function getEmails($aliases) + { + if (!is_array($aliases)) { + return null; + } + $rel = Env::v('contacts'); + $ret = array(); + foreach ($aliases as $alias) { + $ret[$alias] = $rel[$alias]; + } + return join(', ', $ret); + } + + $to2 = getEmails(Env::v('to_contacts')); + $cc2 = getEmails(Env::v('cc_contacts')); $txt = str_replace('^M', '', Env::v('contenu')); $to = Env::v('to'); $subj = Env::v('sujet'); @@ -292,6 +306,12 @@ class EmailModule extends PLModule if (!empty($cc)) { $mymail->addCc($cc); } if (!empty($bcc)) { $mymail->addBcc($bcc); } if (!empty($to2)) { $mymail->addTo($to2); } + if (!empty($cc2)) { $mymail->addCc($cc2); } + if (isset($_FILES['uploaded'])) { + $mymail->addAttachment($_FILES['uploaded']['tmp_name'], + $_FILES['uploaded']['type'], + $_FILES['uploaded']['name']); + } $mymail->setTxtBody(wordwrap($txt,72,"\n")); if ($mymail->send()) { $page->trig("Ton mail a bien été envoyé."); diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index ad4ac2a..00bc231 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -283,7 +283,7 @@ class XnetGrpModule extends PLModule require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php'; $tos = get_all_redirects($mbr, $mls, $mmlist); - send_xnet_mails($from, $sujet, $body, $tos, Post::v('replyto')); + send_xnet_mails($from, $sujet, $body, $tos, Post::v('replyto'), $_FILES['uploaded']); $page->kill("Mail envoyé !"); $page->assign('sent', true); } diff --git a/modules/xnetgrp/mail.inc.php b/modules/xnetgrp/mail.inc.php index 3d55413..646883c 100644 --- a/modules/xnetgrp/mail.inc.php +++ b/modules/xnetgrp/mail.inc.php @@ -93,13 +93,13 @@ function _send_xnet_mail($user, $body, $mailer, $replyto = null) $mailer->addHeader('Reply-To', $replyto); } $mailer->setTxtBody(wordwrap($text, 72)); -// $mailer->send(); + $mailer->send(); } // }}} // {{{ send_xnet_mails -function send_xnet_mails($from, $sujet, $body, $tos, $replyto = null) +function send_xnet_mails($from, $sujet, $body, $tos, $replyto = null, $attach = null) { global $globals; $sent = array(); @@ -107,6 +107,11 @@ function send_xnet_mails($from, $sujet, $body, $tos, $replyto = null) $mailer = new PlMailer(); $mailer->setSubject($sujet); $mailer->setFrom($from); + if (isset($attach)) { + $mailer->addAttachment($attach['tmp_name'], + $attach['type'], + $attach['name']); + } foreach ($tos as $user) { if ($sent[$user['email']]) continue; diff --git a/templates/emails/send.tpl b/templates/emails/send.tpl index 0fa0663..a644398 100644 --- a/templates/emails/send.tpl +++ b/templates/emails/send.tpl @@ -22,30 +22,69 @@

Envoyer un mail

- - -
+ @@ -79,78 +118,88 @@ -
Destinataires
- - {if $contacts|@count} - - - -{foreach key=key item=contact from=$contacts} -{if $key is even} - -{/if} - -{if $key is odd} - -{/if} -{/foreach} -{if $key is even} - - -{/if} -
- - {$contact.prenom} {$contact.nom} (X{$contact.promo}) -
-{/if} - - - - - - - - - + - - + - - - - - - -
sujet
- +
+ • Les destinataires sont simplement séparés par des virgules
+ • Pense à te mettre en copie cachée du mail pour en avoir une trace
- Corps du mail + {if $contacts|@count} +
+ Destinataires parmi tes contacts
- -
- -
+
+ Ajouter une pièce jointe :  + +
+
+ +
+
diff --git a/templates/xnet/groupe/mail.tpl b/templates/xnet/groupe/mail.tpl index 3c87b79..75d82d3 100644 --- a/templates/xnet/groupe/mail.tpl +++ b/templates/xnet/groupe/mail.tpl @@ -29,7 +29,7 @@ Ton message peut masculin ou féminin, par son prénom, ou son nom.

-
+ @@ -106,6 +106,14 @@ Le bureau du groupe {$asso.nom}. + + + +
Ecrire un mail :
+ Attacher un fichier + + +