From: Stéphane Jacob Date: Mon, 9 May 2011 15:15:55 +0000 (+0200) Subject: Enables NLs filling from group members. X-Git-Tag: xorg/1.1.1~4 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=be166df99d1a0ce588c2097b043cbcdb18beb967;p=platal.git Enables NLs filling from group members. Signed-off-by: Stéphane Jacob --- diff --git a/ChangeLog b/ChangeLog index b7e1777..7d0da62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,7 @@ Bug/Wish: - #1470: Fixes autocomplete on countries -JAC * XnetGrp: + - Enables NLs filling from group members -JAC - #1179: Adds alphabetic choices for group directories -XEL - #1460: Enables NLs creation for groups -XEL - #1473: Enables group filling from its MLs and aliases -JAC diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index b7e00ca..447c7b7 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -567,6 +567,18 @@ class NewsLetter return $this->custom_css; } + public function canSyncWithGroup() + { + switch ($this->group) { + case self::GROUP_XORG: + case self::GROUP_AX: + case self::GROUP_EP: + return false; + default: + return true; + } + } + // }}} } diff --git a/modules/xnetnl.php b/modules/xnetnl.php index e04c4d3..a6fb168 100644 --- a/modules/xnetnl.php +++ b/modules/xnetnl.php @@ -30,6 +30,7 @@ class XnetNlModule extends NewsletterModule '%grp/nl/show' => $this->make_hook('nl_show', AUTH_MDP), '%grp/nl/search' => $this->make_hook('nl_search', AUTH_MDP), '%grp/admin/nl' => $this->make_hook('admin_nl', AUTH_MDP, 'groupadmin'), + '%grp/admin/nl/sync' => $this->make_hook('admin_nl_sync', AUTH_MDP, 'groupadmin'), '%grp/admin/nl/enable' => $this->make_hook('admin_nl_enable', AUTH_MDP, 'groupadmin'), '%grp/admin/nl/edit' => $this->make_hook('admin_nl_edit', AUTH_MDP, 'groupadmin'), '%grp/admin/nl/edit/cancel' => $this->make_hook('admin_nl_cancel', AUTH_MDP, 'groupadmin'), @@ -45,6 +46,43 @@ class XnetNlModule extends NewsletterModule return NewsLetter::forGroup($group); } + public function handler_admin_nl_sync($page) + { + global $globals; + $nl = $this->getNl(); + if (!$nl) { + return PL_FORBIDDEN; + } + + if (Env::has('add_users')) { + S::assert_xsrf_token(); + + XDB::execute('INSERT IGNORE INTO newsletter_ins (uid, nlid) + SELECT g.uid, n.id + FROM group_members AS g + INNER JOIN newsletters AS n ON (n.group_id = g.asso_id) + WHERE g.uid IN {?} AND g.asso_id = {?}', + array_keys(Env::v('add_users')), $globals->asso('id')); + + $page->trigSuccess('Ajouts réalisés avec succès.'); + } + + $uids = XDB::fetchColumn('SELECT DISTINCT(g.uid) + FROM group_members AS g + WHERE g.asso_id = {?} AND NOT EXISTS (SELECT ni.* + FROM newsletter_ins AS ni + INNER JOIN newsletters AS n ON (ni.nlid = n.id) + WHERE g.uid = ni.uid AND n.group_id = g.asso_id)', + $globals->asso('id')); + + $users = User::getBulkUsersWithUIDs($uids); + usort($users, 'User::compareDirectoryName'); + + $page->setTitle('Synchronisation de la newsletter'); + $page->changeTpl('newsletter/sync.tpl'); + $page->assign('users', $users); + } + public function handler_admin_nl_enable($page) { global $globals; diff --git a/templates/newsletter/admin.tpl b/templates/newsletter/admin.tpl index 2f724ab..a5d2c03 100644 --- a/templates/newsletter/admin.tpl +++ b/templates/newsletter/admin.tpl @@ -29,6 +29,12 @@ Gérer les catégories d'articles +{if $nl->canSyncWithGroup()} +

+ Synchroniser avec les membres du groupe +

+{/if} +
Date