From bf26b31794e7d9d0043c5df7c3c681ecd9badf5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Sat, 14 May 2011 00:16:55 +0200 Subject: [PATCH] Adds group nl subscription from group profile edition (Closes #1481). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- ChangeLog | 3 +++ modules/xnetgrp.php | 23 +++++++++++++++++++++++ templates/xnetgrp/membres-edit.tpl | 12 ++++++++++++ 3 files changed, 38 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9d0251e..059ad36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ Bug/Wish: * Search: - #1285: Autocompletes on internal words in university search -JAC + * XnetGrp: + - #1481: Adds group nl subscription from group profile edition -JAC + ================================================================================ VERSION 1.1.1 09 05 2011 diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index de4f48c..29daade 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -1234,16 +1234,39 @@ class XnetGrpModule extends PLModule $page->trigSuccess("{$user->fullName()} a été désabonné de $ml."); } } + + if ($globals->asso('has_nl')) { + // Updates group's newsletter subscription. + if (Post::i('newsletter') == 1) { + XDB::execute('INSERT IGNORE INTO newsletter_ins (uid, nlid) + SELECT {?}, id + FROM newsletters + WHERE group_id = {?}', + $user->id(), $globals->asso('id')); + } else { + XDB::execute('DELETE ni + FROM newsletter_ins AS ni + INNER JOIN newsletters AS n ON (n.id = ni.nlid) + WHERE ni.uid = {?} AND n.group_id = {?}', + $user->id(), $globals->asso('id')); + } + } } $res = XDB::rawFetchAllAssoc('SHOW COLUMNS FROM group_members LIKE \'position\''); $positions = str_replace(array('enum(', ')', '\''), '', $res[0]['Type']); + $nl_registered = XDB::fetchOneCell('SELECT COUNT(ni.uid) + FROM newsletter_ins AS ni + INNER JOIN newsletters AS n ON (n.id = ni.nlid) + WHERE ni.uid = {?} AND n.group_id = {?}', + $user->id(), $globals->asso('id')); $page->assign('user', $user); $page->assign('suggest', $this->suggest($user)); $page->assign('listes', $mmlist->get_lists($user->forlifeEmail())); $page->assign('alias', $user->emailGroupAliases($globals->asso('mail_domain'))); $page->assign('positions', explode(',', $positions)); + $page->assign('nl_registered', $nl_registered); } function handler_rss(PlPage $page, PlUser $user) diff --git a/templates/xnetgrp/membres-edit.tpl b/templates/xnetgrp/membres-edit.tpl index f616a56..24edb37 100644 --- a/templates/xnetgrp/membres-edit.tpl +++ b/templates/xnetgrp/membres-edit.tpl @@ -161,6 +161,18 @@ Poste, origine… (accessible à toutes les personnes autorisées à consulter l'annuaire) + {if $asso->has_nl} + + + Newsletter : + + + +  -  + + + + {/if} {if $user->type eq 'xnet'} -- 2.1.4