Migrate Xnet mailer to use PlUpload for attachments
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 21 Mar 2007 18:28:47 +0000 (18:28 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 21 Mar 2007 18:28:47 +0000 (18:28 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1596 839d8a87-29fc-0310-9880-83ba4fa771e5

modules/email.php
modules/xnetgrp.php
modules/xnetgrp/mail.inc.php
templates/search/quick.tpl

index 17c3692..5f0428b 100644 (file)
@@ -332,8 +332,8 @@ class EmailModule extends PLModule
             $to   = Env::v('to');
             $subj = Env::v('sujet');
             $from = Env::v('from');
-            $cc   = Env::v('cc');
-            $bcc  = Env::v('bcc');
+            $cc   = trim(Env::v('cc'));
+            $bcc  = trim(Env::v('bcc'));
 
             if (empty($to) && empty($cc) && empty($to2) && empty($bcc) && empty($cc2)) {
                 $page->trig("Indique au moins un destinataire.");
index 42c70c0..e44b1ba 100644 (file)
@@ -301,7 +301,11 @@ 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'), $_FILES['uploaded']);
+            $upload = PlUpload::get($_FILES['uploaded'], S::v('forlife'), 'xnet.emails', true);
+            send_xnet_mails($from, $sujet, $body, $tos, Post::v('replyto'), $upload, @$_FILES['uploaded']['name']);
+            if ($upload) {
+                $upload->rm();
+            }
             $page->kill("Mail envoyé !");
             $page->assign('sent', true);
         }
index 6c6e866..b6574c5 100644 (file)
@@ -99,7 +99,7 @@ function _send_xnet_mail($user, $body, $mailer, $replyto = null)
 // }}}
 // {{{ send_xnet_mails
 
-function send_xnet_mails($from, $sujet, $body, $tos, $replyto = null, $attach = null)
+function send_xnet_mails($from, $sujet, $body, $tos, $replyto = null, $upload = null, $name = null)
 {
     global $globals;
     $sent = array();
@@ -107,10 +107,8 @@ function send_xnet_mails($from, $sujet, $body, $tos, $replyto = null, $attach =
     $mailer = new PlMailer();
     $mailer->setSubject($sujet);
     $mailer->setFrom($from);
-    if (is_uploaded_file($attach['tmp_name'])) {
-        $mailer->addAttachment($attach['tmp_name'],
-                               $attach['type'],
-                               $attach['name']);
+    if ($upload && $upload->exists()) {
+        $mailer->addUploadAttachment($upload, $name);
     }
 
     foreach ($tos as $user) {
index 7abdf64..28342e8 100644 (file)
 
 {include file=search/quick.form.tpl show_js=1}
 
+{if $smarty.session.perms->hasFlag('user')}
 <h1>Voir le trombi d'une promotion</h1>
 
 <div id="message" style="position:absolute;"></div><br />
 
 <script type="text/javascript">
-  {literal}
+  {liiteral}
   function showPromo()
   {
       var value = document.getElementById('promo').value;
@@ -42,7 +43,7 @@
 </script>
 
 <form action="" method="post" onsubmit="return showPromo();">
-<table class="tinybicol" style="width: 30%; margin-right: auto; margin-left: auto">
+<table class="tinybicol" style="width: 35%; margin-right: auto; margin-left: auto">
   <td class="titre">Promotion :</td>
   <td>
     <input type="text" name="promo" id="promo" size="4" value="" />
@@ -51,6 +52,8 @@
 </table>
 </form>
 
+{/if}
+
 <h1>Comment faire une recherche ?</h1>
 
 <h2>Nom, Prenom, Promo ...</h2>