f6e01098aeba450e2405b34938d3489574db2668
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
, 'lists'),
30 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP
, 'lists', NO_AUTH
),
31 'lists/create' => $this->make_hook('create', AUTH_MDP
, 'lists'),
33 'lists/members' => $this->make_hook('members', AUTH_COOKIE
, 'lists'),
34 'lists/csv' => $this->make_hook('csv', AUTH_COOKIE
, 'lists'),
35 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE
, 'lists'),
36 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE
, 'lists'),
37 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC
, 'lists', NO_HTTPS
),
39 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP
, 'lists'),
40 'lists/admin' => $this->make_hook('admin', AUTH_MDP
, 'lists'),
41 'lists/options' => $this->make_hook('options', AUTH_MDP
, 'lists'),
42 'lists/delete' => $this->make_hook('delete', AUTH_MDP
, 'lists'),
44 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP
, 'lists'),
45 'lists/check' => $this->make_hook('check', AUTH_MDP
, 'lists'),
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->trigError("promo incorrecte, il faut une promo sur 4 chiffres.");
119 if (!is_null($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);
136 function handler_ajax(&$page, $list = null
)
138 pl_content_headers("text/html");
139 $domain = $this->prepare_client($page);
140 $page->changeTpl('lists/liste.inc.tpl', NO_SKIN
);
141 S
::assert_xsrf_token();
143 if (Get
::has('unsubscribe')) {
144 $this->client
->unsubscribe($list);
146 if (Get
::has('subscribe')) {
147 $this->client
->subscribe($list);
149 if (Get
::has('sadd')) { /* 4 = SUBSCRIBE */
150 $this->client
->handle_request($list, Get
::v('sadd'), 4, '');
152 if (Get
::has('mid')) {
153 $this->moderate_mail($domain, $list, Get
::i('mid'));
156 list($liste, $members, $owners) = $this->client
->get_members($list);
158 list($subs,$mails) = $this->get_pending_ops($domain, $list);
159 $liste['subscriptions'] = $subs;
160 $liste['mails'] = $mails;
162 $page->register_modifier('hdc', 'list_header_decode');
163 $page->assign_by_ref('liste', $liste);
166 function handler_create(&$page)
170 $page->changeTpl('lists/create.tpl');
172 $user_promo = S
::user()->profile()->yearPromo();
175 // scolar year starts in september
176 $scolarmonth = ($year - $user_promo) * 12 +
($month - 8);
177 $young_promo = $very_young_promo = 0;
178 // binet are accessible only in april in the first year and until
179 // march of the 5th year
180 if ($scolarmonth >= 8 && $scolarmonth < 56) {
183 // PSC aliases are accesible only between september and june of the second
185 if ($scolarmonth >= 12 && $scolarmonth < 22) {
186 $very_young_promo = 1;
188 $page->assign('young_promo', $young_promo);
189 $page->assign('very_young_promo', $very_young_promo);
191 $owners = preg_split("/[\s]+/", Post
::v('owners'), -1, PREG_SPLIT_NO_EMPTY
);
192 $members = preg_split("/[\s]+/", Post
::v('members'), -1, PREG_SPLIT_NO_EMPTY
);
194 // click on validate button 'add_owner_sub' or type <enter>
195 if (Post
::has('add_owner_sub') && Post
::has('add_owner')) {
196 // if we want to add an owner and then type <enter>, then both
197 // add_owner_sub and add_owner are filled.
198 $oforlifes = User
::getBulkForlifeEmails(Post
::v('add_owner'), true
);
199 $mforlifes = User
::getBulkForlifeEmails(Post
::v('add_member'), true
);
200 if (!is_null($oforlifes)) {
201 $owners = array_merge($owners, $oforlifes);
203 // if we want to add a member and then type <enter>, then
204 // add_owner_sub is filled, whereas add_owner is empty.
205 if (!is_null($mforlifes)) {
206 $members = array_merge($members, $mforlifes);
210 // click on validate button 'add_member_sub'
211 if (Post
::has('add_member_sub') && Post
::has('add_member')) {
212 $forlifes = User
::getBulkForlifeEmails(Post
::v('add_member'), true
);
213 if (!is_null($forlifes)) {
214 $members = array_merge($members, $forlifes);
217 if (Post
::has('add_member_sub') && isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
218 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
220 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
222 $forlifes = User
::getBulkForlifeEmails($upload->getContents(), true
);
223 if (!is_null($forlifes)) {
224 $members = array_merge($members, $forlifes);
230 $owners = array_unique($owners);
232 $members = array_unique($members);
234 $page->assign('owners', join("\n", $owners));
235 $page->assign('members', join("\n", $members));
237 if (!Post
::has('submit')) {
240 S
::assert_xsrf_token();
243 $asso = Post
::v('asso');
244 $liste = Post
::v('liste');
247 $page->trigError('Le champ « adresse souhaitée » est vide.');
249 if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
250 $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.');
253 if (($asso == "binet") ||
($asso == "alias")) {
254 $promo = Post
::i('promo');
255 $domain = $promo . '.' . $globals->mail
->domain
;
257 if (($promo < 1921) ||
($promo > date('Y'))) {
258 $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
261 $new = $liste . '@' . $domain;
262 $res = XDB
::query('SELECT COUNT(*) FROM virtual WHERE alias={?}', $new);
265 if ($asso == "groupex") {
266 $groupex_name = Post
::v('groupex_name');
268 $res_groupe = XDB
::query('SELECT mail_domain FROM groups WHERE nom={?}', $groupex_name);
269 $domain = $res_groupe->fetchOneCell();
272 $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.');
275 $new = $liste . '@' . $domain;
276 $res = XDB
::query('SELECT COUNT(*) FROM virtual WHERE alias={?}', $new);
278 $res = XDB
::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
279 $domain = $globals->mail
->domain
;
283 $n = $res->fetchOneCell();
286 $page->trigError("L'« adresse souhaitée » est déjà prise.");
289 if (!Post
::v('desc')) {
290 $page->trigError('Le sujet est vide.');
293 if (!count($owners)) {
294 $page->trigError('Il n\'y a pas de gestionnaire.');
297 if (count($members)<4) {
298 $page->trigError('Il n\'y a pas assez de membres.');
301 if (!$page->nb_errs()) {
302 $page->trigSuccess('Demande de création envoyée !');
303 $page->assign('created', true
);
304 $req = new ListeReq(S
::user(), $asso, $liste, $domain,
305 Post
::v('desc'), Post
::i('advertise'),
306 Post
::i('modlevel'), Post
::i('inslevel'),
312 function handler_members(&$page, $liste = null
)
314 if (is_null($liste)) {
318 $this->prepare_client($page);
320 $page->changeTpl('lists/members.tpl');
322 if (Get
::has('del')) {
323 S
::assert_xsrf_token();
324 $this->client
->unsubscribe($liste);
325 pl_redirect('lists/members/'.$liste);
328 if (Get
::has('add')) {
329 S
::assert_xsrf_token();
330 $this->client
->subscribe($liste);
331 pl_redirect('lists/members/'.$liste);
334 $members = $this->client
->get_members($liste);
336 $tri_promo = !Env
::b('alpha');
338 if (list($det,$mem,$own) = $members) {
339 $membres = list_sort_members($mem, $tri_promo);
340 $moderos = list_sort_owners($own, $tri_promo);
342 $page->assign_by_ref('details', $det);
343 $page->assign_by_ref('members', $membres);
344 $page->assign_by_ref('owners', $moderos);
345 $page->assign('nb_m', count($mem));
347 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
351 function handler_csv(PlPage
&$page, $liste = null
)
353 if (is_null($liste)) {
356 $this->prepare_client($page);
357 $members = $this->client
->get_members($liste);
358 $list = list_fetch_basic_info(list_extract_members($members[1]));
359 pl_content_headers("text/x-csv");
361 echo "email,nom,promo\n";
362 echo implode("\n", $list);
366 function handler_annu(&$page, $liste = null
, $action = null
, $subaction = null
)
368 if (is_null($liste)) {
372 $this->prepare_client($page);
374 if (Get
::has('del')) {
375 S
::assert_xsrf_token();
376 $this->client
->unsubscribe($liste);
377 pl_redirect('lists/annu/'.$liste);
379 if (Get
::has('add')) {
380 S
::assert_xsrf_token();
381 $this->client
->subscribe($liste);
382 pl_redirect('lists/annu/'.$liste);
385 $owners = $this->client
->get_owners($liste);
386 if (!is_array($owners)) {
387 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
391 list(,$members) = $this->client
->get_members($liste);
393 foreach ($members as $m) {
396 require_once 'userset.inc.php';
397 $view = new ArraySet($users);
398 $view->addMod('trombi', 'Trombinoscope', true
, array('with_promo' => true
));
399 if (empty($GLOBALS['IS_XNET_SITE'])) {
400 $view->addMod('minifiche', 'Mini-fiches', false
);
402 // TODO: Reactivate when the new map is completed.
403 // $view->addMod('geoloc', 'Planisphère');
404 $view->apply("lists/annu/$liste", $page, $action, $subaction);
405 if ($action == 'geoloc' && $subaction) {
409 $page->changeTpl('lists/annu.tpl');
410 $moderos = list_sort_owners($owners[1]);
411 $page->assign_by_ref('details', $owners[0]);
412 $page->assign_by_ref('owners', $moderos);
415 function handler_archives(&$page, $liste = null
, $action = null
, $artid = null
)
419 if (is_null($liste)) {
423 $domain = $this->prepare_client($page);
425 $page->changeTpl('lists/archives.tpl');
427 if (list($det) = $this->client
->get_members($liste)) {
428 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
429 && !$det['own'] && ($det['sub'] < 2)) {
430 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
432 $get = Array('listname' => $liste, 'domain' => $domain);
433 if (Post
::has('updateall')) {
434 $get['updateall'] = Post
::v('updateall');
436 require_once 'banana/ml.inc.php';
437 get_banana_params($get, null
, $action, $artid);
438 run_banana($page, 'MLBanana', $get);
440 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
444 function handler_rss(&$page, $liste = null
, $alias = null
, $hash = null
)
449 $user = Platal
::session()->tokenAuth($alias, $hash);
450 if (is_null($user)) {
454 $domain = $this->prepare_client($page, $user);
455 if (list($det) = $this->client
->get_members($liste)) {
456 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
457 && !$det['own'] && ($det['sub'] < 2)) {
460 require_once('banana/ml.inc.php');
461 $banana = new MLBanana($user, Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
467 function moderate_mail($domain, $liste, $mid)
469 if (Env
::has('mok')) {
471 } elseif (Env
::has('mno')) {
473 } elseif (Env
::has('mdel')) {
479 return XDB
::execute("INSERT IGNORE INTO email_list_moderate
480 VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
481 $liste, $domain, $mid, S
::i('uid'), $action, Post
::v('reason'));
484 function handler_moderate(&$page, $liste = null
)
486 if (is_null($liste)) {
490 $domain = $this->prepare_client($page);
492 $page->changeTpl('lists/moderate.tpl');
494 $page->register_modifier('hdc', 'list_header_decode');
496 if (Env
::has('sadd') || Env
::has('sdel')) {
497 S
::assert_xsrf_token();
499 if (Env
::has('sadd')) { /* 4 = SUBSCRIBE */
500 $sub = $this->client
->get_pending_sub($liste, Env
::v('sadd'));
501 $this->client
->handle_request($liste,Env
::v('sadd'),4,'');
504 if (Post
::has('sdel')) { /* 2 = REJECT */
505 $sub = $this->client
->get_pending_sub($liste, Env
::v('sdel'));
506 $this->client
->handle_request($liste, Post
::v('sdel'), 2, utf8_decode(Post
::v('reason')));
510 $mailer = new PlMailer();
511 $mailer->setFrom("$liste-bounces@{$domain}");
512 $mailer->addTo("$liste-owner@{$domain}");
513 $mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
514 $mailer->setSubject("L'inscription de {$sub['name']} a été $info");
515 $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S
::v('prenom') . ' '
516 . S
::v('nom') . '(' . S
::v('promo') . ")\n";
517 if (trim(Post
::v('reason'))) {
518 $text .= "\nLa raison invoquée est :\n" . Post
::v('reason');
520 $mailer->setTxtBody(wordwrap($text, 72));
523 if (Env
::has('sadd')) {
524 pl_redirect('lists/moderate/'.$liste);
528 if (Post
::has('moderate_mails') && Post
::has('select_mails')) {
529 S
::assert_xsrf_token();
531 $mails = array_keys(Post
::v('select_mails'));
532 foreach($mails as $mail) {
533 $this->moderate_mail($domain, $liste, $mail);
535 } elseif (Env
::has('mid')) {
536 if (Get
::has('mid') && !Env
::has('mok') && !Env
::has('mdel')) {
537 require_once 'banana/moderate.inc.php';
539 $page->changeTpl('lists/moderate_mail.tpl');
540 $params = array('listname' => $liste, 'domain' => $domain,
541 'artid' => Get
::i('mid'), 'part' => Get
::v('part'), 'action' => Get
::v('action'));
542 $params['client'] = $this->client
;
543 run_banana($page, 'ModerationBanana', $params);
545 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
546 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
547 $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
548 $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
549 $msg = str_replace("%(listname)s", $liste, $msg);
550 $page->assign('msg', $msg);
554 $this->moderate_mail($domain, $liste, Env
::i('mid'));
555 } elseif (Env
::has('sid')) {
556 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
557 foreach($subs as $user) {
558 if ($user['id'] == Env
::v('sid')) {
559 $page->changeTpl('lists/moderate_sub.tpl');
560 $page->assign('del_user', $user);
568 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
569 foreach ($mails as $key=>$mail) {
570 $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
571 if ($mail['fromx']) {
572 $page->assign('with_fromx', true
);
574 $page->assign('with_nonfromx', true
);
577 $page->assign_by_ref('subs', $subs);
578 $page->assign_by_ref('mails', $mails);
580 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer.");
584 static public function no_login_callback($login)
586 global $list_unregistered, $globals;
588 $users = User
::getPendingAccounts($login, true
);
589 if ($users && $users->total()) {
590 if (!isset($list_unregistered)) {
591 $list_unregistered = array();
593 $list_unregistered[$login] = $users;
595 list($name, $dom) = @explode
('@', $login);
596 if ($dom == $globals->mail
->domain ||
$dom == $globals->mail
->domain2
) {
597 User
::_default_user_callback($login);
602 function handler_admin(&$page, $liste = null
)
606 if (is_null($liste)) {
610 $domain = $this->prepare_client($page);
612 $page->changeTpl('lists/admin.tpl');
614 if (Env
::has('send_mark')) {
615 S
::assert_xsrf_token();
617 $actions = Env
::v('mk_action');
618 $uids = Env
::v('mk_uid');
619 $mails = Env
::v('mk_email');
620 foreach ($actions as $key=>$action) {
625 case 'marketu': case 'markets':
626 require_once 'emails.inc.php';
627 $mail = valide_email($mails[$key]);
628 if (isvalid_email_redirection($mail)) {
629 $from = ($action == 'marketu') ?
'user' : 'staff';
630 $market = Marketing
::get($uids[$key], $mail);
632 $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S
::v('uid'));
639 XDB
::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain)
640 VALUES ({?}, \'list\', {?}, {?})',
641 $uids[$key], $liste, $domain);
646 if (Env
::has('add_member')) {
647 S
::assert_xsrf_token();
649 $members = User
::getBulkForlifeEmails(Env
::v('add_member'),
651 array('ListsModule', 'no_login_callback'));
652 $arr = $this->client
->mass_subscribe($liste, $members);
653 if (is_array($arr)) {
654 foreach($arr as $addr) {
655 $page->trigSuccess("{$addr[0]} inscrit.");
660 if (isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
661 S
::assert_xsrf_token();
663 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
665 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
667 $members = User
::getBulkForlifeEmails($upload->getContents(),
669 array('ListsModule', 'no_login_callback'));
670 $arr = $this->client
->mass_subscribe($liste, $members);
671 if (is_array($arr)) {
672 foreach($arr as $addr) {
673 $page->trigSuccess("{$addr[0]} inscrit.");
679 if (Env
::has('del_member')) {
680 S
::assert_xsrf_token();
682 if (strpos(Env
::v('del_member'), '@') === false
) {
683 $this->client
->mass_unsubscribe(
684 $liste, array(Env
::v('del_member').'@'.$globals->mail
->domain
));
686 $this->client
->mass_unsubscribe($liste, array(Env
::v('del_member')));
688 pl_redirect('lists/admin/'.$liste);
691 if (Env
::has('add_owner')) {
692 S
::assert_xsrf_token();
694 $owners = User
::getBulkForlifeEmails(Env
::v('add_owner'), false
, array('ListsModule', 'no_login_callback'));
696 foreach ($owners as $login) {
697 if ($this->client
->add_owner($liste, $login)) {
698 $page->trigSuccess($login ." ajouté aux modérateurs.");
704 if (Env
::has('del_owner')) {
705 S
::assert_xsrf_token();
707 if (strpos(Env
::v('del_owner'), '@') === false
) {
708 $this->client
->del_owner($liste, Env
::v('del_owner').'@'.$globals->mail
->domain
);
710 $this->client
->del_owner($liste, Env
::v('del_owner'));
712 pl_redirect('lists/admin/'.$liste);
715 if (list($det,$mem,$own) = $this->client
->get_members($liste)) {
716 global $list_unregistered;
717 if ($list_unregistered) {
718 $page->assign_by_ref('unregistered', $list_unregistered);
720 $membres = list_sort_members($mem, @$tri_promo);
721 $moderos = list_sort_owners($own, @$tri_promo);
723 $page->assign_by_ref('details', $det);
724 $page->assign_by_ref('members', $membres);
725 $page->assign_by_ref('owners', $moderos);
726 $page->assign('np_m', count($mem));
729 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.<br />"
730 . " Si tu penses qu'il s'agit d'une erreur, "
731 . "<a href='mailto:support@polytechnique.org'>contact le support</a>.");
735 function handler_options(&$page, $liste = null
)
737 if (is_null($liste)) {
741 $this->prepare_client($page);
743 $page->changeTpl('lists/options.tpl');
745 if (Post
::has('submit')) {
746 S
::assert_xsrf_token();
749 $values = array_map('utf8_decode', $values);
750 $spamlevel = intval($values['bogo_level']);
751 $unsurelevel = intval($values['unsure_level']);
752 if ($spamlevel == 0) {
755 if ($spamlevel > 3 ||
$spamlevel < 0 ||
$unsurelevel < 0 ||
$unsurelevel > 1) {
756 $page->trigError("Réglage de l'antispam non valide");
758 $this->client
->set_bogo_level($liste, ($spamlevel << 1) +
$unsurelevel);
760 switch($values['moderate']) {
762 $values['generic_nonmember_action'] = 0;
763 $values['default_member_moderation'] = 0;
766 $values['generic_nonmember_action'] = 1;
767 $values['default_member_moderation'] = 0;
770 $values['generic_nonmember_action'] = 1;
771 $values['default_member_moderation'] = 1;
774 unset($values['submit'], $values['bogo_level'], $values['moderate']);
775 $values['send_goodbye_msg'] = !empty($values['send_goodbye_msg']);
776 $values['admin_notify_mchanges'] = !empty($values['admin_notify_mchanges']);
777 $values['subscribe_policy'] = empty($values['subscribe_policy']) ?
0 : 2;
778 if (isset($values['subject_prefix'])) {
779 $values['subject_prefix'] = trim($values['subject_prefix']).' ';
781 $this->client
->set_owner_options($liste, $values);
782 } elseif (isvalid_email(Post
::v('atn_add'))) {
783 S
::assert_xsrf_token();
784 $this->client
->add_to_wl($liste, Post
::v('atn_add'));
785 } elseif (Get
::has('atn_del')) {
786 S
::assert_xsrf_token();
787 $this->client
->del_from_wl($liste, Get
::v('atn_del'));
788 pl_redirect('lists/options/'.$liste);
791 if (list($details,$options) = $this->client
->get_owner_options($liste)) {
792 $page->assign_by_ref('details', $details);
793 $page->assign_by_ref('options', $options);
794 $bogo_level = intval($this->client
->get_bogo_level($liste));
795 $page->assign('unsure_level', $bogo_level & 1);
796 $page->assign('bogo_level', $bogo_level >> 1);
798 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
802 function handler_delete(&$page, $liste = null
)
805 if (is_null($liste)) {
809 $domain = $this->prepare_client($page);
810 if ($domain == $globals->mail
->domain ||
$domain == $globals->mail
->domain2
) {
815 $domain = '@' . $domain;
820 $page->changeTpl('lists/delete.tpl');
821 if (Post
::v('valid') == 'OUI') {
822 S
::assert_xsrf_token();
824 if ($this->client
->delete_list($liste, Post
::b('del_archive'))) {
825 foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) {
826 XDB
::execute("DELETE FROM $table
827 WHERE type={?} AND alias={?}",
828 $type, $liste.$app.$domain);
830 $page->assign('deleted', true
);
831 $page->trigSuccess('La liste a été détruite !');
833 $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
834 . 'Contact les administrateurs du site pour régler le problème : '
835 . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>.');
837 } elseif (list($details,$options) = $this->client
->get_owner_options($liste)) {
838 if (!$details['own']) {
839 $page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
841 $page->assign_by_ref('details', $details);
842 $page->assign_by_ref('options', $options);
843 $page->assign('bogo_level', $this->client
->get_bogo_level($liste));
845 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
849 function handler_soptions(&$page, $liste = null
)
851 if (is_null($liste)) {
855 $this->prepare_client($page);
857 $page->changeTpl('lists/soptions.tpl');
859 if (Post
::has('submit')) {
860 S
::assert_xsrf_token();
863 $values = array_map('utf8_decode', $values);
864 unset($values['submit']);
865 $values['advertised'] = empty($values['advertised']) ? false
: true
;
866 $values['archive'] = empty($values['archive']) ? false
: true
;
867 $this->client
->set_admin_options($liste, $values);
870 if (list($details,$options) = $this->client
->get_admin_options($liste)) {
871 $page->assign_by_ref('details', $details);
872 $page->assign_by_ref('options', $options);
874 $page->kill("La liste n'existe pas.");
878 function handler_check(&$page, $liste = null
)
880 if (is_null($liste)) {
884 $this->prepare_client($page);
886 $page->changeTpl('lists/check.tpl');
888 if (Post
::has('correct')) {
889 S
::assert_xsrf_token();
890 $this->client
->check_options($liste, true
);
893 if (list($details,$options) = $this->client
->check_options($liste)) {
894 $page->assign_by_ref('details', $details);
895 $page->assign_by_ref('options', $options);
897 $page->kill("La liste n'existe pas.");
901 function handler_admin_all(&$page)
903 $page->changeTpl('lists/admin_all.tpl');
904 $page->setTitle('Administration - Mailing lists');
906 $this->prepare_client($page);
907 $listes = $this->client
->get_all_lists();
908 $page->assign_by_ref('listes', $listes);
912 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: