<?php
/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
+ * Copyright (C) 2003-2007 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
'%grp/lists/create' => $this->make_hook('create', AUTH_MDP),
'%grp/lists/members' => $this->make_hook('members', AUTH_COOKIE),
+ '%grp/lists/trombi' => $this->make_hook('trombi', AUTH_COOKIE),
'%grp/lists/archives' => $this->make_hook('archives', AUTH_COOKIE),
'%grp/lists/moderate' => $this->make_hook('moderate', AUTH_MDP),
'%grp/lists/check' => $this->make_hook('check', AUTH_MDP),
'%grp/lists/sync' => $this->make_hook('sync', AUTH_MDP),
- '%grp/alias/admin' => $this->make_hook('aadmin', AUTH_MDP),
- '%grp/alias/create' => $this->make_hook('acreate', AUTH_MDP),
+ '%grp/alias/admin' => $this->make_hook('aadmin', AUTH_MDP, 'groupadmin'),
+ '%grp/alias/create' => $this->make_hook('acreate', AUTH_MDP, 'groupadmin'),
/* hack: lists uses that */
'profile' => $this->make_hook('profile', AUTH_PUBLIC),
{
global $globals;
- require_once 'lists.inc.php';
+ require_once dirname(__FILE__).'/lists/lists.inc.php';
- $this->client =& lists_xmlrpc(S::v('uid'), S::v('password'),
- $globals->asso('mail_domain'));
+ $this->client = new MMList(S::v('uid'), S::v('password'),
+ $globals->asso('mail_domain'));
- $page->useMenu();
$page->assign('asso', $globals->asso());
$page->setType($globals->asso('cat'));
+
+ return $globals->asso('mail_domain');
}
function handler_lists(&$page)
{
global $globals;
+ if (!$globals->asso('mail_domain')) {
+ return PL_NOT_FOUND;
+ }
$this->prepare_client($page);
- $page->changeTpl('xnetlists/index.tpl');
+ new_group_page('xnetlists/index.tpl');
if (Get::has('del')) {
$this->client->unsubscribe(Get::v('del'));
USING x4dat.virtual AS v
LEFT JOIN x4dat.virtual_redirect USING(vid)
WHERE v.alias={?}', $alias);
- $page->trig(Post::v('del_alias')." supprimé !");
+ $page->trig(Post::v('del_alias')." supprimé !");
}
$listes = $this->client->get_lists();
{
global $globals;
+ if (!$globals->asso('mail_domain')) {
+ return PL_NOT_FOUND;
+ }
$this->prepare_client($page);
$page->changeTpl('xnetlists/create.tpl');
- $page->assign('force_list_super', may_update());
if (!Post::has('submit')) {
return;
}
if (!Post::has('liste')) {
- $page->trig('champs «addresse souhaitée» vide');
+ $page->trig('champs «addresse souhaitée» vide');
return;
}
- $liste = Post::v('liste');
+ $liste = strtolower(Post::v('liste'));
if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
- $page->trig('le nom de la liste ne doit contenir que des lettres, chiffres et tirets');
+ $page->trig('le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets');
return;
}
$n = $res->fetchOneCell();
if ($n) {
- $page->trig('cet alias est déjà pris');
+ $page->trig('cet alias est déjà pris');
return;
}
if (!Post::v('desc')) {
return;
}
- require_once 'lists.inc.php';
$ret = $this->client->create_list(
$liste, Post::v('desc'), Post::v('advertise'),
Post::v('modlevel'), Post::v('inslevel'),
$red = $dom.'_'.$liste;
if (!$ret) {
- $page->kill("Un problème est survenu, contacter "
+ $page->kill("Un problème est survenu, contacter "
."<a href='mailto:support@m4x.org'>support@m4x.org</a>");
return;
}
XDB::execute('INSERT INTO x4dat.virtual (alias,type)
VALUES({?},{?})', $liste.'@'.$dom, 'list');
XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
- VALUES ({?}, {?})', mysql_insert_id(),
+ VALUES ({?}, {?})', XDB::insertId(),
"$red+post@listes.polytechnique.org");
XDB::execute('INSERT INTO x4dat.virtual (alias,type)
VALUES({?},{?})', $liste.'-owner@'.$dom, 'list');
XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
- VALUES ({?}, {?})', mysql_insert_id(),
+ VALUES ({?}, {?})', XDB::insertId(),
"$red+owner@listes.polytechnique.org");
XDB::execute('INSERT INTO x4dat.virtual (alias,type)
VALUES({?},{?})', $liste.'-admin@'.$dom, 'list');
XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
- VALUES ({?}, {?})', mysql_insert_id(),
+ VALUES ({?}, {?})', XDB::insertId(),
"$red+admin@listes.polytechnique.org");
XDB::execute('INSERT INTO x4dat.virtual (alias,type)
VALUES({?},{?})', $liste.'-bounces@'.$dom, 'list');
XDB::execute('INSERT INTO x4dat.virtual_redirect (vid,redirect)
- VALUES ({?}, {?})', mysql_insert_id(),
+ VALUES ({?}, {?})', XDB::insertId(),
"$red+bounces@listes.polytechnique.org");
pl_redirect('lists/admin/'.$liste);
{
global $globals;
+ if (!$globals->asso('mail_domain')) {
+ return PL_NOT_FOUND;
+ }
$this->prepare_client($page);
$page->changeTpl('xnetlists/sync.tpl');
list(,$members) = $this->client->get_members($liste);
$mails = array_map(create_function('$arr', 'return $arr[1];'), $members);
- $subscribers = array_unique(array_merge($subscribers, $mails));
+ $subscribers = array_unique($mails);
$not_in_group_x = array();
$not_in_group_ext = array();
$ann = XDB::iterator(
"SELECT if (m.origine='X',if (u.nom_usage<>'', u.nom_usage, u.nom) ,m.nom) AS nom,
if (m.origine='X',u.prenom,m.prenom) AS prenom,
- if (m.origine='X',u.promo,'extérieur') AS promo,
+ if (m.origine='X',u.promo,'extérieur') AS promo,
if (m.origine='X',CONCAT(a.alias, '@polytechnique.org'),m.email) AS email,
if (m.origine='X',FIND_IN_SET('femme', u.flags),0) AS femme,
m.perms='admin' AS admin,
FROM groupex.membres AS m
LEFT JOIN auth_user_md5 AS u ON ( u.user_id = m.uid )
LEFT JOIN aliases AS a ON ( a.id = m.uid AND a.type='a_vie' )
- WHERE m.asso_id = {?}", $globals->asso('id'));
+ WHERE m.asso_id = {?}
+ ORDER BY promo, nom, prenom", $globals->asso('id'));
$not_in_list = array();
while ($tmp = $ann->next()) {
- if (!in_array($tmp['email'], $subscribers)) {
+ if (!in_array(strtolower($tmp['email']), $subscribers)) {
$not_in_list[] = $tmp;
}
}
function handler_aadmin(&$page, $lfull = null)
{
- if (is_null($lfull)) {
+ global $globals;
+
+ if (!$globals->asso('mail_domain') || is_null($lfull)) {
return PL_NOT_FOUND;
}
- new_groupadmin_page('xnet/groupe/alias-admin.tpl');
+ new_groupadmin_page('xnetlists/alias-admin.tpl');
if (Env::has('add_member')) {
$add = Env::v('add_member');
SELECT vid, {?}
FROM x4dat.virtual
WHERE alias={?}", "$alias@m4x.org", $lfull);
- $page->trig("$alias@m4x.org ajouté");
+ $page->trig("$alias@m4x.org ajouté");
} else {
$page->trig("$mbox@polytechnique.org n'existe pas.");
}
SELECT vid,{?}
FROM x4dat.virtual
WHERE alias={?}", "$mbox@$dom", $lfull);
- $page->trig("$mbox@$dom ajouté");
+ $page->trig("$mbox@$dom ajouté");
}
}
pl_redirect('alias/admin/'.$lfull);
}
+ global $globals;
$res = XDB::iterator(
- "SELECT redirect
+ "SELECT redirect,
+ IF(u.nom IS NOT NULL, IF(u.nom_usage<>'', u.nom_usage, u.nom), m.nom) AS nom,
+ IF(u.prenom IS NOT NULL, u.prenom, m.prenom) AS prenom,
+ IF(u.promo IS NOT NULL, u.promo, 'extérieur') AS promo,
+ IF(m2.perms, m2.perms = 'admin', m.perms = 'admin') AS admin,
+ a.alias
FROM x4dat.virtual_redirect AS vr
INNER JOIN x4dat.virtual AS v USING(vid)
+ LEFT JOIN x4dat.aliases AS a ON(vr.redirect = CONCAT(a.alias, CONCAT('@', {?}))
+ OR vr.redirect = CONCAT(a.alias, CONCAT('@', {?})))
+ LEFT JOIN x4dat.auth_user_md5 AS u ON(a.id = u.user_id)
+ LEFT JOIN groupex.membres AS m2 ON(u.user_id = m2.uid AND m2.asso_id = {?})
+ LEFT JOIN groupex.membres AS m ON(m.email = vr.redirect AND m.asso_id = {?})
WHERE v.alias={?}
- ORDER BY redirect", $lfull);
+ ORDER BY redirect",
+ $globals->mail->domain, $globals->mail->domain2,
+ $globals->asso('id'), $globals->asso('id'), $lfull);
$page->assign('mem', $res);
}
{
global $globals;
- new_groupadmin_page('xnet/groupe/alias-create.tpl');
+ if (!$globals->asso('mail_domain')) {
+ return PL_NOT_FOUND;
+ }
+ new_groupadmin_page('xnetlists/alias-create.tpl');
if (!Post::has('submit')) {
return;
}
if (!Post::has('liste')) {
- $page->trig('champs «addresse souhaitée» vide');
+ $page->trig('champs «addresse souhaitée» vide');
return;
}
$liste = Post::v('liste');
$res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
$n = $res->fetchOneCell();
if ($n) {
- $page->trig('cet alias est déjà pris');
+ $page->trig('cet alias est déjà pris');
return;
}
}
}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>