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

index 49f8363..01980f3 100644 (file)
@@ -13,3 +13,7 @@ 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>
+
+[valid_photos]
+from=Equipe Polytechnique.org <validation+trombino@polytechnique.org>
+cc=Equipe Polytechnique.org <validation+trombino@polytechnique.org>
index b930003..e861bd7 100644 (file)
@@ -53,42 +53,7 @@ class PhotoReq extends Validate {
         return parent::get_unique_request($uid,'photo');
     }
 
-    function echo_formu() {
-        $url_app = isset($_COOKIE[session_name()]) ?  "" : "&amp;".SID;
-        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" summary="Demande d'alias">
-        <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 style="vertical-align: middle;" colspan="2">
-                <img src="../getphoto.php?x={$this->uid}$url_app" style="width:110px;" alt=" [ PHOTO ] " />
-                <img src="../getphoto.php?x={$this->uid}&amp;req=true$url_app" style="width:110px;" alt=" [ PHOTO ] " />
-            </td>
-        </tr>
-        <tr>
-            <td style="vertical-align: middle;">
-                <input type="submit" name="submit" value="Accepter" />
-                <br /><br />
-                <input type="submit" name="submit" value="Refuser" />
-            </td>
-            <td>
-                <p>Raison du refus:</p>
-                <textarea rows="5" cols="74" name="motif"></textarea>
-            </td>
-        </tr>
-        </table>
-        </form>
-________EOF;
-    }
+    function formu() { return 'include/form.valid.photos.tpl'; }
     
     function handle_formu () {
         global $no_update_bd;
@@ -98,37 +63,16 @@ ________EOF;
                 || ($_REQUEST['submit']!="Accepter" && $_REQUEST['submit']!="Refuser"))
             return false;
         
-        $message = "Cher(e) camarade,\n\n";
-        
-        if($_REQUEST['submit']=="Accepter") {
-            $sql = mysql_query("SELECT alias FROM auth_user_md5 WHERE user_id=".$this->uid);
-            list($old) = mysql_fetch_row($sql);
-            mysql_free_result($sql);
-
-            $message .=
-                "  La demande de changement de photo que tu as "
-                ."demandée vient d'être effectuée.\n\n";
+        require_once("tpl.mailer.inc.php");
+        $mymail = new TplMailer('valid.photos.tpl');
+        $mymail->assign('username', $this->username);
 
+        if($_REQUEST['submit']=="Accepter") {
+            $mymail->assign('answer','yes');
             $this->commit();
-        } else { // c'était donc Refuser
-            $message .=
-                "La demande de changement de photo que tu avais faite a été refusée.\n";
-            if ($_REQUEST["motif"] != "" )
-                $message .= "\nLa raison de ce refus est : \n".
-                    stripslashes($_REQUEST["motif"])."\n\n";
-        }
+        } else
+            $mymail->assign('answer','no');
         
-        $message .=
-            "Cordialement,\n".
-            "L'équipe X.org";
-
-        $message = wordwrap($message,78);  
-        require_once("diogenes.mailer.inc.php");
-        $mymail = new DiogenesMailer('Equipe Polytechnique.org <validation+trombino@polytechnique.org>',
-                $this->username."@polytechnique.org",
-                "[Polytechnique.org/PHOTO] Changement de photo de ".$this->username,
-                false, "validation+trombino@m4x.org");
-        $mymail->setBody($message);
         $mymail->send();
 
         $this->clean();
diff --git a/templates/include/form.valid.photos.tpl b/templates/include/form.valid.photos.tpl
new file mode 100644 (file)
index 0000000..d95c70a
--- /dev/null
@@ -0,0 +1,35 @@
+{* $Id: form.valid.photos.tpl,v 1.1 2004-02-07 18:32:41 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" summary="Demande d'alias">
+<tr>
+  <td>Demandeur&nbsp;:</td>
+  <td><a href="javascript:x()" onclick="popWin('{"x.php?x=$valid->username"|url}')">
+      {$valid->prenom} {$valid->nom}
+      </a>
+  </td>
+</tr>
+<tr>
+  <td style="vertical-align: middle;" colspan="2">
+    <img src="{"getphoto.php?x=$valid->username"|url}" style="width:110px;" alt=" [ PHOTO ] " />
+    <img src="{"getphoto.php?x=$valid->username&amp;req=true"|url}" style="width:110px;" alt=" [ PHOTO ] " />
+  </td>
+</tr>
+<tr>
+  <td style="vertical-align: middle;">
+    <input type="submit" name="submit" value="Accepter" />
+    <br /><br />
+    <input type="submit" name="submit" value="Refuser" />
+  </td>
+  <td>
+    <p>Raison du refus:</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.photos.tpl b/templates/mails/valid.photos.tpl
new file mode 100644 (file)
index 0000000..9d87b5a
--- /dev/null
@@ -0,0 +1,24 @@
+{* $Id: valid.photos.tpl,v 1.1 2004-02-07 18:32:42 x2000habouzit Exp $ *}
+{config_load file="mails.conf" section="valid_photos"}
+{subject text="[Polytechnique.org/PHOTO] Changement de photo de $username"}
+{from full=#from#}
+{to addr="$username@polytechnique.org"}
+{cc full=#cc#}
+{if $answer eq "yes"}
+Cher(e) camarade,
+
+  La demande de changement de photo que tu as demandée vient d'être effectuée.
+
+Cordialement,
+L'équipe X.org
+{elseif $answer eq 'no'}
+Cher(e) camarade,
+
+  La demande de changement de photo que tu avais faite a été refusée.
+La raison de ce refus est :
+{$smarty.request.motif}
+
+Cordialement,
+L'équipe X.org
+{/if}
+{* vim:set nocindent noautoindent textwidth=0: *}