mls en tpl
authorx2000habouzit <x2000habouzit>
Sat, 7 Feb 2004 18:04:55 +0000 (18:04 +0000)
committerx2000habouzit <x2000habouzit>
Sat, 7 Feb 2004 18:04:55 +0000 (18:04 +0000)
configs/mails.conf
include/valid_ml.inc.php
templates/include/form.valid.ml.tpl [new file with mode: 0644]
templates/mails/valid.ml.tpl [new file with mode: 0644]

index cca4383..49f8363 100644 (file)
@@ -9,3 +9,7 @@ cc=Equipe Polytechnique.org <validation+emploi@polytechnique.org>
 [valid_epouses]
 from=Equipe Polytechnique.org <validation+epouse@polytechnique.org>
 cc=Equipe Polytechnique.org <validation+epouse@polytechnique.org>
+
+[valid_ml]
+from=Equipe Polytechnique.org <validation+listes@polytechnique.org>
+cc=Equipe Polytechnique.org <validation+listes@polytechnique.org>
index c991dd4..702df86 100644 (file)
@@ -38,19 +38,12 @@ class MListReq extends Validate {
     }
 
     function formu() {
-        $comment = nl2br($this->comment);
-
-        $pub = $this->publique ? "checked=\"checked\" " : "";
-        $lib = $this->libre    ? "checked=\"checked\" " : "";
-        $fre = $this->freeins  ? "checked=\"checked\" " : "";
-        $arc = $this->archive  ? "checked=\"checked\" " : "";
-        
         $sql = mysql_query("SELECT username FROM auth_user_md5"
             ." WHERE user_id IN ({$this->moderos})"
             ." ORDER BY nom, prenom");
         $tab = array();
         while(list($username) = mysql_fetch_row($sql)) $tab[] = $username;
-        $modero = implode(', ', $tab);
+        $this->moderos_txt = implode(', ', $tab);
         mysql_free_result($sql);
 
         $sql = mysql_query("SELECT username FROM auth_user_md5"
@@ -58,71 +51,9 @@ class MListReq extends Validate {
             ." ORDER BY nom, prenom");
         $tab = array();
         while(list($username) = mysql_fetch_row($sql)) $tab[] = $username;
-        $membres = implode(', ', $tab);
+        $this->membres_txt = implode(', ', $tab);
         mysql_free_result($sql);
-
-        return <<<________EOF
-        <form action="{$_SERVER['PHP_SELF']}" method="POST">
-        <input type="hidden" name="uid" value="{$this->uid}" />
-        <input type="hidden" name="type" value="{$this->type}" />
-        <input type="hidden" name="stamp" value="{$this->stamp}" />
-        <table class="bicol">
-        <tr>
-            <td>Demandeur&nbsp;:</td>
-            <td><a href="javascript:x()" onclick="popWin('/x.php?x={$this->username}')">
-                {$this->prenom} {$this->nom}
-                </a>
-            </td>
-        </tr>
-        <tr>
-            <td>Motif :</td>
-            <td>{$comment}
-            </td>
-        </tr>
-        <tr>
-            <td style="border-top:1px dotted inherit">
-                Alias :
-            </td>
-            <td style="border-top:1px dotted inherit">
-                <input type="text" name="alias" value="{$this->alias}" />@polytechnique.org
-            </td>
-        </tr>
-        <tr>
-            <td>Topic :</td>
-            <td><input type="text" name="topic" size="60" value="{$this->topic}" />
-            </td>
-        </tr>
-        <tr>
-            <td>Propriétés :</td>
-            <td>
-                <input type="checkbox" name="publique" $pub/>Publique
-                <input type="checkbox" name="libre" $lib/>Libre
-                <input type="checkbox" name="freeins" $fre/>Freeins
-                <input type="checkbox" name="archive" $arc/>Archive
-            </td>
-        </tr>
-        <tr>
-            <td style="border-top:1px dotted inherit">Modéros :</td>
-            <td style="border-top:1px dotted inherit">$moderos</td>
-        </tr>
-        <tr>
-            <td>Membres :</td>
-            <td>$membres</td>
-        </tr>
-        <tr>
-            <td style="border-top:1px dotted inherit; vertical-align: middle;">
-                <input type="submit" name="submit" value="Accepter" />
-                <br /><br />
-                <input type="submit" name="submit" value="Refuser" />
-            </td>
-            <td style="border-top:1px dotted inherit">
-                <p>Explication complémentaire (refus ou changement de config, ...)</p>
-                <textarea rows="5" cols="74" name=motif></textarea>
-            </td>
-        </tr>
-        </table>
-        </form>
-________EOF;
+        return 'include/form.valid.ml.tpl';
     }
     
     function handle_formu () {
@@ -143,45 +74,23 @@ ________EOF;
         $this->clean();
         $this->submit();
 
-        require_once("diogenes.mailer.inc.php");
+        require_once("tpl.mailer.inc.php");
         
-        $mymail = new DiogenesMailer('Equipe Polytechnique.org <validation+listes@polytechnique.org>', 
-                $this->username."@polytechnique.org",
-                "[Polytechnique.org/LISTES] Demande de la liste {$this->alias} par ".$this->username,
-                false, "validation+listes@m4x.org");
-
-        $message =
-            "Cher(e) camarade,\n".
-            "\n";
+        $mymail = new TplMailer();
+        $mymail->assign('username',$this->username);
+        $mymail->assign('alias',$this->alias);
+        $mymail->assign('motif',stripslashes($_REQUEST['motif']));
 
         if($_REQUEST['submit']=="Accepter") {
-            if($this->commit()) {
-                $message .=
-                    "  La mailing list {$this->alias} que tu avais demandée vient".
-                    " d'être créée\n";
-                if (!empty($_REQUEST["motif"]))
-                    $message .= "\nInformations complémentaires :\n".
-                        stripslashes($_REQUEST["motif"])."\n";
-            } else {
-                echo "<p class=\"erreur\">Aucun mail envoyé, erreur !</p>\n";
-                return false;
+            $mymail->assign('answer', 'yes');
+            if(!$this->commit()) {
+                return "<p class=\"erreur\">Aucun mail envoyé, erreur !</p>\n";
             }
         } else {
-            $message .=
-                "La demande que tu avais faite pour la mailing list ".
-                $this->alias." a été refusée.\n";
-            if (!empty($_REQUEST["motif"]))
-                $message .= "\nLa raison de ce refus est : \n".
-                    stripslashes($_REQUEST["motif"])."\n";
+            $mymail->assign('answer', 'no');
             $this->clean();
         }
 
-        $message .=
-            "\n".
-            "Cordialement,\n".
-            "L'équipe X.org";
-        $message = wordwrap($message,78);  
-        $mymail->setBody($message);
         $mymail->send();
         return "Mail envoyé";
     }
diff --git a/templates/include/form.valid.ml.tpl b/templates/include/form.valid.ml.tpl
new file mode 100644 (file)
index 0000000..a00779b
--- /dev/null
@@ -0,0 +1,65 @@
+{* $Id: form.valid.ml.tpl,v 1.1 2004-02-07 18:04:56 x2000habouzit Exp $ *}
+
+<form action="{$smarty.server.PHP_SELF}" method="POST">
+<input type="hidden" name="uid" value="{$valid->uid}" />
+<input type="hidden" name="type" value="{$valid->type}" />
+<input type="hidden" name="stamp" value="{$valid->stamp}" />
+<table class="bicol">
+<tr>
+  <td>Demandeur&nbsp;:</td>
+  <td>
+    <a href="javascript:x()" onclick="popWin('/x.php?x={$valid->username}')">
+    {$valid->prenom} {$valid->nom}
+    </a>
+  </td>
+</tr>
+<tr>
+  <td>Motif :</td>
+  <td>{$valid->comment|escape:"html"|nl2br}
+  </td>
+</tr>
+<tr>
+  <td style="border-top:1px dotted inherit">
+    Alias :
+  </td>
+  <td style="border-top:1px dotted inherit">
+    <input type="text" name="alias" value="{$valid->alias}" />@polytechnique.org
+  </td>
+</tr>
+<tr>
+  <td>Topic :</td>
+  <td><input type="text" name="topic" size="60" value="{$valid->topic}" />
+  </td>
+</tr>
+<tr>
+  <td>Propriétés :</td>
+  <td>
+    <input type="checkbox" name="publique" {if $valid->publique}checked="checked"{/if} />Publique
+    <input type="checkbox" name="libre" {if $valid->libre}checked="checked"{/if} />Libre
+    <input type="checkbox" name="freeins" {if $valid->freeins}checked="checked"{/if} />Freeins
+    <input type="checkbox" name="archive" {if $valid->archive}checked="checked"{/if} />Archive
+  </td>
+</tr>
+<tr>
+  <td style="border-top:1px dotted inherit">Modéros :</td>
+  <td style="border-top:1px dotted inherit">{$valid->moderos_txt}</td>
+</tr>
+<tr>
+  <td>Membres :</td>
+  <td>{$valid->membres_txt}</td>
+</tr>
+<tr>
+  <td style="border-top:1px dotted inherit; vertical-align: middle;">
+    <input type="submit" name="submit" value="Accepter" />
+    <br /><br />
+    <input type="submit" name="submit" value="Refuser" />
+  </td>
+  <td style="border-top:1px dotted inherit">
+    <p>Explication complémentaire (refus ou changement de config, ...)</p>
+    <textarea rows="5" cols="74" name=motif></textarea>
+  </td>
+</tr>
+</table>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/mails/valid.ml.tpl b/templates/mails/valid.ml.tpl
new file mode 100644 (file)
index 0000000..f1ca81b
--- /dev/null
@@ -0,0 +1,28 @@
+{* $Id: valid.ml.tpl,v 1.1 2004-02-07 18:04:56 x2000habouzit Exp $ *}
+{config_load file="mails.conf" section="valid_ml"}
+{subject text="[Polytechnique.org/LISTES] Demande de la liste $alias par $username"}
+{from full=#from#}
+{to addr="$username@polytechnique.org"}
+{cc full=#cc#}
+{if $answer eq "yes"}
+Cher(e) camarade,
+
+  La mailing list {$alias} que tu avais demandée vient d'être créée.
+{if $motif}
+Informations complémentaires:
+{$motif}
+{/if}
+
+Cordialement,
+L'équipe X.org
+{elseif $answer eq 'no'}
+Cher(e) camarade,
+
+  La demande que tu avais faite pour la mailing list {$alias} a été refusée.
+La raison de ce refus est :
+{$motif}
+
+Cordialement,
+L'équipe X.org
+{/if}
+{* vim:set nocindent noautoindent textwidth=0: *}