tons of bugfixes + subscribe moderation now works !!!
authorx2000habouzit <x2000habouzit>
Tue, 21 Sep 2004 15:40:35 +0000 (15:40 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 21 Sep 2004 15:40:35 +0000 (15:40 +0000)
htdocs/listes/index.php
htdocs/listes/liste.php
htdocs/listes/moderate.php
htdocs/listes/trombi.php
scripts/mailman/mailman-rpc.py
templates/listes/liste.tpl
templates/listes/listes.inc.tpl
templates/listes/moderate.tpl
templates/listes/moderate_mail.tpl
templates/listes/moderate_sub.tpl [new file with mode: 0644]

index b8bb818..8c00c89 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: index.php,v 1.1 2004-09-10 11:52:36 x2000habouzit Exp $
+        $Id: index.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $
  ***************************************************************************/
 
 require("auto.prepend.inc.php");
-new_skinned_page('listes/index.tpl', AUTH_COOKIE);
+new_skinned_page('listes/index.tpl', AUTH_MDP);
 include('xml-rpc-client.inc.php');
 $res = $globals->db->query("SELECT password FROM auth_user_md5 WHERE user_id={$_SESSION['uid']}");
 list($pass) = mysql_fetch_row($res);
 mysql_free_result($res);
 
 $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949");
+if(isset($_GET['del'])) { $client->unsubscribe($_GET['del']); header('Location: index.php'); }
+if(isset($_GET['add'])) { $client->subscribe($_GET['add']); header('Location: index.php'); }
 
 $listes = $client->get_lists();
 $page->assign_by_ref('listes',$listes);
index f5c8e5e..e334494 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: liste.php,v 1.5 2004-09-20 20:04:37 x2000habouzit Exp $
+        $Id: liste.php,v 1.6 2004-09-21 15:40:35 x2000habouzit Exp $
  ***************************************************************************/
 
 if(empty($_REQUEST['liste'])) header('Location: index.php');
-$liste = $_REQUEST['liste'];
+$liste = strtolower($_REQUEST['liste']);
 
 require("auto.prepend.inc.php");
 new_skinned_page('listes/liste.tpl', AUTH_MDP, true);
@@ -37,15 +37,7 @@ $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949");
 if(isset($_REQUEST['welc'])) $client->set_welcome($liste, $_REQUEST['welc']);
 
 if(isset($_REQUEST['add_member']) && isset($_REQUEST['member'])) {
-    if(list($added) = $client->mass_subscribe($liste, Array($_REQUEST['member']))) {
-       $members = $client->get_members($liste);
-       include_once("diogenes.mailer.inc.php");
-       $mailer = new DiogenesMailer("\"Mailing list $liste\" <$liste-owner@polytechnique.org>",
-                                    "\"{$added[0]}\" <{$added[1]}>",
-                                    "Bienvenue sur la liste de diffusion $liste@polytechnique.org");
-       $mailer->setBody($members[0]['welc']);
-       $mailer->send();
-    }
+    $client->mass_subscribe($liste, Array($_REQUEST['member']));
 }
 
 if(isset($_REQUEST['del_member']) && isset($_REQUEST['member'])) {
@@ -74,7 +66,7 @@ if(isset($_REQUEST['del_owner']) && isset($_REQUEST['owner'])) {
     mysql_free_result($res);
 }
 
-if(empty($members)) $members = $client->get_members($liste);
+$members = $client->get_members($liste);
 if(is_array($members)) {
     $membres = Array();
     foreach($members[1] as $member) {
index a13f011..d29cc16 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: moderate.php,v 1.1 2004-09-20 20:04:37 x2000habouzit Exp $
+        $Id: moderate.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $
  ***************************************************************************/
 
 if(empty($_REQUEST['liste'])) header('Location: index.php');
-$liste = $_REQUEST['liste'];
+$liste = strtolower($_REQUEST['liste']);
 
 require("auto.prepend.inc.php");
 include('xml-rpc-client.inc.php');
@@ -32,8 +32,33 @@ mysql_free_result($res);
 
 $client = new xmlrpc_client("http://{$_SESSION['uid']}:$pass@localhost:4949");
 if(!$client->is_admin($liste)) header('Location: index.php');
-    
-if(isset($_REQUEST['mid'])) {
+
+if(isset($_REQUEST['sadd'])) {
+    $client->handle_request($liste,$_REQUEST['sadd'],4,''); /** 4 is the magic for SUBSCRIBE see Defaults.py **/
+    header("Location: moderate.php?liste=$liste");
+}
+
+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($_REQUEST['sid'])) {
+    $sid = $_REQUEST['sid'];
+    if(list($subs,$mails) = $client->get_pending_ops($liste)) {
+       foreach($subs as $user) {
+           if($user['id'] == $sid) $u = $user;
+       }
+    }
+
+    if($u) {
+       new_skinned_page('listes/moderate_sub.tpl', AUTH_MDP, true);
+       $page->assign('del_user',$user);
+    } else {
+       new_skinned_page('listes/moderate.tpl', AUTH_MDP, true);
+       $page->assign_by_ref('subs', $subs);
+       $page->assign_by_ref('mails', $mails);
+    }
+} elseif(isset($_REQUEST['mid'])) {
     $mid = $_REQUEST['mid'];
     new_skinned_page('listes/moderate_mail.tpl', AUTH_MDP, true);
     $mail = $client->get_pending_mail($liste,$mid);
index fc886b7..38ee27d 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: trombi.php,v 1.1 2004-09-10 23:13:04 x2000habouzit Exp $
+        $Id: trombi.php,v 1.2 2004-09-21 15:40:35 x2000habouzit Exp $
  ***************************************************************************/
 
 if(empty($_REQUEST['liste'])) header('Location: index.php');
-$liste = $_REQUEST['liste'];
+$liste = strtolower($_REQUEST['liste']);
 
 require("auto.prepend.inc.php");
 new_skinned_page('listes/trombi.tpl', AUTH_COOKIE, true);
index 16cb9ba..abc0b8e 100755 (executable)
@@ -18,7 +18,7 @@
 #*  Foundation, Inc.,                                                      *
 #*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
 #***************************************************************************
-#       $Id: mailman-rpc.py,v 1.20 2004-09-20 20:04:37 x2000habouzit Exp $
+#       $Id: mailman-rpc.py,v 1.21 2004-09-21 15:40:35 x2000habouzit Exp $
 #***************************************************************************
 
 import base64, MySQLdb, os
@@ -167,9 +167,9 @@ def subscribe((userdesc,perms),listname):
     except:
         return 0
     try:
-        if ( mlist.subscribe_policy in (0,1) ) or is_admin_on(userdesc, perms, mlist):
+        if ( mlist.subscribe_policy in (0,1) ) or ( userdesc.address in mlist.owner ) or ( mm_cfg.ADMIN_ML_OWNER in mlist.owner ):
             result = 2
-            mlist.ApprovedAddMember(userdesc,0,0)
+            mlist.ApprovedAddMember(userdesc)
         else:
             result = 1
             try:
@@ -188,7 +188,7 @@ def unsubscribe((userdesc,perms),listname):
     except:
         return 0
     try:
-        mlist.ApprovedDeleteMember(userdesc.address, None, 0, 0)
+        mlist.ApprovedDeleteMember(userdesc.address)
         mlist.Save()
         mlist.Unlock()
         return 1
@@ -222,7 +222,7 @@ def mass_subscribe((userdesc,perms),listname,users):
                 if forlife+'@polytechnique.org' in members:
                     continue
                 userd = UserDesc(forlife+'@polytechnique.org', name, None, 0)
-                mlist.ApprovedAddMember(userd,0,0)
+                mlist.ApprovedAddMember(userd)
                 added.append( (userd.fullname, userd.address) )
         mlist.Save()
     finally:
@@ -238,7 +238,7 @@ def mass_unsubscribe((userdesc,perms),listname,users):
         if not is_admin_on(userdesc, perms, mlist):
             return 0
     
-        map(lambda user: mlist.ApprovedDeleteMember(user+'@polytechnique.org', None, 0, 0), users)
+        map(lambda user: mlist.ApprovedDeleteMember(user+'@polytechnique.org'), users)
         mlist.Save()
     finally:
         mlist.Unlock()
@@ -343,9 +343,12 @@ def handle_request((userdesc,perms),listname,id,value,comment):
     try:
         if not is_admin_on(userdesc, perms, mlist):
             return 0
-        mlist.HandleRequest(int(id),value,comment)
+        mlist.HandleRequest(int(id),int(value),comment)
+        mlist.Save()
+        mlist.Unlock()
         return 1
     except:
+        mlist.Unlock()
         return 0
 
 
index 3541eb8..e4bc567 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: liste.tpl,v 1.7 2004-09-20 20:04:38 x2000habouzit Exp $
+        $Id: liste.tpl,v 1.8 2004-09-21 15:40:36 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
 </table>
 {/if}
 
-{if $details.you > 1 || ($details.priv>1 && $smarty.session.perms eq admin)}
+{if $details.you > 1 || $smarty.session.perms eq admin}
 <div class='rubrique'>
   Administrer la liste
 </div>
+{if $details.priv < 2}
+<p class='erreur'>
+Tu n'es pas administrateur de la liste, mais du site.
+</p>
+{/if}
+
+<p><strong>modération :</strong> <a href='moderate.php?liste={$smarty.request.liste}'>modérer la liste</a></p>
 
 <p>
 Pour entrer un utilisateur, il faut remplir les champs prévus à cet effet par son login,
@@ -149,10 +156,6 @@ c'est-
 Un message est adressé automatiquement à toute personne ajoutée à la liste de diffusion.  Voici le
 message actuellement envoyé : il est modifiable à volonté !
 </p>
-<p>
-L'objet du mail est "Bienvenue sur la liste de diffusion {$details.name} !"<br />
-Et si la personne fait "répondre à", le message arrive aux modérateurs de la liste.
-</p>
 
 <form method='post' action='{$smarty.server.REQUEST_URI}'>
   <div class='center'>
index a0fd164..d25b951 100644 (file)
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: listes.inc.tpl,v 1.1 2004-09-20 21:31:29 x2000habouzit Exp $
+        $Id: listes.inc.tpl,v 1.2 2004-09-21 15:40:36 x2000habouzit Exp $
  ***************************************************************************}
 
-<form action='{$smarty.server.PHP_SELF}'>
-  <table class='bicol' cellpadding='0' cellspacing='0'>
-    <tr>
-      <th>Liste</th>
-      <th>Description</th>
-      <th>Diffusion</th>
-      <th>Inscription</th>
-    </tr>
-    {foreach from=$listes item=liste}
-    {if $liste.priv >= $min && $liste.priv <= $max|default:$min}
-    <tr class='{cycle values="impair,pair"}'>
-      <td>
-        <a href='liste.php?liste={$liste.list}'>{$liste.list}</a>
-        {if $liste.you>1}[<a href='moderate.php?liste={$liste.list}'>mod</a>]{/if}
-      </td>
-      <td>{$liste.desc}</td>
-      <td class='center'>{if $liste.diff}modérée{else}libre{/if}</td>
-      <td class='right'>
-        {if $liste.you is odd}
-        {if $liste.ins}inscrit{/if} <input type='checkbox' checked='checked' name='{$liste.desc}' />
-        {elseif $liste.ins}
-        <input type='submit' name='{$liste.desc}' value='demander' />
-        {else}
-        <input type='checkbox' name='{$liste.desc}' />
-        {/if}
-      </td>
-    </tr>
-    {/if}
-    {/foreach}
-  </table>
-</form>
+<table class='bicol' cellpadding='0' cellspacing='0'>
+  <tr>
+    <th>Liste</th>
+    <th>Description</th>
+    <th>Diffusion</th>
+    <th>Inscription</th>
+    <th></th>
+  </tr>
+  {foreach from=$listes item=liste}
+  {if $liste.priv >= $min && $liste.priv <= $max|default:$min}
+  <tr class='{cycle values="impair,pair"}'>
+    <td>
+      <a href='liste.php?liste={$liste.list}'>{$liste.list}</a>
+      {if $liste.you>1}[<a href='moderate.php?liste={$liste.list}'>mod</a>]{/if}
+    </td>
+    <td>{$liste.desc}</td>
+    <td class='center'>{if $liste.diff}modérée{else}libre{/if}</td>
+    <td class='center'>{if $liste.ins}modérée{else}libre{/if}</td>
+    <td class='right'>
+      {if $liste.you is odd}
+      <a href='{$smarty.server.PHP_SELF}?del={$liste.list}'>me désinscrire</a>
+      {elseif $liste.ins}
+      <a href='{$smarty.server.PHP_SELF}?add={$liste.list}'>m'inscrire</a>
+      {/if}
+    </td>
+  </tr>
+  {/if}
+  {/foreach}
+</table>
 
 {* vim:set et sw=2 sts=2 sws=2: *}
index 771fa66..b1f2be5 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: moderate.tpl,v 1.2 2004-09-20 21:31:29 x2000habouzit Exp $
+        $Id: moderate.tpl,v 1.3 2004-09-21 15:40:36 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
 </div>
 
 {if $subs|@count}
+<table class='bicol' cellpadding='0' cellspacing='0'>
+  <tr>
+    <th>Nom</th>
+    <th>Adresse</th>
+    <th></th>
+  </tr>
+  {foreach from=$subs item=s}
+  <tr class='{cycle values="pair,impair"}'>
+    <td>{$s.name}</td>
+    <td>{$s.addr}</td>
+    <td class='action'>
+      <a href='?liste={$smarty.request.liste}&amp;sadd={$s.id}'>ajouter</a>
+      <a href='?liste={$smarty.request.liste}&amp;sid={$s.id}'>refuser</a>
+    </td>
+  </tr>
+  {/foreach}
+</table>
 {else}
 <p>pas d'inscriptions en attente de modération</p>
 {/if}
@@ -57,7 +74,7 @@
     <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'>
-      <a href='{$smarty.server.PHP_SELF}?liste={$smarty.request.liste}&amp;mid={$m.id}'>voir</a>
+      <a href='?liste={$smarty.request.liste}&amp;mid={$m.id}'>voir</a>
     </td>
   </tr>
   {/foreach}
index 668309f..803976a 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: moderate_mail.tpl,v 1.1 2004-09-20 20:04:38 x2000habouzit Exp $
+        $Id: moderate_mail.tpl,v 1.2 2004-09-21 15:40:36 x2000habouzit Exp $
  ***************************************************************************}
 
 {dynamic}
@@ -70,4 +70,4 @@
 
 {/dynamic}
 
-{* vim:settd>{$mail et sw=2 sts=2 sws=2: *}
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/listes/moderate_sub.tpl b/templates/listes/moderate_sub.tpl
new file mode 100644 (file)
index 0000000..b158d2f
--- /dev/null
@@ -0,0 +1,61 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************
+        $Id: moderate_sub.tpl,v 1.1 2004-09-21 15:40:36 x2000habouzit Exp $
+ ***************************************************************************}
+
+{dynamic}
+
+{if $no_list}
+
+<p class='erreur'>La liste n'existe pas ou tu n'as pas le droit de la modérer</p>
+
+{else}
+
+<div class='rubrique'>
+  Refuser l'inscription d'un utilisateur
+</div>
+
+<form method='post' action='?liste={$smarty.request.liste}'>
+  <table class='tinybicol' cellpadding='0' cellspacing='0'>
+    <tr>
+      <th class='titre'>refuser l'inscription de :</th>
+    </tr>
+    <tr>
+      <td>{$del_user.name}</td>
+    </tr>
+    <tr>
+      <td>raison:
+        <textarea cols='50' rows='10' name='reason'></textarea>
+      </td>
+    </tr>
+    <tr>
+      <td class='center'>
+        <input type='hidden' name='sdel' value='{$del_user.id}' />
+        <input type='submit' value='Refuser !' />
+      </td>
+    </tr>
+  </table>
+</form>
+
+{/if}
+
+{/dynamic}
+
+{* vim:set et sw=2 sts=2 sws=2: *}