various bugfixes, closes FS#18
authorx2000habouzit <x2000habouzit>
Tue, 31 Aug 2004 08:57:24 +0000 (08:57 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 31 Aug 2004 08:57:24 +0000 (08:57 +0000)
htdocs/sendmail.php
templates/sendmail.tpl

index 68778f4..f14f1d2 100644 (file)
@@ -2,6 +2,7 @@
 require("auto.prepend.inc.php");
 new_skinned_page('sendmail.tpl',AUTH_MDP,true);
 
+
 // action si on recoit un formulaire
 if (isset($_REQUEST['submit']) and $_REQUEST['submit'] == 'Envoyer'
     and isset($_REQUEST['to']) and isset($_REQUEST['sujet']) 
@@ -9,18 +10,19 @@ if (isset($_REQUEST['submit']) and $_REQUEST['submit'] == 'Envoyer'
     and isset($_REQUEST['bcc'])) {
         $autre_to = (isset($_REQUEST['contacts']) ? join(', ',$_REQUEST['contacts']) : '');
 
+    if (get_magic_quotes_gpc()) {
+       $_REQUEST['contenu'] = str_replace('\r', '', stripslashes($_REQUEST['contenu']));
+       $_REQUEST['to'] = stripslashes($_REQUEST['to']);
+       $_REQUEST['sujet'] = stripslashes($_REQUEST['sujet']);
+       $_REQUEST['from'] = stripslashes($_REQUEST['from']);
+       $_REQUEST['cc'] = stripslashes($_REQUEST['cc']);
+       $_REQUEST['bcc'] = stripslashes($_REQUEST['bcc']);
+       $autre_to = stripslashes($autre_to);
+    }
+
     if ($_REQUEST['to'] == '' and $_REQUEST['cc'] == '' and $autre_to == '') {
-        echo "<p class=\"erreur\">\n  Indique au moins un destinataire.\n</p>\n";
+        $page->assign('error',"Indique au moins un destinataire.");
     } else {
-        if (get_magic_quotes_gpc()) {
-            $_REQUEST['contenu'] = str_replace('\r', '', stripslashes($_REQUEST['contenu']));
-            $_REQUEST['to'] = stripslashes($_REQUEST['to']);
-            $_REQUEST['sujet'] = stripslashes($_REQUEST['sujet']);
-            $_REQUEST['from'] = stripslashes($_REQUEST['from']);
-            $_REQUEST['cc'] = stripslashes($_REQUEST['cc']);
-            $_REQUEST['bcc'] = stripslashes($_REQUEST['bcc']);
-            $autre_to = stripslashes($autre_to);
-        }
         require("diogenes.mailer.inc.php");
         $FROM = "From: {$_REQUEST['from']}";
         //$_REQUEST['contenu'] = chunk_split($_REQUEST['contenu'], 76, "\n"); // pas bon, ne tient pas compte des mots
index 41cde5a..f71e126 100644 (file)
@@ -1,8 +1,8 @@
-{* $Id: sendmail.tpl,v 1.7 2004-08-29 16:20:42 x2000habouzit Exp $ *}
+{* $Id: sendmail.tpl,v 1.8 2004-08-31 08:57:24 x2000habouzit Exp $ *}
 
 {dynamic}
 
-{$error}
+<p class="erreur">{$error}</p>
 
 <div class="rubrique">
   Envoyer un mail
   </li>
 </ul>
 
-<form action="{$smarty.server.REQUEST_URI}" method="post">
+<script type="text/javascript">//<![CDATA[
+  {literal}
+  function check(form) {
+    if(form.sujet.value == "") {
+      return confirm ("Le sujet du mail est vide, veux tu continuer ?");
+    }
+    return true;
+  }
+  {/literal}
+//]]>
+</script>
+
+<form action="{$smarty.server.REQUEST_URI}" method="post" onsubmit="return check(this);">
   <table class="bicol" cellpadding="2" cellspacing="0" summary="En-têtes du message">
     <tr> 
       <th colspan="2">en-têtes</th>
@@ -52,7 +64,7 @@
     <tr> 
       <td class="titre">copie cachée&nbsp;:</td>
       <td>
-        <input type='text' name='bcc' size='45' value="{$smarty.request.bcc}" />
+        <input type='text' name='bcc' size='45' value="{$smarty.request.bcc|default:$smarty.session.username}" />
       </td>
     </tr>
     <tr> 
@@ -79,9 +91,9 @@
 {/if}
     <td>
       <input type="checkbox" name="contacts[{$contact.username}]"
-      value="{"`$contact.prenom` `$contact.nom` &lt;`$contact.username`@polytechnique.org&gt;"}"
+        value="{$contact.prenom} {$contact.nom} &lt;{$contact.username}@polytechnique.org&gt;"
         {if $smarty.request.contacts && $smarty.request.contacts.username}checked="checked"{/if} />
-        <a href="javascript:x()" onclick="popWin('fiche.php?user={$contact.username}')">{$contact.prenom} {$contact.nom}</a> (X{$contact.promo})
+      <a href="javascript:x()" onclick="popWin('fiche.php?user={$contact.username}')">{$contact.prenom} {$contact.nom}</a> (X{$contact.promo})
     </td>
 {if $key is odd}
   </tr>
       <td class="center">
         <textarea name='contenu' rows="30" cols="75">
 {$smarty.request.contenu}
-{if $smarty.request.signature}
-
+{if !$smarty.request.contenu}
 -- 
 {$smarty.session.prenom} {$smarty.session.nom}
 {/if}</textarea>