validation evenements
authorx2000habouzit <x2000habouzit>
Sun, 8 Feb 2004 12:21:32 +0000 (12:21 +0000)
committerx2000habouzit <x2000habouzit>
Sun, 8 Feb 2004 12:21:32 +0000 (12:21 +0000)
configs/mails.conf
include/valid_evts.inc.php
templates/include/form.valid.evts.tpl [new file with mode: 0644]
templates/mails/valid.evts.tpl [new file with mode: 0644]

index 01980f3..ba897ca 100644 (file)
@@ -17,3 +17,7 @@ cc=Equipe Polytechnique.org <validation+listes@polytechnique.org>
 [valid_photos]
 from=Equipe Polytechnique.org <validation+trombino@polytechnique.org>
 cc=Equipe Polytechnique.org <validation+trombino@polytechnique.org>
+
+[valid_evts]
+from=Equipe Polytechnique.org <validation+evts@polytechnique.org>
+cc=Equipe Polytechnique.org <validation+evts@polytechnique.org>
index e23cba8..2f0a67b 100644 (file)
@@ -35,100 +35,32 @@ class EvtReq extends Validate {
         return false;  //non unique
     }
 
-    function formu() {
-        return <<<________EOF
-        <form action="{$_SERVER['PHP_SELF']}" method="POST" name="modif">
-          <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" width="98%">
-            <thead>
-              <tr>
-                <th colspan="2">Événement</th>
-              </tr>
-            </thead>
-            <tbody>
-              <tr>
-                <td>
-                  Posté par <a href="javascript:x()"  onclick="popWin('../x.php?x={$this->username}">
-                    {$this->prenom} {$this->nom} (X{$this->promo})
-                  </a>
-                  [<a href="mailto:{$this->username}@polytechnique.org">lui écrire</a>]"
-                </td>
-              </tr>
-              <tr>
-                <th>Titre</th>
-                <td>{$this->titre}</td>
-              </tr>
-              <tr>
-                <th>Texte</th>
-                <td>{$this->texte}</td>
-              </tr>
-              <tr>
-                <th>Péremption</th>
-                <td>{$this->peremption}</td>
-              </tr>
-              <tr>
-                <th>Promos</th>
-                <td>{$this->pmin} - {$this->pmax}</td>
-              </tr>
-              <tr>
-                <th>Commentaire</th>
-                <td>{$this->comment}</td>
-              </tr>
-              <tr>
-                <td class="center" colspan="2">
-                  <input type="submit" name="action" value="Valider" />
-                  <input type="submit" name="action" value="Invalider" />
-                  <input type="submit" name="action" value="Supprimer" />
-                </td>
-              </tr>
-            </tbody>
-          </table>
-        </form>
-________EOF;
-    }
+    function formu() { return 'include/form.valid.evts.tpl'; }
 
     function handle_formu() {
         if (isset($_POST['action'])) {
-            require("diogenes.mailer.inc.php");
-            $mymail = new DiogenesMailer('Equipe Polytechnique.org '
-                .'<validation+recrutement@polytechnique.org>', 
-                $this->username."@polytechnique.org",
-                "[Polytechnique.org/EVENEMENTS] Proposition d'événement",
-                false, "validation+evts@m4x.org");
-
-            $message = "Cher(e) camarade,\n\n";
+            require("tpl.mailer.inc.php");
+            $mymail = new TplMailer('valid.evts.tpl');
+            $mymail->assign('username',$this->username);
+            $mymail->assign('titre',$this->titre);
 
             if($_REQUEST['action']=="Valider") {
-                $req="UPDATE evenements SET creation_date = "
-                ."creation_date, validation_user_id =".$_SESSION['uid']
-                .", validation_date = NULL, flags = CONCAT(flags,"
-                ."',valide')  WHERE id='{$this->evtid}' LIMIT 1";
-                $result = mysql_query ($req);
-                $message .= "L'annonce que tu avais proposée ("
-                    .strip_tags($this->titre).") vient d'être validée.";
+                mysql_query("UPDATE evenements
+                             SET creation_date = creation_date, validation_user_id = {$_SESSION['uid']},
+                                 validation_date = NULL, flags = CONCAT(flags,',valide')
+                             WHERE id='{$this->evtid}' LIMIT 1");
+                $mymail->assign('answer','yes');
             }
             if($_REQUEST['action']=="Invalider") {
-                $req="UPDATE evenements SET creation_date = "
-                ."creation_date, validation_user_id =".$_SESSION['uid']
-                .", validation_date = NULL, flags = REPLACE(flags,"
-                ."'valide','')  WHERE id='{$this->evtid}' LIMIT 1";
-                $result = mysql_query ($req);
-                $message .= "L'annonce que tu avais proposée ("
-                    .strip_tags($this->titre).") a été refusée.";
+                mysql_query("UPDATE evenements
+                             SET creation_date = creation_date, validation_user_id = {$_SESSION['uid']},
+                                 validation_date = NULL, flags = REPLACE(flags,'valide','')
+                             WHERE id='{$this->evtid}' LIMIT 1");
+                $mymail->assign('answer', 'no');
             }
             if($_REQUEST['action']=="Supprimer") {
-                $req="DELETE from evenements WHERE id='{$this->evtid}'"
-                ." LIMIT 1";
-                $result = mysql_query ($req);
+                mysql_query("DELETE from evenements WHERE id='{$this->evtid}' LIMIT 1");
             }
-            $message .=
-                "\n".
-                "Cordialement,\n".
-                "L'équipe X.org";
-            $message = wordwrap($message,78);  
-            $mymail->setBody($message);
             if ($_POST['action']!="Supprimer")
                 $mymail->send();
             $this->clean();
diff --git a/templates/include/form.valid.evts.tpl b/templates/include/form.valid.evts.tpl
new file mode 100644 (file)
index 0000000..873de59
--- /dev/null
@@ -0,0 +1,53 @@
+{* $Id: form.valid.evts.tpl,v 1.1 2004-02-08 12:21:33 x2000habouzit Exp $ *}
+
+<form action="{$smarty.server.PHP_SELF}" method="POST" name="modif">
+  <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" width="98%">
+    <thead>
+      <tr>
+        <th colspan="2">Événement</th>
+      </tr>
+    </thead>
+    <tbody>
+      <tr>
+        <td>
+          Posté par <a href="javascript:x()"  onclick="popWin('{"x.php?x=$valid->username"|url}">
+            {$valid->prenom} {$valid->nom} (X{$valid->promo})
+          </a>
+          [<a href="mailto:{$valid->username}@polytechnique.org">lui écrire</a>]"
+        </td>
+      </tr>
+      <tr>
+        <th>Titre</th>
+        <td>{$valid->titre}</td>
+      </tr>
+      <tr>
+        <th>Texte</th>
+        <td>{$valid->texte}</td>
+      </tr>
+      <tr>
+        <th>Péremption</th>
+        <td>{$valid->peremption}</td>
+      </tr>
+      <tr>
+        <th>Promos</th>
+        <td>{$valid->pmin} - {$valid->pmax}</td>
+      </tr>
+      <tr>
+        <th>Commentaire</th>
+        <td>{$valid->comment}</td>
+      </tr>
+      <tr>
+        <td class="center" colspan="2">
+          <input type="submit" name="action" value="Valider" />
+          <input type="submit" name="action" value="Invalider" />
+          <input type="submit" name="action" value="Supprimer" />
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/mails/valid.evts.tpl b/templates/mails/valid.evts.tpl
new file mode 100644 (file)
index 0000000..f251347
--- /dev/null
@@ -0,0 +1,23 @@
+{* $Id: valid.evts.tpl,v 1.1 2004-02-08 12:21:33 x2000habouzit Exp $ *}
+{config_load file="mails.conf" section="valid_evts"}
+{subject text="[Polytechnique.org/EVENEMENTS] Proposition d'événement"}
+{from full=#from#}
+{to addr="$username@polytechnique.org"}
+{cc full=#cc#}
+{if $answer eq "yes"}
+Cher(e) camarade,
+
+  L'annonce que tu avais proposée ({$titre|strip_tags}) vient d'être validée.
+
+Cordialement,
+L'équipe X.org
+{elseif $answer eq 'no'}
+
+Cher(e) camarade,
+
+  L'annonce que tu avais proposée ({$titre|strip_tags}) a été refusée.
+
+Cordialement,
+L'équipe X.org
+{/if}
+{* vim:set nocindent noautoindent textwidth=0: *}