From 216f7feda0159d7601eda4d0d29c6adfc090bb36 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 25 Sep 2004 20:11:33 +0000 Subject: [PATCH] big commit with stupid message, BUT ... ... .... ..... ML are DONE oh yeah ! --- configs/mails.conf | 2 +- htdocs/listes/create.php | 88 ++++++++++++++ include/valid_listes.inc.php | 105 +++++++++++++++++ include/validations.inc.php | 5 +- scripts/mailman/mailman-rpc.py | 49 +++++++- scripts/migration.sql | 2 + templates/include/form.valid.listes.tpl | 95 +++++++++++++++ templates/listes/create.tpl | 137 ++++++++++++++++++++++ templates/listes/index.tpl | 17 ++- templates/mails/{valid.ml.tpl => valid.liste.tpl} | 4 +- 10 files changed, 492 insertions(+), 12 deletions(-) create mode 100644 htdocs/listes/create.php create mode 100644 include/valid_listes.inc.php create mode 100644 templates/include/form.valid.listes.tpl create mode 100644 templates/listes/create.tpl rename templates/mails/{valid.ml.tpl => valid.liste.tpl} (94%) diff --git a/configs/mails.conf b/configs/mails.conf index 86541eb..e1b16b0 100644 --- a/configs/mails.conf +++ b/configs/mails.conf @@ -10,7 +10,7 @@ cc=Equipe Polytechnique.org from=Equipe Polytechnique.org cc=Equipe Polytechnique.org -[valid_ml] +[valid_liste] from=Equipe Polytechnique.org cc=Equipe Polytechnique.org diff --git a/htdocs/listes/create.php b/htdocs/listes/create.php new file mode 100644 index 0000000..55bf08a --- /dev/null +++ b/htdocs/listes/create.php @@ -0,0 +1,88 @@ +db->query(" + SELECT a.alias AS forlife + FROM aliases AS a + INNER JOIN aliases AS b USING(id) + WHERE b.alias='{$_POST['add_owner']}' AND b.type!='homonyme' AND a.type='a_vie'"); + if(list($forlife) = mysql_fetch_row($res)) { + $owners [] = $forlife; + } + mysql_free_result($res); +} + +if(isset($_POST['add_member_sub']) && isset($_POST['add_member'])) { + $res = $globals->db->query(" + SELECT a.alias AS forlife + FROM aliases AS a + INNER JOIN aliases AS b USING(id) + WHERE b.alias='{$_POST['add_member']}' AND b.type!='homonyme' AND a.type='a_vie'"); + if(list($forlife) = mysql_fetch_row($res)) { + $members[] = $forlife; + } + mysql_free_result($res); +} + +ksort($owners); array_unique($owners); +ksort($members); array_unique($members); + +if(isset($_POST['submit'])) { + $err = Array(); + + if(empty($_POST['liste'])) $err[] = 'champs «addresse souhaitée» vide'; + + $res = $globals->db->query("SELECT COUNT(*) FROM aliases WHERE alias='{$_POST['liste']}'"); + list($n) = mysql_fetch_row($res); + mysql_free_result($res); + if($n) $err[] = 'cet alias est déjà pris'; + + if(empty($_POST['desc'])) $err[] = 'le sujet est vide'; + if(!count($owners)) $err[] = 'pas de gestionnaire'; + if(count($members)<4) $err[] = 'pas assez de membres'; + + if(!count($err)) { + $page->assign('created', true); + require('validations.inc.php'); + $req = new ListeReq($_SESSION['uid'], $_POST['liste'], $_POST['desc'], + $_POST['advertise'], $_POST['modlevel'], $_POST['inslevel'], + $owners, $members); + $req->submit(); + } else { + $page->assign('err', $err); + } +} + +$page->assign('owners', join("\n",$owners)); +$page->assign('members', join("\n",$members)); +$page->run(); +?> diff --git a/include/valid_listes.inc.php b/include/valid_listes.inc.php new file mode 100644 index 0000000..977717b --- /dev/null +++ b/include/valid_listes.inc.php @@ -0,0 +1,105 @@ +Validate($_uid, true, 'liste', $_stamp); + $this->liste = $_liste; + $this->desc = $_desc; + + $this->advertise = $_advertise; + $this->modlevel = $_modlevel; + $this->inslevel = $_inslevel; + + $this->owners = $_owners; + $this->members = $_members; + + $sql = $globals->db->query(" + SELECT l.alias + FROM auth_user_md5 AS u + INNER JOIN aliases AS l ON (u.user_id=l.id AND type='a_vie') + WHERE user_id='".$this->uid."'"); + list($this->forlife) = mysql_fetch_row($sql); + mysql_free_result($sql); + } + + function get_unique_request($uid) { + return parent::get_unique_request($uid,'liste'); + } + + function formu() { return 'include/form.valid.listes.tpl'; } + + function handle_formu () { + if(empty($_REQUEST['submit']) + || ($_REQUEST['submit']!="Accepter" && $_REQUEST['submit']!="Refuser")) + return false; + + require_once("tpl.mailer.inc.php"); + $mymail = new TplMailer('valid.liste.tpl'); + $mymail->assign('alias', $this->liste); + $mymail->assign('forlife', $this->forlife); + $mymail->assign('motif', stripslashes($_REQUEST['motif'])); + + if($_REQUEST['submit']=="Accepter") { + $mymail->assign('answer', 'yes'); + if(!$this->commit()) return 'problème'; + } else { + $mymail->assign('answer', 'no'); + } + $mymail->send(); + //Suppression de la demande + $this->clean(); + return "Mail envoyé"; + } + + function commit () { + global $globals; + 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"); + $ret = $client->create_list('polytechnique.org', $this->liste, $this->desc, + $this->advertise, $this->modlevel, $this->inslevel, + $this->owners, $this->members); + if($ret) { + $globals->db->query("INSERT INTO aliases (alias,type) VALUES('{$this->liste}', 'liste')"); + } + return $ret; + } +} + +?> diff --git a/include/validations.inc.php b/include/validations.inc.php index da71a32..7f0978e 100644 --- a/include/validations.inc.php +++ b/include/validations.inc.php @@ -18,11 +18,11 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: validations.inc.php,v 1.15 2004-09-02 20:12:08 x2000habouzit Exp $ + $Id: validations.inc.php,v 1.16 2004-09-25 20:11:34 x2000habouzit Exp $ ***************************************************************************/ /* vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: - * $Id: validations.inc.php,v 1.15 2004-09-02 20:12:08 x2000habouzit Exp $ + * $Id: validations.inc.php,v 1.16 2004-09-25 20:11:34 x2000habouzit Exp $ * */ @@ -180,5 +180,6 @@ require("valid_aliases.inc.php"); require("valid_epouses.inc.php"); require("valid_photos.inc.php"); require("valid_evts.inc.php"); +require("valid_listes.inc.php"); ?> diff --git a/scripts/mailman/mailman-rpc.py b/scripts/mailman/mailman-rpc.py index 5fbccc4..6a61b6a 100755 --- a/scripts/mailman/mailman-rpc.py +++ b/scripts/mailman/mailman-rpc.py @@ -18,10 +18,10 @@ #* Foundation, Inc., * #* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * #*************************************************************************** -# $Id: mailman-rpc.py,v 1.40 2004-09-25 15:55:56 x2000habouzit Exp $ +# $Id: mailman-rpc.py,v 1.41 2004-09-25 20:11:35 x2000habouzit Exp $ #*************************************************************************** -import base64, MySQLdb, os, getopt, sys, MySQLdb.converters +import base64, MySQLdb, os, getopt, sys, MySQLdb.converters, sha from pwd import getpwnam from grp import getgrnam @@ -92,9 +92,6 @@ class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): else: return None - def log_message(self, format, *args): - return - ################################################################################ # # XML RPC STUFF @@ -599,8 +596,48 @@ def check_options((userdesc,perms),vhost,listname,correct=False): return (details,options) except: mlist.Unlock() + return 0 + +#------------------------------------------------------------------------------- +# admin procedures [ soptions.php ] +# + +def create_list((userdesc,perms),vhost,listname,desc,advertise,modlevel,inslevel,owners,members): + if perms != 'admin': + return 0 + name = vhost+'-'+listname; + if Utils.list_exists(name): + return 0 + + mlist = MailList.MailList() + try: + oldmask = os.umask(002) + pw = sha.new('foobar').hexdigest() + try: + mlist.Create(name, owners[0]+'@polytechnique.org', pw) + finally: + os.umask(oldmask) + + mlist.real_name = listname + mlist.description = desc + + mlist.advertised = int(advertise) + mlist.default_member_moderation = int(modlevel) is 2 + mlist.generic_nonmember_action = int(modlevel) > 0 + mlist.subscribe_policy = 2 * (int(inslevel) is 1) + + mlist.owner = map(lambda a: a+'@polytechnique.org', owners) + + mlist.Save() + mlist.Unlock() + check_options((userdesc,perms),vhost,listname,True) + mass_subscribe((userdesc,perms),vhost,listname,members) + except: raise return 0 + return 1 + + #------------------------------------------------------------------------------- # server @@ -666,6 +703,8 @@ server.register_function(get_admin_options) server.register_function(set_admin_options) # check.php server.register_function(check_options) +# create +server.register_function(create_list) server.serve_forever() diff --git a/scripts/migration.sql b/scripts/migration.sql index 5612a32..85095bb 100644 --- a/scripts/migration.sql +++ b/scripts/migration.sql @@ -20,6 +20,8 @@ drop trackers; -- pas sur que je veuille le dropper pr le moment celui la ... a voir --*-- ALTER TABLE x4dat.auth_user_md5 DROP COLUMN lastnewslogin; +-- cgt de type pour les ML +ALTER TABLE x4dat.requests CHANGE `type` `type` ENUM('alias','epouse','liste','photo','sondage','emploi','evts' ) DEFAULT 'alias' NOT NULL -- lastlogin --> logger ALTER TABLE x4dat.auth_user_md5 DROP COLUMN lastlogin; ALTER TABLE x4dat.auth_user_md5 DROP COLUMN host; diff --git a/templates/include/form.valid.listes.tpl b/templates/include/form.valid.listes.tpl new file mode 100644 index 0000000..0a081d0 --- /dev/null +++ b/templates/include/form.valid.listes.tpl @@ -0,0 +1,95 @@ +{*************************************************************************** + * 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: form.valid.listes.tpl,v 1.1 2004-09-25 20:11:35 x2000habouzit Exp $ + ***************************************************************************} + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Demandeur : + + forlife}')"> + {$valid->forlife} +
Liste :{$valid->liste}@polytechnique.org
Desc : + {$valid->desc} +
Propriétés : + + + + + + + + + + + + + +
visibilité:{if $valid->advertise}publique{else}privée{/if}
diffusion:{if $valid->modlevel eq 2}modérée{elseif $valid->modlevel}restreinte{else}libre{/if}
inscription:{if $valid->inslevel}modérée{else}libre{/if}
+
Getionnaires : + {foreach from=$valid->owners item=o} + {$o} + {/foreach} +
Membres : + {foreach from=$valid->members item=o} + {$o} + {/foreach} +
+ + + + +

+ +
+ +
+
+ +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/listes/create.tpl b/templates/listes/create.tpl new file mode 100644 index 0000000..72066fd --- /dev/null +++ b/templates/listes/create.tpl @@ -0,0 +1,137 @@ +{*************************************************************************** + * 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: create.tpl,v 1.1 2004-09-25 20:11:36 x2000habouzit Exp $ + ***************************************************************************} + +{dynamic} + +{foreach from=$err item=e} +

{$e}

+{/foreach} + +
+ Création d'une liste de diffusion +
+ +{if $created} +

Demande de création envoyée !

+ +{else} + +

+N'importe qui peut faire la demande de création d'une mailing-list, il suffit pour cela d'être au +moins 4 polytechniciens inscrits sur le site, et de fournir les informations suivantes concernant la +liste : +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Caractéristiques de la Liste
Addresse souhaitée : + @polytechnique.org +
Sujet (bref) : + +
Propriétés : + + + + + + + + + + + + + + + + + + + +
visibilité :publiqueprivée
diffusion :librerestreintemodérée
inscription :libremodérée
+
Membres et Gestionnaires
Gestionnaires + + {$owners|nl2br|default:"pas de gestionnaires"} +
+ + +
Membres + + {$members|nl2br|default:"pas de membres"} +
+ + +
+

+ La création de la liste sera soumise à un contrôle manuel avant d'être validée. Ce contrôle a + pour but notamment de vérifier qu'il n'y aura pas ambiguité entre les membres de la liste et son + identité. Exemple: n'importe qui ne peut pas ouvrir pointgamma@polytechnique.org, il ne suffit + pas d'être le premier à le demander :-) +

+

+ La liste est habituellement créée dans les jours qui suivent la demande sauf exception. Pour plus + d'informations écris-nous à l'adresse {mailto address='listes@polytechnique.org'} en mettant dans + le sujet de ton mail le nom de la liste souhaité afin de faciliter les échanges de mails + ultérieurs éventuels. +

+
+
+ +
+
+ +{/if} + +{/dynamic} + +{* vim:set et sw=2 sts=2 sws=2: *} diff --git a/templates/listes/index.tpl b/templates/listes/index.tpl index 8653e50..2dcc9b3 100644 --- a/templates/listes/index.tpl +++ b/templates/listes/index.tpl @@ -17,7 +17,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: index.tpl,v 1.9 2004-09-25 16:30:26 x2000habouzit Exp $ + $Id: index.tpl,v 1.10 2004-09-25 20:11:36 x2000habouzit Exp $ ***************************************************************************}
@@ -59,11 +59,24 @@ La diffusion a trois niveaux de mod
  • modérée: l'envoi d'un mail à la liste est alors filtré par des modérateurs, eux seuls peuvent accepter un message envoyé à la liste.
  • -

    +

    NB : les gestionnaires d'une liste sont aussi ses modérateurs.

    +
    + Demander la création d'une liste de diffusion +
    + +

    +Nos listes ont pour but de réunir des X autour de thèmes ou centres d'intérêt communs. C'est un +moyen pratique et efficace de rassembler plusieurs personnes autour d'un projet commun ou d'une +thématique particulière. +

    +

    +Tu peux demander la création d'une liste de diffusion sur le thème de ton choix. +

    + {dynamic}
    diff --git a/templates/mails/valid.ml.tpl b/templates/mails/valid.liste.tpl similarity index 94% rename from templates/mails/valid.ml.tpl rename to templates/mails/valid.liste.tpl index f9c9e0f..6e73b95 100644 --- a/templates/mails/valid.ml.tpl +++ b/templates/mails/valid.liste.tpl @@ -17,10 +17,10 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: valid.ml.tpl,v 1.3 2004-09-02 21:09:33 x2000habouzit Exp $ + $Id: valid.liste.tpl,v 1.1 2004-09-25 20:11:36 x2000habouzit Exp $ ***************************************************************************} -{config_load file="mails.conf" section="valid_ml"} +{config_load file="mails.conf" section="valid_liste"} {subject text="[Polytechnique.org/LISTES] Demande de la liste $alias par $forlife"} {from full=#from#} {to addr="$forlife@polytechnique.org"} -- 2.1.4