more improvements + mail moderation
authorx2000habouzit <x2000habouzit>
Wed, 22 Sep 2004 11:39:51 +0000 (11:39 +0000)
committerx2000habouzit <x2000habouzit>
Wed, 22 Sep 2004 11:39:51 +0000 (11:39 +0000)
I still want to give acces for administrators to more things about their ML, so admin.php will still have to evolve.
but I guess the current impl match what was possible before

htdocs/listes/moderate.php
templates/listes/admin.tpl
templates/listes/moderate.tpl
templates/listes/moderate_mail.tpl

index d29cc16..e152246 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: moderate.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $
+        $Id: moderate.php,v 1.3 2004-09-22 11:39:51 x2000habouzit Exp $
  ***************************************************************************/
 
 if(empty($_REQUEST['liste'])) header('Location: index.php');
@@ -42,6 +42,16 @@ if(isset($_POST['sdel'])) {
     $client->handle_request($liste,$_POST['sdel'],2,stripslashes($_POST['reason'])); /** 2 is the magic for REJECT see Defaults.py **/
 }
 
+if(isset($_POST['mid'])) {
+    $mid = $_POST['mid'];
+    if(isset($_POST['mok']))
+       $client->handle_request($liste,$mid,1,''); /** 1 = APPROVE **/
+    elseif(isset($_POST['mno']))
+       $client->handle_request($liste,$mid,2,stripslashes($_POST['reason'])); /** 2 = REJECT **/
+    elseif(isset($_POST['mdel']))
+       $client->handle_request($liste,$mid,3,''); /** 3 = DISCARD **/
+}
+
 if(isset($_REQUEST['sid'])) {
     $sid = $_REQUEST['sid'];
     if(list($subs,$mails) = $client->get_pending_ops($liste)) {
@@ -58,14 +68,25 @@ if(isset($_REQUEST['sid'])) {
        $page->assign_by_ref('subs', $subs);
        $page->assign_by_ref('mails', $mails);
     }
-} elseif(isset($_REQUEST['mid'])) {
+
+} elseif(isset($_GET['mid'])) {
+
     $mid = $_REQUEST['mid'];
-    new_skinned_page('listes/moderate_mail.tpl', AUTH_MDP, true);
     $mail = $client->get_pending_mail($liste,$mid);
     if(is_array($mail)) {
+       new_skinned_page('listes/moderate_mail.tpl', AUTH_MDP, true);
         $page->assign_by_ref('mail', $mail);
+    } else {
+       new_skinned_page('listes/moderate.tpl', AUTH_MDP, true);
+
+       if(list($subs,$mails) = $client->get_pending_ops($liste)) {
+           $page->assign_by_ref('subs', $subs);
+           $page->assign_by_ref('mails', $mails);
+       }
     }
+
 } else {
+    
     new_skinned_page('listes/moderate.tpl', AUTH_MDP, true);
 
     if(list($subs,$mails) = $client->get_pending_ops($liste)) {
@@ -73,5 +94,9 @@ if(isset($_REQUEST['sid'])) {
        $page->assign_by_ref('mails', $mails);
     }
 }
+
+function tolatin1($s) { return iconv('utf-8', 'iso-8859-1', $s); }
+$page->register_modifier('tl1','tolatin1');
+$page->register_modifier('qpd','quoted_printable_decode');
 $page->run();
 ?>
index 89a11ea..50dfbc7 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: admin.tpl,v 1.1 2004-09-21 16:14:35 x2000habouzit Exp $
+        $Id: admin.tpl,v 1.2 2004-09-22 11:39:51 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
 <div class='rubrique'>
   Administrer la liste
 </div>
-{if $details.priv < 2}
+{if $details.you < 2}
 <p class='erreur'>
 Tu n'es pas administrateur de la liste, mais du site.
 </p>
index fe1b1b8..bbdd823 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: moderate.tpl,v 1.4 2004-09-22 08:42:26 x2000habouzit Exp $
+        $Id: moderate.tpl,v 1.5 2004-09-22 11:39:51 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
@@ -74,8 +74,8 @@
   </tr>
   {foreach from=$mails item=m}
   <tr class='{cycle values="pair,impair"}'>
-    <td>{$m.sender}</td>
-    <td>{$m.subj}</td>
+    <td>{$m.sender|tl1}</td>
+    <td>{$m.subj|tl1}</td>
     <td class='right'>{$m.size}o</td>
     <td class='right'>{$m.stamp|date_format:"%H:%M:%S<br />%d %b %Y"}</td>
     <td class='action'>
index 803976a..9af0e63 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: moderate_mail.tpl,v 1.2 2004-09-21 15:40:36 x2000habouzit Exp $
+        $Id: moderate_mail.tpl,v 1.3 2004-09-22 11:39:51 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
 <table class='tinybicol' cellpadding='0' cellspacing='0'>
   <tr>
     <td class='titre'>émetteur</td>
-    <td>{$mail.sender}</td>
+    <td>{$mail.sender|tl1}</td>
   </tr>
   <tr>
     <td class='titre'>sujet</td>
-    <td>{$mail.subj}</td>
+    <td>{$mail.subj|tl1}</td>
   </tr>
   <tr>
     <td class='titre'>taille</td>
   {foreach from=$mail.parts item=part key=i}
   <tr><th>Partie n°{$i}</th></tr>
   <tr class='{cycle values="impair,pair"}'>
-    <td><pre>{$part|regex_replace:"!\\n-- *\\n(.*?)$!sm":"</pre><hr style='width:98%;margin:1%'/><pre>\\1"}</pre></td>
+    <td><pre>{$part|qpd|regex_replace:"!\\n-- *\\n(.*?)$!sm":"</pre><hr style='width:98%;margin:1%'/><pre>\\1"}</pre></td>
   </tr>
   {/foreach}
 </table>
+<br />
 {/if}
 
+<form method='post' action='?liste={$smarty.request.liste}'>
+  <table class='tinybicol' cellpadding='0' cellspacing='0'>
+    <tr>
+      <th class='titre'>Modérer le mail de :</th>
+    </tr>
+    <tr>
+      <td>raison (pour les refus) :
+        <textarea cols='50' rows='10' name='reason'></textarea>
+      </td>
+    </tr>
+    <tr>
+      <td class='center'>
+        <input type='hidden' name='mid' value='{$smarty.get.mid}' />
+        <input type='submit' name='mok' value='Accepter !' />&nbsp;
+        <input type='submit' name='mno' value='Refuser !' />&nbsp;
+        <input type='submit' name='mdel' value='Rejeter !' style='color:red;' />
+      </td>
+    </tr>
+  </table>
+</form>
+
 {/if}
 
 {/dynamic}