X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fnewsletter.php;h=230265e1afebc3e74fdcaf2e3ecff9d041448139;hb=ad47a0aa4c6a13b4e4d051f7159641204707d11c;hp=809caef00b1ddb042793d548efe9707a548e0c2b;hpb=e93255ef54304c697ef7ac101247f23dc5f7b31f;p=platal.git diff --git a/modules/newsletter.php b/modules/newsletter.php index 809caef..230265e 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -1,6 +1,6 @@ $this->make_hook('admin_nl_cat', AUTH_PASSWD, 'admin'), 'admin/newsletter/edit' => $this->make_hook('admin_nl_edit', AUTH_PASSWD, 'admin'), 'admin/newsletter/edit/delete' => $this->make_hook('admin_nl_delete', AUTH_PASSWD, 'admin'), + 'stat/newsletter' => $this->make_hook('stat_nl', AUTH_PASSWD, 'admin') // Automatic mailing is disabled for X.org NL // 'admin/newsletter/edit/cancel' => $this->make_hook('cancel', AUTH_PASSWD, 'admin'), // 'admin/newsletter/edit/valid' => $this->make_hook('valid', AUTH_PASSWD, 'admin'), @@ -224,7 +225,6 @@ class NewsletterModule extends PLModule 'id' => 'Id', 'group_name' => 'Groupe', 'name' => 'Titre', - 'custom_css' => 'CSS spécifique', 'criteria' => 'Critères actifs' ); static $next_orders = array( @@ -420,6 +420,11 @@ class NewsletterModule extends PLModule if (!$issue) { $page->kill("La lettre {$nid} n'existe pas."); } + + if ($issue->isEmpty()) { + $page->trigErrorRedirect("La lettre étant vide, il n'est pas possible de l'envoyer.", $nl->adminPrefix()); + } + if (!$issue->scheduleMailing()) { $page->trigErrorRedirect("Une erreur est survenue lors de la validation de l'envoi.", $nl->adminPrefix()); } @@ -491,7 +496,53 @@ class NewsletterModule extends PLModule $table_editor->on_delete(null, null); $table_editor->apply($page, $action, $id); } + + function handler_stat_nl($page) + { + $nl = $this->getNl(); + if (!$nl) { + return PL_NOT_FOUND; + } + if (!$nl->mayEdit()) { + return PL_FORBIDDEN; + } + + $page->setTitle('Statistiques - Newsletter'); + $page->changeTpl('newsletter/statistics.tpl'); + + $data = array(); + foreach (Profile::$cycles as $grade => $name) { + $data[$name] = array(); + list($min, $max) = Profile::extremePromotions($grade); + $bound = (((int)($min / 10)) + 1) * 10; + while ($bound <= $max) { + $data[$name][$min . ' - ' . $bound] = array( + 'count' => $nl->subscriberCount(null, null, $grade, $min, $bound), + 'lost' => $nl->subscriberCount(true, null, $grade, $min, $bound), + 'count_female' => $nl->subscriberCount(null, User::GENDER_FEMALE, $grade, $min, $bound), + 'lost_female' => $nl->subscriberCount(true, User::GENDER_FEMALE, $grade, $min, $bound) + ); + $min = $bound + 1; + $bound += 10; + } + $bound -= 9; + if ($bound <= $max) { + $data[$name][$bound . ' - ' . $max] = array( + 'count' => $nl->subscriberCount(null, null, $grade, $bound, $max), + 'lost' => $nl->subscriberCount(true, null, $grade, $bound, $max), + 'count_female' => $nl->subscriberCount(null, User::GENDER_FEMALE, $grade, $bound, $max), + 'lost_female' => $nl->subscriberCount(true, User::GENDER_FEMALE, $grade, $bound, $max) + ); + } + } + $page->assign_by_ref('nl', $nl); + $page->assign('count', $nl->subscriberCount()); + $page->assign('lost', $nl->lostSubscriberCount()); + $page->assign('count_female', $nl->subscriberCount(null, User::GENDER_FEMALE)); + $page->assign('lost_female', $nl->lostSubscriberCount(User::GENDER_FEMALE)); + $page->assign('data', $data); + } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>