X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fxnetnl.php;h=e04c4d3395a5831cd37410c8f1c0375ca09838cc;hb=738b4620af26b943d2fa3bfe72a0f4e53ab2a789;hp=1979087482334380e07b1b32fce285d0863081d3;hpb=5ae3e9a9b7e095956904a2bedbc0845af88434f0;p=platal.git diff --git a/modules/xnetnl.php b/modules/xnetnl.php index 1979087..e04c4d3 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/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'), '%grp/admin/nl/edit/valid' => $this->make_hook('admin_nl_valid', AUTH_MDP, 'groupadmin'), @@ -43,6 +44,36 @@ class XnetNlModule extends NewsletterModule $group = $globals->asso('shortname'); return NewsLetter::forGroup($group); } + + public function handler_admin_nl_enable($page) + { + global $globals; + $nl = $this->getNl(); + if ($nl) { + return PL_FORBIDDEN; + } + + if (Post::has('title')) { + if (!S::has_xsrf_token()) { + return PL_FORBIDDEN; + } + + XDB::execute('INSERT INTO newsletters + SET group_id = {?}, name = {?}', + $globals->asso('id'), Post::s('title')); + + $mailer = new PlMailer(); + $mailer->assign('group', $globals->asso('nom')); + $mailer->assign('user', S::user()); + $mailer->send(); + + $page->trigSuccessRedirect("La lettre d'informations du groupe " . + $globals->asso('nom') . " a bien été créée", + $globals->asso('shortname') . '/admin/nl'); + } + $page->setTitle('Activation de la newsletter'); + $page->changeTpl('newsletter/enable.tpl'); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: