From 9fdacf8d3f30d59d44a8988449db6aae6e4aae21 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 15 Jul 2006 13:19:15 +0000 Subject: [PATCH] migrate xnet list index. migrate xnet list sync module also remove 'trombi' trigger for xnet git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@493 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs.net/groupe/listes-sync.php | 51 -------------------- htdocs.net/groupe/listes.php | 55 ---------------------- modules/xnetlists.php | 88 ++++++++++++++++++++++++++++++++++- templates/skin/common.bandeau.tpl | 2 +- templates/xnet/groupe/listes-sync.tpl | 4 +- templates/xnet/groupe/listes.tpl | 12 ++--- 6 files changed, 96 insertions(+), 116 deletions(-) delete mode 100644 htdocs.net/groupe/listes-sync.php delete mode 100644 htdocs.net/groupe/listes.php diff --git a/htdocs.net/groupe/listes-sync.php b/htdocs.net/groupe/listes-sync.php deleted file mode 100644 index 9c97ed7..0000000 --- a/htdocs.net/groupe/listes-sync.php +++ /dev/null @@ -1,51 +0,0 @@ -asso('mail_domain')); - -if (Env::has('add')) { - $client->mass_subscribe($liste, array_keys(Env::getMixed('add'))); -} - -list(,$members) = $client->get_members($liste); -$mails = array_map(create_function('$arr', 'return $arr[1];'), $members); -$subscribers = array_unique(array_merge($subscribers, $mails)); - -$not_in_group_x = array(); -$not_in_group_ext = array(); - -$ann = $globals->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',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, - m.origine='X' AS x - 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')); - -$not_in_list = array(); - -while ($tmp = $ann->next()) { - if (!in_array($tmp['email'], $subscribers)) { - $not_in_list[] = $tmp; - } -} - -$page->assign('not_in_list', $not_in_list); -$page->run(); - -?> diff --git a/htdocs.net/groupe/listes.php b/htdocs.net/groupe/listes.php deleted file mode 100644 index 9c61c83..0000000 --- a/htdocs.net/groupe/listes.php +++ /dev/null @@ -1,55 +0,0 @@ -asso('mail_domain')); - - -if(Get::has('del')) { - $client->unsubscribe(Get::get('del')); - redirect('listes.php'); -} -if(Get::has('add')) { - $client->subscribe(Get::get('add')); - redirect('listes.php'); -} -if(Post::has('promo_add')) { - $promo = Post::getInt('promo_add'); - if ($promo>=1900 and $promo<2100) { - $client->subscribe("promo$promo"); - } else { - $page->trig("promo incorrecte, il faut une promo sur 4 chiffres."); - } -} - - -if (Post::has('del_alias') && may_update()) { - $alias = Post::get('del_alias'); - // prevent group admin from erasing aliases from other groups - $alias = substr($alias, 0, strpos($alias, '@')).'@'.$globals->asso('mail_domain'); - $globals->xdb->query( - 'DELETE FROM x4dat.virtual_redirect, x4dat.virtual - USING x4dat.virtual AS v - LEFT JOIN x4dat.virtual_redirect USING(vid) - WHERE v.alias={?}', $alias); - $page->trig(Post::get('del_alias')." supprimé !"); -} - -$listes = $client->get_lists(); -$page->assign('listes',$listes); - -$alias = $globals->xdb->iterator( - 'SELECT alias,type - FROM x4dat.virtual - WHERE alias - LIKE {?} AND type="user" - ORDER BY alias', '%@'.$globals->asso('mail_domain')); -$page->assign('alias', $alias); - -$page->assign('may_update', may_update()); - -$page->run(); -?> diff --git a/modules/xnetlists.php b/modules/xnetlists.php index 08a0aee..a539774 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -32,7 +32,6 @@ class XnetListsModule extends ListsModule '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), @@ -42,6 +41,7 @@ class XnetListsModule extends ListsModule 'grp/lists/soptions' => $this->make_hook('soptions', AUTH_MDP), 'grp/lists/check' => $this->make_hook('check', AUTH_MDP), + 'grp/lists/sync' => $this->make_hook('sync', AUTH_MDP), /* hack: lists uses that */ 'profile' => $this->make_hook('profile', AUTH_PUBLIC), @@ -63,6 +63,92 @@ class XnetListsModule extends ListsModule $page->setType($globals->asso('cat')); } + function handler_lists(&$page) + { + global $globals; + + $this->prepare_client($page); + + $page->changeTpl('xnet/groupe/listes.tpl'); + + if (Get::has('del')) { + $this->client->unsubscribe(Get::get('del')); + redirect('lists'); + } + if (Get::has('add')) { + $this->client->subscribe(Get::get('add')); + redirect('lists'); + } + + if (Post::has('del_alias') && may_update()) { + $alias = Post::get('del_alias'); + // prevent group admin from erasing aliases from other groups + $alias = substr($alias, 0, strpos($alias, '@')).'@'.$globals->asso('mail_domain'); + $globals->xdb->query( + 'DELETE FROM x4dat.virtual_redirect, x4dat.virtual + USING x4dat.virtual AS v + LEFT JOIN x4dat.virtual_redirect USING(vid) + WHERE v.alias={?}', $alias); + $page->trig(Post::get('del_alias')." supprimé !"); + } + + $listes = $this->client->get_lists(); + $page->assign('listes',$listes); + + $alias = $globals->xdb->iterator( + 'SELECT alias,type + FROM x4dat.virtual + WHERE alias + LIKE {?} AND type="user" + ORDER BY alias', '%@'.$globals->asso('mail_domain')); + $page->assign('alias', $alias); + + $page->assign('may_update', may_update()); + } + + function handler_sync(&$page, $liste = null) + { + global $globals; + + $this->prepare_client($page); + + $page->changeTpl('xnet/groupe/listes-sync.tpl'); + + if (Env::has('add')) { + $this->client->mass_subscribe($liste, array_keys(Env::getMixed('add'))); + } + + list(,$members) = $this->client->get_members($liste); + $mails = array_map(create_function('$arr', 'return $arr[1];'), $members); + $subscribers = array_unique(array_merge($subscribers, $mails)); + + $not_in_group_x = array(); + $not_in_group_ext = array(); + + $ann = $globals->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',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, + m.origine='X' AS x + 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')); + + $not_in_list = array(); + + while ($tmp = $ann->next()) { + if (!in_array($tmp['email'], $subscribers)) { + $not_in_list[] = $tmp; + } + } + + $page->assign('not_in_list', $not_in_list); + } + function handler_profile(&$page, $user = null) { redirect('https://www.polytechnique.org/profile/'.$user); diff --git a/templates/skin/common.bandeau.tpl b/templates/skin/common.bandeau.tpl index 2269bb5..165460a 100644 --- a/templates/skin/common.bandeau.tpl +++ b/templates/skin/common.bandeau.tpl @@ -26,7 +26,7 @@
-
  L'École · Institutional site  ~~  FX · AX  ~~  Polytechnique.org · Associations polytechniciennes · Élèves · Manageurs
+
  L'École · Institutional site  ~~  FX · AX  ~~  Polytechnique.org · Associations polytechniciennes · Élèves · Manageurs
diff --git a/templates/xnet/groupe/listes-sync.tpl b/templates/xnet/groupe/listes-sync.tpl index 17e69ce..8244a22 100644 --- a/templates/xnet/groupe/listes-sync.tpl +++ b/templates/xnet/groupe/listes-sync.tpl @@ -21,9 +21,9 @@ {**************************************************************************} {include file='listes/header_listes.tpl' on='sync'} -

Non abonnés à la liste {$smarty.request.liste}@{$asso.mail_domain}

+

Non abonnés à la liste {$platal->argv[1]}@{$asso.mail_domain}

-
+ diff --git a/templates/xnet/groupe/listes.tpl b/templates/xnet/groupe/listes.tpl index 91fdfac..e4c6870 100644 --- a/templates/xnet/groupe/listes.tpl +++ b/templates/xnet/groupe/listes.tpl @@ -23,13 +23,13 @@ {if $smarty.get.del_alias}

Est tu sur de supprimer l'alias {$smarty.get.del_alias} ?

- +
-

[retour à la page des listes]

+

[retour à la page des listes]

{else} @@ -62,7 +62,7 @@ croix verte te permet de t'inscrire, apr @@ -103,7 +103,7 @@ t'emp {if $may_update} - + {else} {/if} -- 2.1.4
[mail] - {$l.list} {if $l.priv}#{/if}{if $l.own}o{/if} + {$l.list} {if $l.priv}#{/if}{if $l.own}o{/if} {$l.desc} @@ -72,11 +72,11 @@ croix verte te permet de t'inscrire, apr {$l.nbsub} {if $l.sub eq 2} - [désinscrire] + [désinscrire] {elseif $l.sub eq 1} [en attente] {else} - [m'inscrire] + [m'inscrire] {/if}
[mail] {$a.alias}[supprimer][supprimer][mail] {$a.alias}