From 80f44cfedec2007a6f9bfb7bf516d452281fc225 Mon Sep 17 00:00:00 2001
From: x2000habouzit
Date: Sat, 15 Jul 2006 13:33:30 +0000
Subject: [PATCH] migrate list creation. fix problem with list deletion.
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@496 839d8a87-29fc-0310-9880-83ba4fa771e5
---
htdocs.net/groupe/listes-create.php | 54 ------------------------
include/xnet/page.inc.php | 4 +-
modules/lists.php | 2 +-
modules/xnetlists.php | 74 +++++++++++++++++++++++++++++++++
templates/xnet/groupe/listes-create.tpl | 2 +-
5 files changed, 78 insertions(+), 58 deletions(-)
delete mode 100644 htdocs.net/groupe/listes-create.php
diff --git a/htdocs.net/groupe/listes-create.php b/htdocs.net/groupe/listes-create.php
deleted file mode 100644
index 7934c0b..0000000
--- a/htdocs.net/groupe/listes-create.php
+++ /dev/null
@@ -1,54 +0,0 @@
-assign('force_list_super', may_update());
-
-if (Post::has('submit')) {
- if (!Post::has('liste')) {
- $page->trig_run('champs «addresse souhaitée» vide');
- }
-
- $liste = Post::get('liste');
-
- if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
- $page->trig_run('le nom de la liste ne doit contenir que des lettres, chiffres et tirets');
- }
-
- $new = $liste.'@'.$globals->asso('mail_domain');
- $res = $globals->xdb->query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
- $n = $res->fetchOneCell();
-
- if($n) {
- $page->trig_run('cet alias est déjà pris');
- }
- if(!Post::get('desc')) {
- $page->trig_run('le sujet est vide');
- }
-
- require_once('platal/xmlrpc-client.inc.php');
- require_once('lists.inc.php');
- $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain'));
- $ret = $client->create_list($liste, Post::get('desc'), Post::get('advertise'), Post::get('modlevel'), Post::get('inslevel'), array(Session::get('forlife')), array());
-
- $dom = strtolower($globals->asso("mail_domain"));
- $red = $dom.'_'.$liste;
-
- if($ret) {
- $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'@'.$dom, 'list');
- $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+post@listes.polytechnique.org");
- $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-owner@'.$dom, 'list');
- $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+owner@listes.polytechnique.org");
- $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-admin@'.$dom, 'list');
- $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+admin@listes.polytechnique.org");
- $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-bounces@'.$dom, 'list');
- $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+bounces@listes.polytechnique.org");
- redirect("listes-admin.php?liste=$liste");
- } else {
- $page->kill("Un problème est survenu, contacter support@m4x.org");
- }
-}
-
-$page->run()
-
-?>
diff --git a/include/xnet/page.inc.php b/include/xnet/page.inc.php
index ffcf56e..2939ebe 100644
--- a/include/xnet/page.inc.php
+++ b/include/xnet/page.inc.php
@@ -79,7 +79,7 @@ class XnetPage extends PlatalPage
$sub['carte'] = "$dim/geoloc.php";
}
if ($globals->asso('mail_domain')) {
- $sub['listes de diffusion'] = "$dim/listes.php";
+ $sub['listes de diffusion'] = "$dim/lists";
}
$sub['événement'] = "$dim/evenements.php";
if (false) {
@@ -97,7 +97,7 @@ class XnetPage extends PlatalPage
$sub['wiki'] = "$dim/Accueil";
if ($globals->asso('mail_domain')) {
$sub['envoyer un mail'] = "$dim/mail";
- $sub['créer une liste'] = "$dim/listes-create.php";
+ $sub['créer une liste'] = "$dim/lists/create";
$sub['créer un alias'] = "$dim/alias-create.php";
}
$menu['Administrer Groupe'] = $sub;
diff --git a/modules/lists.php b/modules/lists.php
index 2f74ea6..6435b4d 100644
--- a/modules/lists.php
+++ b/modules/lists.php
@@ -557,7 +557,7 @@ class ListsModule extends PLModule
foreach (array('', '-owner', '-admin', '-bounces') as $app) {
$globals->xdb->execute("DELETE FROM aliases
WHERE type='liste' AND alias='{?}'",
- $ml.$app);
+ $liste.$app);
}
$page->assign('deleted', true);
} elseif (list($details,$options) = $this->client->get_owner_options($liste)) {
diff --git a/modules/xnetlists.php b/modules/xnetlists.php
index b07f7ef..97a74db 100644
--- a/modules/xnetlists.php
+++ b/modules/xnetlists.php
@@ -106,6 +106,80 @@ class XnetListsModule extends ListsModule
$page->assign('may_update', may_update());
}
+ function handler_create(&$page)
+ {
+ global $globals;
+
+ $this->prepare_client($page);
+
+ $page->changeTpl('xnet/groupe/listes-create.tpl');
+ $page->assign('force_list_super', may_update());
+
+ if (!Post::has('submit')) {
+ return;
+ }
+
+ if (!Post::has('liste')) {
+ $page->trig_run('champs «addresse souhaitée» vide');
+ }
+
+ $liste = Post::get('liste');
+
+ if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
+ $page->trig_run('le nom de la liste ne doit contenir que des lettres, chiffres et tirets');
+ }
+
+ $new = $liste.'@'.$globals->asso('mail_domain');
+ $res = $globals->xdb->query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
+ $n = $res->fetchOneCell();
+
+ if($n) {
+ $page->trig_run('cet alias est déjà pris');
+ }
+ if(!Post::get('desc')) {
+ $page->trig_run('le sujet est vide');
+ }
+
+ require_once('platal/xmlrpc-client.inc.php');
+ require_once('lists.inc.php');
+ $ret = $this->client->create_list(
+ $liste, Post::get('desc'), Post::get('advertise'),
+ Post::get('modlevel'), Post::get('inslevel'),
+ array(Session::get('forlife')), array());
+
+ $dom = strtolower($globals->asso("mail_domain"));
+ $red = $dom.'_'.$liste;
+
+ if (!$ret) {
+ $page->kill("Un problème est survenu, contacter "
+ ."support@m4x.org");
+ return;
+ }
+ $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type)
+ VALUES({?},{?})', $liste.'@'.$dom, 'list');
+ $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
+ VALUES ({?}, {?})', mysql_insert_id(),
+ "$red+post@listes.polytechnique.org");
+ $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type)
+ VALUES({?},{?})', $liste.'-owner@'.$dom, 'list');
+ $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
+ VALUES ({?}, {?})', mysql_insert_id(),
+ "$red+owner@listes.polytechnique.org");
+ $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type)
+ VALUES({?},{?})', $liste.'-admin@'.$dom, 'list');
+ $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
+ VALUES ({?}, {?})', mysql_insert_id(),
+ "$red+admin@listes.polytechnique.org");
+ $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type)
+ VALUES({?},{?})', $liste.'-bounces@'.$dom, 'list');
+ $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
+ VALUES ({?}, {?})', mysql_insert_id(),
+ "$red+bounces@listes.polytechnique.org");
+
+ global $platal;
+ redirect(smarty_function_rel().'/'.$platal->ns.'lists/admin/'.$liste);
+ }
+
function handler_sync(&$page, $liste = null)
{
global $globals;
diff --git a/templates/xnet/groupe/listes-create.tpl b/templates/xnet/groupe/listes-create.tpl
index 0ab584c..25aae99 100644
--- a/templates/xnet/groupe/listes-create.tpl
+++ b/templates/xnet/groupe/listes-create.tpl
@@ -33,7 +33,7 @@ D'autre part, il est impossible d'inscrire une liste de diffusion
Si tu as besoin de cette fonctionnalité, il faut alors impérativement utiliser
un alias qui, lui, est capable de regrouper plusieurs listes.
-