From 359f9ca3126ce7a3d16836bbe5c37329ba211b05 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 15 Jun 2008 19:14:28 +0200 Subject: [PATCH] Group managers can choose between receiving notifications or not (default is not). Signed-off-by: Florent Bruneau --- include/globals.inc.php.in | 4 +++- modules/xnetgrp.php | 44 ++++++++++++++++++++++++------------------- templates/xnetgrp/edit.tpl | 6 ++++++ upgrade/0.9.17/03_xnetgrp.sql | 7 +++++++ 4 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 upgrade/0.9.17/03_xnetgrp.sql diff --git a/include/globals.inc.php.in b/include/globals.inc.php.in index c5148e4..f052c6b 100644 --- a/include/globals.inc.php.in +++ b/include/globals.inc.php.in @@ -208,7 +208,9 @@ class PlatalGlobals } if ($gp) { - $res = XDB::query('SELECT a.*, d.nom AS domnom, FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc + $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 FROM groupex.asso AS a LEFT JOIN groupex.dom AS d ON d.id = a.dom WHERE diminutif = {?}', $gp); diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index c6cc7e0..fecd5e2 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -224,6 +224,10 @@ class XnetGrpModule extends PLModule if (Post::has('submit')) { S::assert_xsrf_token(); + $flags = new FlagSet('wiki_desc'); + if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) { + $flags->addFlag('notif_unsub'); + } if (S::has_perms()) { if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) { $page->trigError("le domaine doit être un FQDN (aucune modif effectuée) !!!"); @@ -235,7 +239,7 @@ class XnetGrpModule extends PLModule descr={?}, site={?}, mail={?}, resp={?}, forum={?}, mail_domain={?}, ax={?}, pub={?}, sub_url={?}, inscriptible={?}, unsub_url={?}, - flags='wiki_desc' + flags={?} WHERE id={?}", Post::v('nom'), Post::v('diminutif'), Post::v('cat'), Post::i('dom'), @@ -244,7 +248,7 @@ class XnetGrpModule extends PLModule Post::v('forum'), Post::v('mail_domain'), Post::has('ax'), Post::v('pub'), Post::v('sub_url'), Post::v('inscriptible'), - Post::v('unsub_url'),$globals->asso('id')); + Post::v('unsub_url'), $flags->flags(), $globals->asso('id')); if (Post::v('mail_domain')) { XDB::execute('INSERT INTO virtual_domains (domain) VALUES({?})', Post::v('mail_domain')); @@ -254,14 +258,14 @@ class XnetGrpModule extends PLModule "UPDATE groupex.asso SET descr={?}, site={?}, mail={?}, resp={?}, forum={?}, ax={?}, pub= {?}, sub_url={?}, - unsub_url={?},flags='wiki_desc' + unsub_url={?},flags={?} WHERE id={?}", Post::v('descr'), Post::v('site'), Post::v('mail'), Post::v('resp'), Post::v('forum'), Post::has('ax'), Post::v('pub'), Post::v('sub_url'), Post::v('unsub_url'), - $globals->asso('id')); + $flags->flags(), $globals->asso('id')); } if ($_FILES['logo']['name']) { @@ -771,22 +775,24 @@ class XnetGrpModule extends PLModule "DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}", $user['uid'], $globals->asso('id')); - $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl'); - $res = XDB::iterRow("SELECT a.alias, u.prenom, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom - FROM groupex.membres AS m - INNER JOIN aliases AS a ON (m.uid = a.id AND FIND_IN_SET('bestalias', a.flags)) - INNER JOIn auth_user_md5 AS u ON (u.user_id = a.id) - WHERE m.asso_id = {?} AND m.perms = 'admin'", - $globals->asso('id')); - while (list($alias, $prenom, $nom) = $res->next()) { - $mailer->addTo("\"$prenom $nom\" <$alias@{$globals->mail->domain}>"); + if ($globals->asso('notif_unsub')) { + $mailer = new PlMailer('xnetgrp/unsubscription-notif.mail.tpl'); + $res = XDB::iterRow("SELECT a.alias, u.prenom, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom + FROM groupex.membres AS m + INNER JOIN aliases AS a ON (m.uid = a.id AND FIND_IN_SET('bestalias', a.flags)) + INNER JOIn auth_user_md5 AS u ON (u.user_id = a.id) + WHERE m.asso_id = {?} AND m.perms = 'admin'", + $globals->asso('id')); + while (list($alias, $prenom, $nom) = $res->next()) { + $mailer->addTo("\"$prenom $nom\" <$alias@{$globals->mail->domain}>"); + } + $mailer->assign('group', $globals->asso('nom')); + $mailer->assign('prenom', $user['prenom']); + $mailer->assign('nom', $user['nom']); + $mailer->assign('mail', $user['email2']); + $mailer->assign('selfdone', $user['uid'] == S::i('uid')); + $mailer->send(); } - $mailer->assign('group', $globals->asso('nom')); - $mailer->assign('prenom', $user['prenom']); - $mailer->assign('nom', $user['nom']); - $mailer->assign('mail', $user['email2']); - $mailer->assign('selfdone', $user['uid'] == S::i('uid')); - $mailer->send(); $user_same_email = get_infos($user['email']); $domain = $globals->asso('mail_domain'); diff --git a/templates/xnetgrp/edit.tpl b/templates/xnetgrp/edit.tpl index fb9a389..a90313a 100644 --- a/templates/xnetgrp/edit.tpl +++ b/templates/xnetgrp/edit.tpl @@ -178,6 +178,12 @@ + + + + prévenir les animateurs lors de la désinscription d'un membre + +
diff --git a/upgrade/0.9.17/03_xnetgrp.sql b/upgrade/0.9.17/03_xnetgrp.sql new file mode 100644 index 0000000..7f25048 --- /dev/null +++ b/upgrade/0.9.17/03_xnetgrp.sql @@ -0,0 +1,7 @@ +use groupex; + +alter table asso change column flags flags set('wiki_desc', 'notif_unsub') not null; + +use x4dat; + +# vim:set syntax=mysql: -- 2.1.4