5e2b71cadc2602bc7736ca1832f5aaa187daf198
2 /***************************************************************************
3 * Copyright (C) 2003-2010 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/csv' => $this->make_hook('csv', AUTH_COOKIE
),
35 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE
),
36 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE
),
37 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC
, 'user', NO_HTTPS
),
39 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP
),
40 'lists/admin' => $this->make_hook('admin', AUTH_MDP
),
41 'lists/options' => $this->make_hook('options', AUTH_MDP
),
42 'lists/delete' => $this->make_hook('delete', AUTH_MDP
),
44 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP
),
45 'lists/check' => $this->make_hook('check', AUTH_MDP
),
46 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP
, 'admin'),
50 function prepare_client(&$page, $user = null
)
54 $this->load('lists.inc.php');
59 $this->client
= new MMList($user);
60 return $globals->mail
->domain
;
63 function get_pending_ops($domain, $list)
65 list($subs,$mails) = $this->client
->get_pending_ops($list);
66 $res = XDB
::query("SELECT mid
67 FROM email_list_moderate
68 WHERE ml = {?} AND domain = {?}",
70 $mids = $res->fetchColumn();
71 foreach ($mails as $key=>$mail) {
72 if (in_array($mail['id'], $mids)) {
76 return array($subs, $mails);
79 function handler_lists(&$page)
81 function filter_owner($list)
86 function filter_member($list)
91 $domain = $this->prepare_client($page);
93 $page->changeTpl('lists/index.tpl');
94 $page->addJsLink('ajax.js');
95 $page->setTitle('Listes de diffusion');
98 if (Get
::has('del')) {
99 S
::assert_xsrf_token();
100 $this->client
->unsubscribe(Get
::v('del'));
101 pl_redirect('lists');
103 if (Get
::has('add')) {
104 S
::assert_xsrf_token();
105 $this->client
->subscribe(Get
::v('add'));
106 pl_redirect('lists');
108 if (Post
::has('promo_add')) {
109 S
::assert_xsrf_token();
111 $promo = Post
::i('promo_add');
112 if ($promo >= 1900 and $promo < 2100) {
113 $this->client
->subscribe("promo$promo");
115 $page->trigSuccess("promo incorrecte, il faut une promo sur 4 chiffres.");
119 $listes = $this->client
->get_lists();
120 $owner = array_filter($listes, 'filter_owner');
121 $listes = array_diff_key($listes, $owner);
122 $member = array_filter($listes, 'filter_member');
123 $listes = array_diff_key($listes, $member);
124 foreach ($owner as $key=>$liste) {
125 list($subs,$mails) = $this->get_pending_ops($domain, $liste['list']);
126 $owner[$key]['subscriptions'] = $subs;
127 $owner[$key]['mails'] = $mails;
129 $page->register_modifier('hdc', 'list_header_decode');
130 $page->assign_by_ref('owner', $owner);
131 $page->assign_by_ref('member', $member);
132 $page->assign_by_ref('public', $listes);
135 function handler_ajax(&$page, $list = null
)
137 pl_content_headers("text/html");
138 $domain = $this->prepare_client($page);
139 $page->changeTpl('lists/liste.inc.tpl', NO_SKIN
);
140 S
::assert_xsrf_token();
142 if (Get
::has('unsubscribe')) {
143 $this->client
->unsubscribe($list);
145 if (Get
::has('subscribe')) {
146 $this->client
->subscribe($list);
148 if (Get
::has('sadd')) { /* 4 = SUBSCRIBE */
149 $this->client
->handle_request($list, Get
::v('sadd'), 4, '');
151 if (Get
::has('mid')) {
152 $this->moderate_mail($domain, $list, Get
::i('mid'));
155 list($liste, $members, $owners) = $this->client
->get_members($list);
157 list($subs,$mails) = $this->get_pending_ops($domain, $list);
158 $liste['subscriptions'] = $subs;
159 $liste['mails'] = $mails;
161 $page->register_modifier('hdc', 'list_header_decode');
162 $page->assign_by_ref('liste', $liste);
165 function handler_create(&$page)
169 $page->changeTpl('lists/create.tpl');
171 $user_promo = S
::i('promo');
174 $young_promo = $very_young_promo = 0;
175 if ((($year > $user_promo) && ($month > 3)) && ($year < $user_promo +
5)) {
178 if ((($year > $user_promo) && ($month > 7)) && (($year < $user_promo +
1) && ($month < 8))) {
179 $very_young_promo = 1;
181 $page->assign('young_promo', $young_promo);
182 $page->assign('very_young_promo', $very_young_promo);
184 $owners = preg_split("/[\s]+/", Post
::v('owners'), -1, PREG_SPLIT_NO_EMPTY
);
185 $members = preg_split("/[\s]+/", Post
::v('members'), -1, PREG_SPLIT_NO_EMPTY
);
187 // click on validate button 'add_owner_sub' or type <enter>
188 if (Post
::has('add_owner_sub') && Post
::has('add_owner')) {
189 // if we want to add an owner and then type <enter>, then both
190 // add_owner_sub and add_owner are filled.
191 $oforlifes = User
::getBulkForlifeEmails(Post
::v('add_owner'), true
);
192 $mforlifes = User
::getBulkForlifeEmails(Post
::v('add_member'), true
);
193 if (!is_null($oforlifes)) {
194 $owners = array_merge($owners, $oforlifes);
196 // if we want to add a member and then type <enter>, then
197 // add_owner_sub is filled, whereas add_owner is empty.
198 if (!is_null($mforlifes)) {
199 $members = array_merge($members, $mforlifes);
203 // click on validate button 'add_member_sub'
204 if (Post
::has('add_member_sub') && Post
::has('add_member')) {
205 $forlifes = User
::getBulkForlifeEmails(Post
::v('add_member'), true
);
206 if (!is_null($forlifes)) {
207 $members = array_merge($members, $forlifes);
210 if (Post
::has('add_member_sub') && isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
211 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
213 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
215 $forlifes = User
::getBulkForlifeEmails($upload->getContents(), true
);
216 if (!is_null($forlifes)) {
217 $members = array_merge($members, $forlifes);
223 $owners = array_unique($owners);
225 $members = array_unique($members);
227 $page->assign('owners', join("\n", $owners));
228 $page->assign('members', join("\n", $members));
230 if (!Post
::has('submit')) {
233 S
::assert_xsrf_token();
236 $asso = Post
::v('asso');
237 $liste = Post
::v('liste');
240 $page->trigError('Le champ « adresse souhaitée » est vide.');
242 if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
243 $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.');
246 if (($asso == "binet") ||
($asso == "alias")) {
247 $promo = Post
::i('promo');
248 $domain = $promo . '.' . $globals->mail
->domain
;
250 if (($promo < 1921) ||
($promo > date('Y'))) {
251 $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
254 $new = $liste . '@' . $domain;
255 $res = XDB
::query('SELECT COUNT(*) FROM virtual WHERE alias={?}', $new);
258 if ($asso == "groupex") {
259 $groupex_name = Post
::v('groupex_name');
261 $res_groupe = XDB
::query('SELECT mail_domain FROM groups WHERE nom={?}', $groupex_name);
262 $domain = $res_groupe->fetchOneCell();
265 $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.');
268 $new = $liste . '@' . $domain;
269 $res = XDB
::query('SELECT COUNT(*) FROM virtual WHERE alias={?}', $new);
271 $res = XDB
::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
272 $domain = $globals->mail
->domain
;
276 $n = $res->fetchOneCell();
279 $page->trigError("L'« adresse souhaitée » est déjà prise.");
282 if (!Post
::v('desc')) {
283 $page->trigError('Le sujet est vide.');
286 if (!count($owners)) {
287 $page->trigError('Il n\'y a pas de gestionnaire.');
290 if (count($members)<4) {
291 $page->trigError('Il n\'y a pas assez de membres.');
294 if (!$page->nb_errs()) {
295 $page->trigSuccess('Demande de création envoyée !');
296 $page->assign('created', true
);
297 require_once 'validations.inc.php';
298 $req = new ListeReq(S
::user(), $asso, $liste, $domain,
299 Post
::v('desc'), Post
::i('advertise'),
300 Post
::i('modlevel'), Post
::i('inslevel'),
306 function handler_members(&$page, $liste = null
)
308 if (is_null($liste)) {
312 $this->prepare_client($page);
314 $page->changeTpl('lists/members.tpl');
316 if (Get
::has('del')) {
317 S
::assert_xsrf_token();
318 $this->client
->unsubscribe($liste);
319 pl_redirect('lists/members/'.$liste);
322 if (Get
::has('add')) {
323 S
::assert_xsrf_token();
324 $this->client
->subscribe($liste);
325 pl_redirect('lists/members/'.$liste);
328 $members = $this->client
->get_members($liste);
330 $tri_promo = !Env
::b('alpha');
332 if (list($det,$mem,$own) = $members) {
333 $membres = list_sort_members($mem, $tri_promo);
334 $moderos = list_sort_owners($own, $tri_promo);
336 $page->assign_by_ref('details', $det);
337 $page->assign_by_ref('members', $membres);
338 $page->assign_by_ref('owners', $moderos);
339 $page->assign('nb_m', count($mem));
341 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
345 function handler_csv(PlPage
&$page, $liste = null
)
347 if (is_null($liste)) {
350 $this->prepare_client($page);
351 $members = $this->client
->get_members($liste);
352 $list = list_fetch_names(list_extract_members($members[1]));
353 pl_content_headers("text/x-csv");
355 echo "email,nom,prenom,promo\n";
356 foreach ($list as $member) {
357 echo @$member['email'] . ',' . @$member['nom'] . ',' . @$member['prenom'] . ',' . @$member['promo'] . "\n";
362 function handler_annu(&$page, $liste = null
, $action = null
, $subaction = null
)
364 if (is_null($liste)) {
368 $this->prepare_client($page);
370 if (Get
::has('del')) {
371 S
::assert_xsrf_token();
372 $this->client
->unsubscribe($liste);
373 pl_redirect('lists/annu/'.$liste);
375 if (Get
::has('add')) {
376 S
::assert_xsrf_token();
377 $this->client
->subscribe($liste);
378 pl_redirect('lists/annu/'.$liste);
381 $owners = $this->client
->get_owners($liste);
382 if (!is_array($owners)) {
383 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
387 list(,$members) = $this->client
->get_members($liste);
389 foreach ($members as $m) {
392 require_once 'userset.inc.php';
393 $view = new ArraySet($users);
394 $view->addMod('trombi', 'Trombinoscope', true
, array('with_promo' => true
));
395 if (empty($GLOBALS['IS_XNET_SITE'])) {
396 $view->addMod('minifiche', 'Mini-fiches', false
);
398 // TODO: Reactivate when the new map is completed.
399 // $view->addMod('geoloc', 'Planisphère');
400 $view->apply("lists/annu/$liste", $page, $action, $subaction);
401 if ($action == 'geoloc' && $subaction) {
405 $page->changeTpl('lists/annu.tpl');
406 $moderos = list_sort_owners($owners[1]);
407 $page->assign_by_ref('details', $owners[0]);
408 $page->assign_by_ref('owners', $moderos);
411 function handler_archives(&$page, $liste = null
, $action = null
, $artid = null
)
415 if (is_null($liste)) {
419 $domain = $this->prepare_client($page);
421 $page->changeTpl('lists/archives.tpl');
423 if (list($det) = $this->client
->get_members($liste)) {
424 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
425 && !$det['own'] && ($det['sub'] < 2)) {
426 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
428 $get = Array('listname' => $liste, 'domain' => $domain);
429 if (Post
::has('updateall')) {
430 $get['updateall'] = Post
::v('updateall');
432 require_once 'banana/ml.inc.php';
433 get_banana_params($get, null
, $action, $artid);
434 run_banana($page, 'MLBanana', $get);
436 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
440 function handler_rss(&$page, $liste = null
, $alias = null
, $hash = null
)
445 $user = Platal
::session()->tokenAuth($alias, $hash);
446 if (is_null($user)) {
450 $domain = $this->prepare_client($page, $user);
451 if (list($det) = $this->client
->get_members($liste)) {
452 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
453 && !$det['own'] && ($det['sub'] < 2)) {
456 require_once('banana/ml.inc.php');
457 $banana = new MLBanana($user, Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
463 function moderate_mail($domain, $liste, $mid)
465 if (Env
::has('mok')) {
467 } elseif (Env
::has('mno')) {
469 } elseif (Env
::has('mdel')) {
475 return XDB
::execute("INSERT IGNORE INTO email_list_moderate
476 VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
477 $liste, $domain, $mid, S
::i('uid'), $action, Post
::v('reason'));
480 function handler_moderate(&$page, $liste = null
)
482 if (is_null($liste)) {
486 $domain = $this->prepare_client($page);
488 $page->changeTpl('lists/moderate.tpl');
490 $page->register_modifier('hdc', 'list_header_decode');
492 if (Env
::has('sadd') || Env
::has('sdel')) {
493 S
::assert_xsrf_token();
495 if (Env
::has('sadd')) { /* 4 = SUBSCRIBE */
496 $sub = $this->client
->get_pending_sub($liste, Env
::v('sadd'));
497 $this->client
->handle_request($liste,Env
::v('sadd'),4,'');
500 if (Post
::has('sdel')) { /* 2 = REJECT */
501 $sub = $this->client
->get_pending_sub($liste, Env
::v('sdel'));
502 $this->client
->handle_request($liste, Post
::v('sdel'), 2, utf8_decode(Post
::v('reason')));
506 $mailer = new PlMailer();
507 $mailer->setFrom("$liste-bounces@{$domain}");
508 $mailer->addTo("$liste-owner@{$domain}");
509 $mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
510 $mailer->setSubject("L'inscription de {$sub['name']} a été $info");
511 $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S
::v('prenom') . ' '
512 . S
::v('nom') . '(' . S
::v('promo') . ")\n";
513 if (trim(Post
::v('reason'))) {
514 $text .= "\nLa raison invoquée est :\n" . Post
::v('reason');
516 $mailer->setTxtBody(wordwrap($text, 72));
519 if (Env
::has('sadd')) {
520 pl_redirect('lists/moderate/'.$liste);
524 if (Post
::has('moderate_mails') && Post
::has('select_mails')) {
525 S
::assert_xsrf_token();
527 $mails = array_keys(Post
::v('select_mails'));
528 foreach($mails as $mail) {
529 $this->moderate_mail($domain, $liste, $mail);
531 } elseif (Env
::has('mid')) {
532 if (Get
::has('mid') && !Env
::has('mok') && !Env
::has('mdel')) {
533 require_once 'banana/moderate.inc.php';
535 $page->changeTpl('lists/moderate_mail.tpl');
536 $params = array('listname' => $liste, 'domain' => $domain,
537 'artid' => Get
::i('mid'), 'part' => Get
::v('part'), 'action' => Get
::v('action'));
538 $params['client'] = $this->client
;
539 run_banana($page, 'ModerationBanana', $params);
541 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
542 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
543 $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
544 $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
545 $msg = str_replace("%(listname)s", $liste, $msg);
546 $page->assign('msg', $msg);
550 $this->moderate_mail($domain, $liste, Env
::i('mid'));
551 } elseif (Env
::has('sid')) {
552 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
553 foreach($subs as $user) {
554 if ($user['id'] == Env
::v('sid')) {
555 $page->changeTpl('lists/moderate_sub.tpl');
556 $page->assign('del_user', $user);
564 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
565 foreach ($mails as $key=>$mail) {
566 $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
567 if ($mail['fromx']) {
568 $page->assign('with_fromx', true
);
570 $page->assign('with_nonfromx', true
);
573 $page->assign_by_ref('subs', $subs);
574 $page->assign_by_ref('mails', $mails);
576 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer.");
580 static public function no_login_callback($login)
582 global $list_unregistered, $globals;
584 /* TODO: fixes this call to a removed function. */
585 $users = get_not_registered_user($login, true
);
586 if ($users && $users->total()) {
587 if (!isset($list_unregistered)) {
588 $list_unregistered = array();
590 $list_unregistered[$login] = $users;
592 list($name, $dom) = @explode
('@', $login);
593 if ($dom == $globals->mail
->domain ||
$dom == $globals->mail
->domain2
) {
594 User
::_default_user_callback($login);
599 function handler_admin(&$page, $liste = null
)
603 if (is_null($liste)) {
607 $domain = $this->prepare_client($page);
609 $page->changeTpl('lists/admin.tpl');
611 if (Env
::has('send_mark')) {
612 S
::assert_xsrf_token();
614 $actions = Env
::v('mk_action');
615 $uids = Env
::v('mk_uid');
616 $mails = Env
::v('mk_email');
617 foreach ($actions as $key=>$action) {
622 case 'marketu': case 'markets':
623 require_once 'emails.inc.php';
624 $mail = valide_email($mails[$key]);
625 if (isvalid_email_redirection($mail)) {
626 $from = ($action == 'marketu') ?
'user' : 'staff';
627 $market = Marketing
::get($uids[$key], $mail);
629 $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S
::v('uid'));
636 XDB
::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain)
637 VALUES ({?}, \'list\', {?}, {?})',
638 $uids[$key], $liste, $domain);
643 if (Env
::has('add_member')) {
644 S
::assert_xsrf_token();
646 $members = User
::getBulkForlifeEmails(Env
::v('add_member'),
648 array('ListsModule', 'no_login_callback'));
649 $arr = $this->client
->mass_subscribe($liste, $members);
650 if (is_array($arr)) {
651 foreach($arr as $addr) {
652 $page->trigSuccess("{$addr[0]} inscrit.");
657 if (isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
658 S
::assert_xsrf_token();
660 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
662 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
664 $members = User
::getBulkForlifeEmails($upload->getContents(),
666 array('ListsModule', 'no_login_callback'));
667 $arr = $this->client
->mass_subscribe($liste, $members);
668 if (is_array($arr)) {
669 foreach($arr as $addr) {
670 $page->trigSuccess("{$addr[0]} inscrit.");
676 if (Env
::has('del_member')) {
677 S
::assert_xsrf_token();
679 if (strpos(Env
::v('del_member'), '@') === false
) {
680 $this->client
->mass_unsubscribe(
681 $liste, array(Env
::v('del_member').'@'.$globals->mail
->domain
));
683 $this->client
->mass_unsubscribe($liste, array(Env
::v('del_member')));
685 pl_redirect('lists/admin/'.$liste);
688 if (Env
::has('add_owner')) {
689 S
::assert_xsrf_token();
691 $owners = User
::getBulkForlifeEmails(Env
::v('add_owner'), false
, array('ListsModule', 'no_login_callback'));
693 foreach ($owners as $login) {
694 if ($this->client
->add_owner($liste, $login)) {
695 $page->trigSuccess($login ." ajouté aux modérateurs.");
701 if (Env
::has('del_owner')) {
702 S
::assert_xsrf_token();
704 if (strpos(Env
::v('del_owner'), '@') === false
) {
705 $this->client
->del_owner($liste, Env
::v('del_owner').'@'.$globals->mail
->domain
);
707 $this->client
->del_owner($liste, Env
::v('del_owner'));
709 pl_redirect('lists/admin/'.$liste);
712 if (list($det,$mem,$own) = $this->client
->get_members($liste)) {
713 global $list_unregistered;
714 if ($list_unregistered) {
715 $page->assign_by_ref('unregistered', $list_unregistered);
717 $membres = list_sort_members($mem, @$tri_promo);
718 $moderos = list_sort_owners($own, @$tri_promo);
720 $page->assign_by_ref('details', $det);
721 $page->assign_by_ref('members', $membres);
722 $page->assign_by_ref('owners', $moderos);
723 $page->assign('np_m', count($mem));
726 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.<br />"
727 . " Si tu penses qu'il s'agit d'une erreur, "
728 . "<a href='mailto:support@polytechnique.org'>contact le support</a>.");
732 function handler_options(&$page, $liste = null
)
734 if (is_null($liste)) {
738 $this->prepare_client($page);
740 $page->changeTpl('lists/options.tpl');
742 if (Post
::has('submit')) {
743 S
::assert_xsrf_token();
746 $values = array_map('utf8_decode', $values);
747 $spamlevel = intval($values['bogo_level']);
748 $unsurelevel = intval($values['unsure_level']);
749 if ($spamlevel == 0) {
752 if ($spamlevel > 3 ||
$spamlevel < 0 ||
$unsurelevel < 0 ||
$unsurelevel > 1) {
753 $page->trigError("Réglage de l'antispam non valide");
755 $this->client
->set_bogo_level($liste, ($spamlevel << 1) +
$unsurelevel);
757 switch($values['moderate']) {
759 $values['generic_nonmember_action'] = 0;
760 $values['default_member_moderation'] = 0;
763 $values['generic_nonmember_action'] = 1;
764 $values['default_member_moderation'] = 0;
767 $values['generic_nonmember_action'] = 1;
768 $values['default_member_moderation'] = 1;
771 unset($values['submit'], $values['bogo_level'], $values['moderate']);
772 $values['send_goodbye_msg'] = !empty($values['send_goodbye_msg']);
773 $values['admin_notify_mchanges'] = !empty($values['admin_notify_mchanges']);
774 $values['subscribe_policy'] = empty($values['subscribe_policy']) ?
0 : 2;
775 if (isset($values['subject_prefix'])) {
776 $values['subject_prefix'] = trim($values['subject_prefix']).' ';
778 $this->client
->set_owner_options($liste, $values);
779 } elseif (isvalid_email(Post
::v('atn_add'))) {
780 S
::assert_xsrf_token();
781 $this->client
->add_to_wl($liste, Post
::v('atn_add'));
782 } elseif (Get
::has('atn_del')) {
783 S
::assert_xsrf_token();
784 $this->client
->del_from_wl($liste, Get
::v('atn_del'));
785 pl_redirect('lists/options/'.$liste);
788 if (list($details,$options) = $this->client
->get_owner_options($liste)) {
789 $page->assign_by_ref('details', $details);
790 $page->assign_by_ref('options', $options);
791 $bogo_level = intval($this->client
->get_bogo_level($liste));
792 $page->assign('unsure_level', $bogo_level & 1);
793 $page->assign('bogo_level', $bogo_level >> 1);
795 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
799 function handler_delete(&$page, $liste = null
)
802 if (is_null($liste)) {
806 $domain = $this->prepare_client($page);
807 if ($domain == $globals->mail
->domain ||
$domain == $globals->mail
->domain2
) {
812 $domain = '@' . $domain;
817 $page->changeTpl('lists/delete.tpl');
818 if (Post
::v('valid') == 'OUI') {
819 S
::assert_xsrf_token();
821 if ($this->client
->delete_list($liste, Post
::b('del_archive'))) {
822 foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) {
823 XDB
::execute("DELETE FROM $table
824 WHERE type={?} AND alias={?}",
825 $type, $liste.$app.$domain);
827 $page->assign('deleted', true
);
828 $page->trigSuccess('La liste a été détruite !');
830 $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
831 . 'Contact les administrateurs du site pour régler le problème : '
832 . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>.');
834 } elseif (list($details,$options) = $this->client
->get_owner_options($liste)) {
835 if (!$details['own']) {
836 $page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
838 $page->assign_by_ref('details', $details);
839 $page->assign_by_ref('options', $options);
840 $page->assign('bogo_level', $this->client
->get_bogo_level($liste));
842 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
846 function handler_soptions(&$page, $liste = null
)
848 if (is_null($liste)) {
852 $this->prepare_client($page);
854 $page->changeTpl('lists/soptions.tpl');
856 if (Post
::has('submit')) {
857 S
::assert_xsrf_token();
860 $values = array_map('utf8_decode', $values);
861 unset($values['submit']);
862 $values['advertised'] = empty($values['advertised']) ? false
: true
;
863 $values['archive'] = empty($values['archive']) ? false
: true
;
864 $this->client
->set_admin_options($liste, $values);
867 if (list($details,$options) = $this->client
->get_admin_options($liste)) {
868 $page->assign_by_ref('details', $details);
869 $page->assign_by_ref('options', $options);
871 $page->kill("La liste n'existe pas.");
875 function handler_check(&$page, $liste = null
)
877 if (is_null($liste)) {
881 $this->prepare_client($page);
883 $page->changeTpl('lists/check.tpl');
885 if (Post
::has('correct')) {
886 S
::assert_xsrf_token();
887 $this->client
->check_options($liste, true
);
890 if (list($details,$options) = $this->client
->check_options($liste)) {
891 $page->assign_by_ref('details', $details);
892 $page->assign_by_ref('options', $options);
894 $page->kill("La liste n'existe pas.");
898 function handler_admin_all(&$page)
900 $page->changeTpl('lists/admin_all.tpl');
901 $page->setTitle('Administration - Mailing lists');
903 $this->prepare_client($page);
904 $listes = $this->client
->get_all_lists();
905 $page->assign_by_ref('listes', $listes);
909 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: