2 /***************************************************************************
3 * Copyright (C) 2003-2008 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class ListsModule
extends PLModule
29 'lists' => $this->make_hook('lists', AUTH_MDP
),
30 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP
, 'user', NO_AUTH
),
31 'lists/create' => $this->make_hook('create', AUTH_MDP
),
33 'lists/members' => $this->make_hook('members', AUTH_COOKIE
),
34 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE
),
35 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE
),
36 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC
, 'user', NO_HTTPS
),
38 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP
),
39 'lists/admin' => $this->make_hook('admin', AUTH_MDP
),
40 'lists/options' => $this->make_hook('options', AUTH_MDP
),
41 'lists/delete' => $this->make_hook('delete', AUTH_MDP
),
43 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP
),
44 'lists/check' => $this->make_hook('check', AUTH_MDP
),
45 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP
, 'admin'),
49 function prepare_client(&$page)
53 $this->load('lists.inc.php');
55 $this->client
= new MMList(S
::v('uid'), S
::v('password'));
56 return $globals->mail
->domain
;
59 function get_pending_ops($domain, $list)
61 list($subs,$mails) = $this->client
->get_pending_ops($list);
62 $res = XDB
::query("SELECT mid
64 WHERE ml = {?} AND domain = {?}",
66 $mids = $res->fetchColumn();
67 foreach ($mails as $key=>$mail) {
68 if (in_array($mail['id'], $mids)) {
72 return array($subs, $mails);
75 function handler_lists(&$page)
77 function filter_owner($list)
82 function filter_member($list)
87 $domain = $this->prepare_client($page);
89 $page->changeTpl('lists/index.tpl');
90 $page->addJsLink('ajax.js');
91 $page->setTitle('Listes de diffusion');
94 if (Get
::has('del')) {
95 S
::assert_xsrf_token();
96 $this->client
->unsubscribe(Get
::v('del'));
99 if (Get
::has('add')) {
100 S
::assert_xsrf_token();
101 $this->client
->subscribe(Get
::v('add'));
102 pl_redirect('lists');
104 if (Post
::has('promo_add')) {
105 S
::assert_xsrf_token();
107 $promo = Post
::i('promo_add');
108 if ($promo >= 1900 and $promo < 2100) {
109 $this->client
->subscribe("promo$promo");
111 $page->trigSuccess("promo incorrecte, il faut une promo sur 4 chiffres.");
115 $listes = $this->client
->get_lists();
116 $owner = array_filter($listes, 'filter_owner');
117 $listes = array_diff_key($listes, $owner);
118 $member = array_filter($listes, 'filter_member');
119 $listes = array_diff_key($listes, $member);
120 foreach ($owner as $key=>$liste) {
121 list($subs,$mails) = $this->get_pending_ops($domain, $liste['list']);
122 $owner[$key]['subscriptions'] = $subs;
123 $owner[$key]['mails'] = $mails;
125 $page->register_modifier('hdc', 'list_header_decode');
126 $page->assign_by_ref('owner', $owner);
127 $page->assign_by_ref('member', $member);
128 $page->assign_by_ref('public', $listes);
131 function handler_ajax(&$page, $list = null
)
133 header('Content-Type: text/html; charset="UTF-8"');
134 $domain = $this->prepare_client($page);
135 $page->changeTpl('lists/liste.inc.tpl', NO_SKIN
);
136 S
::assert_xsrf_token();
138 if (Get
::has('unsubscribe')) {
139 $this->client
->unsubscribe($list);
141 if (Get
::has('subscribe')) {
142 $this->client
->subscribe($list);
144 if (Get
::has('sadd')) { /* 4 = SUBSCRIBE */
145 $this->client
->handle_request($list, Get
::v('sadd'), 4, '');
147 if (Get
::has('mid')) {
148 $this->moderate_mail($domain, $list, Get
::i('mid'));
151 list($liste, $members, $owners) = $this->client
->get_members($list);
153 list($subs,$mails) = $this->get_pending_ops($domain, $list);
154 $liste['subscriptions'] = $subs;
155 $liste['mails'] = $mails;
157 $page->register_modifier('hdc', 'list_header_decode');
158 $page->assign_by_ref('liste', $liste);
161 function handler_create(&$page)
165 $page->changeTpl('lists/create.tpl');
167 $user_promo = S
::i('promo');
170 $young_promo = $very_young_promo = 0;
171 if ((($year > $user_promo) && ($month > 3)) && ($year < $user_promo +
5)) {
174 if ((($year > $user_promo) && ($month > 7)) && (($year < $user_promo +
1) && ($month < 8))) {
175 $very_young_promo = 1;
177 $page->assign('young_promo', $young_promo);
178 $page->assign('very_young_promo', $very_young_promo);
180 $owners = preg_split("/[\s]+/", Post
::v('owners'), -1, PREG_SPLIT_NO_EMPTY
);
181 $members = preg_split("/[\s]+/", Post
::v('members'), -1, PREG_SPLIT_NO_EMPTY
);
183 // click on validate button 'add_owner_sub' or type <enter>
184 if (Post
::has('add_owner_sub') && Post
::has('add_owner')) {
185 // if we want to add an owner and then type <enter>, then both
186 // add_owner_sub and add_owner are filled.
187 $oforlifes = User
::getBulkForlifeEmails(Post
::v('add_owner'), true
);
188 $mforlifes = User
::getBulkForlifeEmails(Post
::v('add_member'), true
);
189 if (!is_null($oforlifes)) {
190 $owners = array_merge($owners, $oforlifes);
192 // if we want to add a member and then type <enter>, then
193 // add_owner_sub is filled, whereas add_owner is empty.
194 if (!is_null($mforlifes)) {
195 $members = array_merge($members, $mforlifes);
199 // click on validate button 'add_member_sub'
200 if (Post
::has('add_member_sub') && Post
::has('add_member')) {
201 $forlifes = User
::getBulkForlifeEmails(Post
::v('add_member'), true
);
202 if (!is_null($forlifes)) {
203 $members = array_merge($members, $forlifes);
206 if (Post
::has('add_member_sub') && isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
207 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
209 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
211 $forlifes = User
::getBulkForlifeEmails($upload->getContents(), true
);
212 if (!is_null($forlifes)) {
213 $members = array_merge($members, $forlifes);
219 $owners = array_unique($owners);
221 $members = array_unique($members);
223 $page->assign('owners', join("\n", $owners));
224 $page->assign('members', join("\n", $members));
226 if (!Post
::has('submit')) {
229 S
::assert_xsrf_token();
232 $asso = Post
::v('asso');
233 $liste = Post
::v('liste');
236 $page->trigError('Le champ «adresse souhaitée» est vide.');
238 if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
239 $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.');
242 if (($asso == "binet") ||
($asso == "alias")) {
243 $promo = Post
::i('promo');
244 $domain = $promo . '.' . $globals->mail
->domain
;
246 if (($promo < 1921) ||
($promo > date('Y'))) {
247 $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
250 $new = $liste . '@' . $domain;
251 $res = XDB
::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
254 if ($asso == "groupex") {
255 $groupex_name = Post
::v('groupex_name');
257 $res_groupe = XDB
::query('SELECT mail_domain FROM groupex.asso WHERE nom={?}', $groupex_name);
258 $domain = $res_groupe->fetchOneCell();
261 $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.');
264 $new = $liste . '@' . $domain;
265 $res = XDB
::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
267 $res = XDB
::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
268 $domain = $globals->mail
->domain
;
272 $n = $res->fetchOneCell();
275 $page->trigError('L\'«adresse souhaitée» est déjà prise.');
278 if (!Post
::v('desc')) {
279 $page->trigError('Le sujet est vide.');
282 if (!count($owners)) {
283 $page->trigError('Il n\'y a pas de gestionnaire.');
286 if (count($members)<4) {
287 $page->trigError('Il n\'y a pas assez de membres.');
290 if (!$page->nb_errs()) {
291 $page->assign('created', true
);
292 require_once 'validations.inc.php';
293 $req = new ListeReq(S
::user(), $asso, $liste, $domain,
294 Post
::v('desc'), Post
::i('advertise'),
295 Post
::i('modlevel'), Post
::i('inslevel'),
301 function handler_members(&$page, $liste = null
)
303 if (is_null($liste)) {
307 $this->prepare_client($page);
309 $page->changeTpl('lists/members.tpl');
311 if (Get
::has('del')) {
312 S
::assert_xsrf_token();
313 $this->client
->unsubscribe($liste);
314 pl_redirect('lists/members/'.$liste);
317 if (Get
::has('add')) {
318 S
::assert_xsrf_token();
319 $this->client
->subscribe($liste);
320 pl_redirect('lists/members/'.$liste);
323 $members = $this->client
->get_members($liste);
325 $tri_promo = !Env
::b('alpha');
327 if (list($det,$mem,$own) = $members) {
328 $membres = list_sort_members($mem, $tri_promo);
329 $moderos = list_sort_owners($own, $tri_promo);
331 $page->assign_by_ref('details', $det);
332 $page->assign_by_ref('members', $membres);
333 $page->assign_by_ref('owners', $moderos);
334 $page->assign('nb_m', count($mem));
336 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
340 function handler_annu(&$page, $liste = null
, $action = null
, $subaction = null
)
342 if (is_null($liste)) {
346 $this->prepare_client($page);
348 if (Get
::has('del')) {
349 S
::assert_xsrf_token();
350 $this->client
->unsubscribe($liste);
351 pl_redirect('lists/annu/'.$liste);
353 if (Get
::has('add')) {
354 S
::assert_xsrf_token();
355 $this->client
->subscribe($liste);
356 pl_redirect('lists/annu/'.$liste);
359 $owners = $this->client
->get_owners($liste);
360 if (!is_array($owners)) {
361 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
365 list(,$members) = $this->client
->get_members($liste);
367 foreach ($members as $m) {
370 require_once 'userset.inc.php';
371 $view = new ArraySet($users);
372 $view->addMod('trombi', 'Trombinoscope', true
, array('with_promo' => true
));
373 if (empty($GLOBALS['IS_XNET_SITE'])) {
374 $view->addMod('minifiche', 'Mini-fiches', false
);
376 $view->addMod('geoloc', 'Planisphère');
377 $view->apply("lists/annu/$liste", $page, $action, $subaction);
378 if ($action == 'geoloc' && $subaction) {
382 $page->changeTpl('lists/annu.tpl');
383 $moderos = list_sort_owners($owners[1]);
384 $page->assign_by_ref('details', $owners[0]);
385 $page->assign_by_ref('owners', $moderos);
388 function handler_archives(&$page, $liste = null
, $action = null
, $artid = null
)
392 if (is_null($liste)) {
396 $domain = $this->prepare_client($page);
398 $page->changeTpl('lists/archives.tpl');
400 if (list($det) = $this->client
->get_members($liste)) {
401 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
402 && !$det['own'] && ($det['sub'] < 2)) {
403 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
405 $get = Array('listname' => $liste, 'domain' => $domain);
406 if (Post
::has('updateall')) {
407 $get['updateall'] = Post
::v('updateall');
409 require_once 'banana/ml.inc.php';
410 get_banana_params($get, null
, $action, $artid);
411 run_banana($page, 'MLBanana', $get);
413 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
417 function handler_rss(&$page, $liste = null
, $alias = null
, $hash = null
)
419 require_once('rss.inc.php');
420 $uid = init_rss(null
, $alias, $hash);
421 if (!$uid ||
!$liste) {
425 $res = XDB
::query("SELECT user_id AS uid, password, alias AS forlife
426 FROM auth_user_md5 AS u
427 INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie')
428 WHERE u.user_id = {?}", $uid);
429 $row = $res->fetchOneAssoc();
430 $_SESSION = array_merge($row, $_SESSION);
432 $domain = $this->prepare_client($page);
433 if (list($det) = $this->client
->get_members($liste)) {
434 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
435 && !$det['own'] && ($det['sub'] < 2)) {
438 require_once('banana/ml.inc.php');
439 $banana = new MLBanana(S
::user(), Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
445 function moderate_mail($domain, $liste, $mid)
447 if (Env
::has('mok')) {
449 } elseif (Env
::has('mno')) {
451 } elseif (Env
::has('mdel')) {
457 return XDB
::execute("INSERT IGNORE INTO ml_moderate
458 VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
459 $liste, $domain, $mid, S
::i('uid'), $action, Post
::v('reason'));
462 function handler_moderate(&$page, $liste = null
)
464 if (is_null($liste)) {
468 $domain = $this->prepare_client($page);
470 $page->changeTpl('lists/moderate.tpl');
472 $page->register_modifier('hdc', 'list_header_decode');
474 if (Env
::has('sadd') || Env
::has('sdel')) {
475 S
::assert_xsrf_token();
477 if (Env
::has('sadd')) { /* 4 = SUBSCRIBE */
478 $sub = $this->client
->get_pending_sub($liste, Env
::v('sadd'));
479 $this->client
->handle_request($liste,Env
::v('sadd'),4,'');
482 if (Post
::has('sdel')) { /* 2 = REJECT */
483 $sub = $this->client
->get_pending_sub($liste, Env
::v('sdel'));
484 $this->client
->handle_request($liste, Post
::v('sdel'), 2, utf8_decode(Post
::v('reason')));
488 $mailer = new PlMailer();
489 $mailer->setFrom("$liste-bounces@{$domain}");
490 $mailer->addTo("$liste-owner@{$domain}");
491 $mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
492 $mailer->setSubject("L'inscription de {$sub['name']} a été $info");
493 $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S
::v('prenom') . ' '
494 . S
::v('nom') . '(' . S
::v('promo') . ")\n";
495 if (trim(Post
::v('reason'))) {
496 $text .= "\nLa raison invoquée est :\n" . Post
::v('reason');
498 $mailer->setTxtBody(wordwrap($text, 72));
501 if (Env
::has('sadd')) {
502 pl_redirect('lists/moderate/'.$liste);
506 if (Post
::has('moderate_mails') && Post
::has('select_mails')) {
507 S
::assert_xsrf_token();
509 $mails = array_keys(Post
::v('select_mails'));
510 foreach($mails as $mail) {
511 $this->moderate_mail($domain, $liste, $mail);
513 } elseif (Env
::has('mid')) {
514 if (Get
::has('mid') && !Env
::has('mok') && !Env
::has('mdel')) {
515 $page->changeTpl('lists/moderate_mail.tpl');
516 require_once('banana/moderate.inc.php');
517 $params = array('listname' => $liste, 'domain' => $domain,
518 'artid' => Get
::i('mid'), 'part' => Get
::v('part'), 'action' => Get
::v('action'));
519 $params['client'] = $this->client
;
520 run_banana($page, 'ModerationBanana', $params);
522 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
523 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
524 $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
525 $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
526 $msg = str_replace("%(listname)s", $liste, $msg);
527 $page->assign('msg', $msg);
531 $mail = $this->moderate_mail($domain, $liste, Env
::i('mid'));
532 } elseif (Env
::has('sid')) {
533 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
534 foreach($subs as $user) {
535 if ($user['id'] == Env
::v('sid')) {
536 $page->changeTpl('lists/moderate_sub.tpl');
537 $page->assign('del_user', $user);
545 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
546 foreach ($mails as $key=>$mail) {
547 $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
548 if ($mail['fromx']) {
549 $page->assign('with_fromx', true
);
551 $page->assign('with_nonfromx', true
);
554 $page->assign_by_ref('subs', $subs);
555 $page->assign_by_ref('mails', $mails);
557 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer");
561 static public function no_login_callback($login)
563 require_once 'user.func.inc.php';
564 global $list_unregistered, $globals;
566 $users = get_not_registered_user($login, true
);
567 if ($users && $users->total()) {
568 if (!isset($list_unregistered)) {
569 $list_unregistered = array();
571 $list_unregistered[$login] = $users;
573 list($name, $dom) = @explode
('@', $login);
574 if ($dom == $globals->mail
->domain ||
$dom == $globals->mail
->domain2
) {
575 User
::_default_user_callback($login);
580 function handler_admin(&$page, $liste = null
)
584 if (is_null($liste)) {
588 $domain = $this->prepare_client($page);
590 $page->changeTpl('lists/admin.tpl');
592 if (Env
::has('send_mark')) {
593 S
::assert_xsrf_token();
595 $actions = Env
::v('mk_action');
596 $uids = Env
::v('mk_uid');
597 $mails = Env
::v('mk_email');
598 foreach ($actions as $key=>$action) {
603 case 'marketu': case 'markets':
604 require_once 'emails.inc.php';
605 $mail = valide_email($mails[$key]);
606 if (isvalid_email_redirection($mail)) {
607 $from = ($action == 'marketu') ?
'user' : 'staff';
608 $market = Marketing
::get($uids[$key], $mail);
610 $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S
::v('uid'));
617 XDB
::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain)
618 VALUES ({?}, \'list\', {?}, {?})',
619 $uids[$key], $liste, $domain);
624 if (Env
::has('add_member')) {
625 S
::assert_xsrf_token();
627 $members = User
::getBulkForlifeEmails(Env
::v('add_member'),
629 array('ListsModule', 'no_login_callback'));
630 $arr = $this->client
->mass_subscribe($liste, $members);
631 if (is_array($arr)) {
632 foreach($arr as $addr) {
633 $page->trigSuccess("{$addr[0]} inscrit.");
638 if (isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
639 S
::assert_xsrf_token();
641 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
643 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
645 $members = User
::getBulkForlifeEmails($upload->getContents(),
647 array('ListsModule', 'no_login_callback'));
648 $arr = $this->client
->mass_subscribe($liste, $members);
649 if (is_array($arr)) {
650 foreach($arr as $addr) {
651 $page->trigSuccess("{$addr[0]} inscrit.");
657 if (Env
::has('del_member')) {
658 S
::assert_xsrf_token();
660 if (strpos(Env
::v('del_member'), '@') === false
) {
661 $this->client
->mass_unsubscribe(
662 $liste, array(Env
::v('del_member').'@'.$globals->mail
->domain
));
664 $this->client
->mass_unsubscribe($liste, array(Env
::v('del_member')));
666 pl_redirect('lists/admin/'.$liste);
669 if (Env
::has('add_owner')) {
670 S
::assert_xsrf_token();
672 $owners = User
::getBulkForlifeEmails(Env
::v('add_owner'), false
, array('ListsModule', 'no_login_callback'));
674 foreach ($owners as $login) {
675 if ($this->client
->add_owner($liste, $login)) {
676 $page->trigSuccess($login ." ajouté aux modérateurs.");
682 if (Env
::has('del_owner')) {
683 S
::assert_xsrf_token();
685 if (strpos(Env
::v('del_owner'), '@') === false
) {
686 $this->client
->del_owner($liste, Env
::v('del_owner').'@'.$globals->mail
->domain
);
688 $this->client
->del_owner($liste, Env
::v('del_owner'));
690 pl_redirect('lists/admin/'.$liste);
693 if (list($det,$mem,$own) = $this->client
->get_members($liste)) {
694 global $list_unregistered;
695 if ($list_unregistered) {
696 $page->assign_by_ref('unregistered', $list_unregistered);
698 $membres = list_sort_members($mem, @$tri_promo);
699 $moderos = list_sort_owners($own, @$tri_promo);
701 $page->assign_by_ref('details', $det);
702 $page->assign_by_ref('members', $membres);
703 $page->assign_by_ref('owners', $moderos);
704 $page->assign('np_m', count($mem));
707 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.<br />"
708 ." Si tu penses qu'il s'agit d'une erreur, "
709 ."<a href='mailto:support@polytechnique.org'>contact le support</a>");
713 function handler_options(&$page, $liste = null
)
715 if (is_null($liste)) {
719 $this->prepare_client($page);
721 $page->changeTpl('lists/options.tpl');
723 if (Post
::has('submit')) {
724 S
::assert_xsrf_token();
727 $values = array_map('utf8_decode', $values);
728 $spamlevel = intval($values['bogo_level']);
729 $unsurelevel = intval($values['unsure_level']);
730 if ($spamlevel == 0) {
733 if ($spamlevel > 3 ||
$spamlevel < 0 ||
$unsurelevel < 0 ||
$unsurelevel > 1) {
734 $page->trigError("Réglage de l'antispam non valide");
736 $this->client
->set_bogo_level($liste, ($spamlevel << 1) +
$unsurelevel);
738 switch($values['moderate']) {
740 $values['generic_nonmember_action'] = 0;
741 $values['default_member_moderation'] = 0;
744 $values['generic_nonmember_action'] = 1;
745 $values['default_member_moderation'] = 0;
748 $values['generic_nonmember_action'] = 1;
749 $values['default_member_moderation'] = 1;
752 unset($values['submit'], $values['bogo_level'], $values['moderate']);
753 $values['send_goodbye_msg'] = !empty($values['send_goodbye_msg']);
754 $values['admin_notify_mchanges'] = !empty($values['admin_notify_mchanges']);
755 $values['subscribe_policy'] = empty($values['subscribe_policy']) ?
0 : 2;
756 if (isset($values['subject_prefix'])) {
757 $values['subject_prefix'] = trim($values['subject_prefix']).' ';
759 $this->client
->set_owner_options($liste, $values);
760 } elseif (isvalid_email(Post
::v('atn_add'))) {
761 S
::assert_xsrf_token();
762 $this->client
->add_to_wl($liste, Post
::v('atn_add'));
763 } elseif (Get
::has('atn_del')) {
764 S
::assert_xsrf_token();
765 $this->client
->del_from_wl($liste, Get
::v('atn_del'));
766 pl_redirect('lists/options/'.$liste);
769 if (list($details,$options) = $this->client
->get_owner_options($liste)) {
770 $page->assign_by_ref('details', $details);
771 $page->assign_by_ref('options', $options);
772 $bogo_level = intval($this->client
->get_bogo_level($liste));
773 $page->assign('unsure_level', $bogo_level & 1);
774 $page->assign('bogo_level', $bogo_level >> 1);
776 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
780 function handler_delete(&$page, $liste = null
)
783 if (is_null($liste)) {
787 $domain = $this->prepare_client($page);
788 if ($domain == $globals->mail
->domain ||
$domain == $globals->mail
->domain2
) {
793 $domain = '@' . $domain;
798 $page->changeTpl('lists/delete.tpl');
799 if (Post
::v('valid') == 'OUI') {
800 S
::assert_xsrf_token();
802 if ($this->client
->delete_list($liste, Post
::b('del_archive'))) {
803 foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) {
804 XDB
::execute("DELETE FROM $table
805 WHERE type={?} AND alias={?}",
806 $type, $liste.$app.$domain);
808 $page->assign('deleted', true
);
809 $page->trigSuccess('La liste a été détruite !');
811 $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
812 . 'Contact les administrateurs du site pour régler le problème : '
813 . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
815 } elseif (list($details,$options) = $this->client
->get_owner_options($liste)) {
816 if (!$details['own']) {
817 $page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
819 $page->assign_by_ref('details', $details);
820 $page->assign_by_ref('options', $options);
821 $page->assign('bogo_level', $this->client
->get_bogo_level($liste));
823 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
827 function handler_soptions(&$page, $liste = null
)
829 if (is_null($liste)) {
833 $this->prepare_client($page);
835 $page->changeTpl('lists/soptions.tpl');
837 if (Post
::has('submit')) {
838 S
::assert_xsrf_token();
841 $values = array_map('utf8_decode', $values);
842 unset($values['submit']);
843 $values['advertised'] = empty($values['advertised']) ? false
: true
;
844 $values['archive'] = empty($values['archive']) ? false
: true
;
845 $this->client
->set_admin_options($liste, $values);
848 if (list($details,$options) = $this->client
->get_admin_options($liste)) {
849 $page->assign_by_ref('details', $details);
850 $page->assign_by_ref('options', $options);
852 $page->kill("La liste n'existe pas");
856 function handler_check(&$page, $liste = null
)
858 if (is_null($liste)) {
862 $this->prepare_client($page);
864 $page->changeTpl('lists/check.tpl');
866 if (Post
::has('correct')) {
867 S
::assert_xsrf_token();
868 $this->client
->check_options($liste, true
);
871 if (list($details,$options) = $this->client
->check_options($liste)) {
872 $page->assign_by_ref('details', $details);
873 $page->assign_by_ref('options', $options);
875 $page->kill("La liste n'existe pas");
879 function handler_admin_all(&$page) {
880 $page->changeTpl('lists/admin_all.tpl');
881 $page->setTitle('Administration - Mailing lists');
883 $client = new MMList(S
::v('uid'), S
::v('password'));
884 $listes = $client->get_all_lists();
885 $page->assign_by_ref('listes', $listes);
889 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: