From 41c0150b1cdb3a69a931727b0be0276777b009bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 29 Apr 2009 23:38:43 +0200 Subject: [PATCH] Only proposes to synchronise the group and its MLs when there is at least one ML in the group. --- classes/platalglobals.php.in | 10 ++++++---- modules/xnetlists.php | 15 ++++++++++++++- templates/xnetgrp/annuaire.tpl | 2 ++ upgrade/0.10.1/01_groupex.sql | 3 +++ 4 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 upgrade/0.10.1/01_groupex.sql diff --git a/classes/platalglobals.php.in b/classes/platalglobals.php.in index cc95b1b..94803e8 100644 --- a/classes/platalglobals.php.in +++ b/classes/platalglobals.php.in @@ -60,12 +60,14 @@ class PlatalGlobals extends PlGlobals } if ($gp) { - $res = XDB::query('SELECT a.*, d.nom AS domnom, - FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc, - FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub + $res = XDB::query("SELECT a.*, d.nom AS domnom, + FIND_IN_SET('wiki_desc', a.flags) AS wiki_desc, + FIND_IN_SET('notif_unsub', a.flags) AS notif_unsub, + FIND_IN_SET('has_ml', a.flags) AS has_ml FROM groupex.asso AS a LEFT JOIN groupex.dom AS d ON d.id = a.dom - WHERE diminutif = {?}', $gp); + WHERE diminutif = {?}", + $gp); if (!($aid = $res->fetchOneAssoc())) { $aid = array(); } diff --git a/modules/xnetlists.php b/modules/xnetlists.php index 9bd47f5..036452e 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -104,7 +104,7 @@ class XnetListsModule extends ListsModule } $listes = $this->client->get_lists(); - $page->assign('listes',$listes); + $page->assign('listes', $listes); $alias = XDB::iterator( 'SELECT alias,type @@ -115,6 +115,13 @@ class XnetListsModule extends ListsModule $page->assign('alias', $alias); $page->assign('may_update', may_update()); + + if (count($listes) > 0 && !$globals->asso('has_ml')) { + XDB::execute("UPDATE groupex.asso + SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml') + WHERE id = {?}", + $globals->asso('id')); + } } function handler_create(&$page) @@ -181,6 +188,12 @@ class XnetListsModule extends ListsModule VALUES ({?}, {?})', XDB::insertId(), $red . $mdir . '@listes.polytechnique.org'); } + + XDB::execute("UPDATE groupex.asso + SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml') + WHERE id = {?}", + $globals->asso('id')); + pl_redirect('lists/admin/'.$liste); } diff --git a/templates/xnetgrp/annuaire.tpl b/templates/xnetgrp/annuaire.tpl index d462aa5..94e8a22 100644 --- a/templates/xnetgrp/annuaire.tpl +++ b/templates/xnetgrp/annuaire.tpl @@ -34,6 +34,7 @@ Le groupe {$asso.nom} compte {$nb_tot} membres : Ajouter un membre + {if $asso.has_ml}
  • {icon name=wand title="Synchroniser"} @@ -41,6 +42,7 @@ Le groupe {$asso.nom} compte {$nb_tot} membres :
  • {/if} + {/if}
  • {icon name=page_excel title="Fichier Excel"} diff --git a/upgrade/0.10.1/01_groupex.sql b/upgrade/0.10.1/01_groupex.sql new file mode 100644 index 0000000..e52291e --- /dev/null +++ b/upgrade/0.10.1/01_groupex.sql @@ -0,0 +1,3 @@ +ALTER TABLE groupex.asso CHANGE COLUMN flags flags SET('wiki_desc', 'notif_unsub', 'has_ml') NOT NULL; + +-- vim:set syntax=mysql: -- 2.1.4