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 require_once 'validations.inc.php';
305 $req = new ListeReq(S
::user(), $asso, $liste, $domain,
306 Post
::v('desc'), Post
::i('advertise'),
307 Post
::i('modlevel'), Post
::i('inslevel'),
313 function handler_members(&$page, $liste = null
)
315 if (is_null($liste)) {
319 $this->prepare_client($page);
321 $page->changeTpl('lists/members.tpl');
323 if (Get
::has('del')) {
324 S
::assert_xsrf_token();
325 $this->client
->unsubscribe($liste);
326 pl_redirect('lists/members/'.$liste);
329 if (Get
::has('add')) {
330 S
::assert_xsrf_token();
331 $this->client
->subscribe($liste);
332 pl_redirect('lists/members/'.$liste);
335 $members = $this->client
->get_members($liste);
337 $tri_promo = !Env
::b('alpha');
339 if (list($det,$mem,$own) = $members) {
340 $membres = list_sort_members($mem, $tri_promo);
341 $moderos = list_sort_owners($own, $tri_promo);
343 $page->assign_by_ref('details', $det);
344 $page->assign_by_ref('members', $membres);
345 $page->assign_by_ref('owners', $moderos);
346 $page->assign('nb_m', count($mem));
348 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
352 function handler_csv(PlPage
&$page, $liste = null
)
354 if (is_null($liste)) {
357 $this->prepare_client($page);
358 $members = $this->client
->get_members($liste);
359 $list = list_fetch_basic_info(list_extract_members($members[1]));
360 pl_content_headers("text/x-csv");
362 echo "email,nom,promo\n";
363 echo implode("\n", $list);
367 function handler_annu(&$page, $liste = null
, $action = null
, $subaction = null
)
369 if (is_null($liste)) {
373 $this->prepare_client($page);
375 if (Get
::has('del')) {
376 S
::assert_xsrf_token();
377 $this->client
->unsubscribe($liste);
378 pl_redirect('lists/annu/'.$liste);
380 if (Get
::has('add')) {
381 S
::assert_xsrf_token();
382 $this->client
->subscribe($liste);
383 pl_redirect('lists/annu/'.$liste);
386 $owners = $this->client
->get_owners($liste);
387 if (!is_array($owners)) {
388 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails.");
392 list(,$members) = $this->client
->get_members($liste);
394 foreach ($members as $m) {
397 require_once 'userset.inc.php';
398 $view = new ArraySet($users);
399 $view->addMod('trombi', 'Trombinoscope', true
, array('with_promo' => true
));
400 if (empty($GLOBALS['IS_XNET_SITE'])) {
401 $view->addMod('minifiche', 'Mini-fiches', false
);
403 // TODO: Reactivate when the new map is completed.
404 // $view->addMod('geoloc', 'Planisphère');
405 $view->apply("lists/annu/$liste", $page, $action, $subaction);
406 if ($action == 'geoloc' && $subaction) {
410 $page->changeTpl('lists/annu.tpl');
411 $moderos = list_sort_owners($owners[1]);
412 $page->assign_by_ref('details', $owners[0]);
413 $page->assign_by_ref('owners', $moderos);
416 function handler_archives(&$page, $liste = null
, $action = null
, $artid = null
)
420 if (is_null($liste)) {
424 $domain = $this->prepare_client($page);
426 $page->changeTpl('lists/archives.tpl');
428 if (list($det) = $this->client
->get_members($liste)) {
429 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
430 && !$det['own'] && ($det['sub'] < 2)) {
431 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
433 $get = Array('listname' => $liste, 'domain' => $domain);
434 if (Post
::has('updateall')) {
435 $get['updateall'] = Post
::v('updateall');
437 require_once 'banana/ml.inc.php';
438 get_banana_params($get, null
, $action, $artid);
439 run_banana($page, 'MLBanana', $get);
441 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
445 function handler_rss(&$page, $liste = null
, $alias = null
, $hash = null
)
450 $user = Platal
::session()->tokenAuth($alias, $hash);
451 if (is_null($user)) {
455 $domain = $this->prepare_client($page, $user);
456 if (list($det) = $this->client
->get_members($liste)) {
457 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
458 && !$det['own'] && ($det['sub'] < 2)) {
461 require_once('banana/ml.inc.php');
462 $banana = new MLBanana($user, Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
468 function moderate_mail($domain, $liste, $mid)
470 if (Env
::has('mok')) {
472 } elseif (Env
::has('mno')) {
474 } elseif (Env
::has('mdel')) {
480 return XDB
::execute("INSERT IGNORE INTO email_list_moderate
481 VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
482 $liste, $domain, $mid, S
::i('uid'), $action, Post
::v('reason'));
485 function handler_moderate(&$page, $liste = null
)
487 if (is_null($liste)) {
491 $domain = $this->prepare_client($page);
493 $page->changeTpl('lists/moderate.tpl');
495 $page->register_modifier('hdc', 'list_header_decode');
497 if (Env
::has('sadd') || Env
::has('sdel')) {
498 S
::assert_xsrf_token();
500 if (Env
::has('sadd')) { /* 4 = SUBSCRIBE */
501 $sub = $this->client
->get_pending_sub($liste, Env
::v('sadd'));
502 $this->client
->handle_request($liste,Env
::v('sadd'),4,'');
505 if (Post
::has('sdel')) { /* 2 = REJECT */
506 $sub = $this->client
->get_pending_sub($liste, Env
::v('sdel'));
507 $this->client
->handle_request($liste, Post
::v('sdel'), 2, utf8_decode(Post
::v('reason')));
511 $mailer = new PlMailer();
512 $mailer->setFrom("$liste-bounces@{$domain}");
513 $mailer->addTo("$liste-owner@{$domain}");
514 $mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
515 $mailer->setSubject("L'inscription de {$sub['name']} a été $info");
516 $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S
::v('prenom') . ' '
517 . S
::v('nom') . '(' . S
::v('promo') . ")\n";
518 if (trim(Post
::v('reason'))) {
519 $text .= "\nLa raison invoquée est :\n" . Post
::v('reason');
521 $mailer->setTxtBody(wordwrap($text, 72));
524 if (Env
::has('sadd')) {
525 pl_redirect('lists/moderate/'.$liste);
529 if (Post
::has('moderate_mails') && Post
::has('select_mails')) {
530 S
::assert_xsrf_token();
532 $mails = array_keys(Post
::v('select_mails'));
533 foreach($mails as $mail) {
534 $this->moderate_mail($domain, $liste, $mail);
536 } elseif (Env
::has('mid')) {
537 if (Get
::has('mid') && !Env
::has('mok') && !Env
::has('mdel')) {
538 require_once 'banana/moderate.inc.php';
540 $page->changeTpl('lists/moderate_mail.tpl');
541 $params = array('listname' => $liste, 'domain' => $domain,
542 'artid' => Get
::i('mid'), 'part' => Get
::v('part'), 'action' => Get
::v('action'));
543 $params['client'] = $this->client
;
544 run_banana($page, 'ModerationBanana', $params);
546 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
547 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
548 $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
549 $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
550 $msg = str_replace("%(listname)s", $liste, $msg);
551 $page->assign('msg', $msg);
555 $this->moderate_mail($domain, $liste, Env
::i('mid'));
556 } elseif (Env
::has('sid')) {
557 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
558 foreach($subs as $user) {
559 if ($user['id'] == Env
::v('sid')) {
560 $page->changeTpl('lists/moderate_sub.tpl');
561 $page->assign('del_user', $user);
569 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
570 foreach ($mails as $key=>$mail) {
571 $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
572 if ($mail['fromx']) {
573 $page->assign('with_fromx', true
);
575 $page->assign('with_nonfromx', true
);
578 $page->assign_by_ref('subs', $subs);
579 $page->assign_by_ref('mails', $mails);
581 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer.");
585 static public function no_login_callback($login)
587 global $list_unregistered, $globals;
589 $users = User
::getPendingAccounts($login, true
);
590 if ($users && $users->total()) {
591 if (!isset($list_unregistered)) {
592 $list_unregistered = array();
594 $list_unregistered[$login] = $users;
596 list($name, $dom) = @explode
('@', $login);
597 if ($dom == $globals->mail
->domain ||
$dom == $globals->mail
->domain2
) {
598 User
::_default_user_callback($login);
603 function handler_admin(&$page, $liste = null
)
607 if (is_null($liste)) {
611 $domain = $this->prepare_client($page);
613 $page->changeTpl('lists/admin.tpl');
615 if (Env
::has('send_mark')) {
616 S
::assert_xsrf_token();
618 $actions = Env
::v('mk_action');
619 $uids = Env
::v('mk_uid');
620 $mails = Env
::v('mk_email');
621 foreach ($actions as $key=>$action) {
626 case 'marketu': case 'markets':
627 require_once 'emails.inc.php';
628 $mail = valide_email($mails[$key]);
629 if (isvalid_email_redirection($mail)) {
630 $from = ($action == 'marketu') ?
'user' : 'staff';
631 $market = Marketing
::get($uids[$key], $mail);
633 $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S
::v('uid'));
640 XDB
::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain)
641 VALUES ({?}, \'list\', {?}, {?})',
642 $uids[$key], $liste, $domain);
647 if (Env
::has('add_member')) {
648 S
::assert_xsrf_token();
650 $members = User
::getBulkForlifeEmails(Env
::v('add_member'),
652 array('ListsModule', 'no_login_callback'));
653 $arr = $this->client
->mass_subscribe($liste, $members);
654 if (is_array($arr)) {
655 foreach($arr as $addr) {
656 $page->trigSuccess("{$addr[0]} inscrit.");
661 if (isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
662 S
::assert_xsrf_token();
664 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::user()->login(), 'list.addmember', true
);
666 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
668 $members = User
::getBulkForlifeEmails($upload->getContents(),
670 array('ListsModule', 'no_login_callback'));
671 $arr = $this->client
->mass_subscribe($liste, $members);
672 if (is_array($arr)) {
673 foreach($arr as $addr) {
674 $page->trigSuccess("{$addr[0]} inscrit.");
680 if (Env
::has('del_member')) {
681 S
::assert_xsrf_token();
683 if (strpos(Env
::v('del_member'), '@') === false
) {
684 $this->client
->mass_unsubscribe(
685 $liste, array(Env
::v('del_member').'@'.$globals->mail
->domain
));
687 $this->client
->mass_unsubscribe($liste, array(Env
::v('del_member')));
689 pl_redirect('lists/admin/'.$liste);
692 if (Env
::has('add_owner')) {
693 S
::assert_xsrf_token();
695 $owners = User
::getBulkForlifeEmails(Env
::v('add_owner'), false
, array('ListsModule', 'no_login_callback'));
697 foreach ($owners as $login) {
698 if ($this->client
->add_owner($liste, $login)) {
699 $page->trigSuccess($login ." ajouté aux modérateurs.");
705 if (Env
::has('del_owner')) {
706 S
::assert_xsrf_token();
708 if (strpos(Env
::v('del_owner'), '@') === false
) {
709 $this->client
->del_owner($liste, Env
::v('del_owner').'@'.$globals->mail
->domain
);
711 $this->client
->del_owner($liste, Env
::v('del_owner'));
713 pl_redirect('lists/admin/'.$liste);
716 if (list($det,$mem,$own) = $this->client
->get_members($liste)) {
717 global $list_unregistered;
718 if ($list_unregistered) {
719 $page->assign_by_ref('unregistered', $list_unregistered);
721 $membres = list_sort_members($mem, @$tri_promo);
722 $moderos = list_sort_owners($own, @$tri_promo);
724 $page->assign_by_ref('details', $det);
725 $page->assign_by_ref('members', $membres);
726 $page->assign_by_ref('owners', $moderos);
727 $page->assign('np_m', count($mem));
730 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.<br />"
731 . " Si tu penses qu'il s'agit d'une erreur, "
732 . "<a href='mailto:support@polytechnique.org'>contact le support</a>.");
736 function handler_options(&$page, $liste = null
)
738 if (is_null($liste)) {
742 $this->prepare_client($page);
744 $page->changeTpl('lists/options.tpl');
746 if (Post
::has('submit')) {
747 S
::assert_xsrf_token();
750 $values = array_map('utf8_decode', $values);
751 $spamlevel = intval($values['bogo_level']);
752 $unsurelevel = intval($values['unsure_level']);
753 if ($spamlevel == 0) {
756 if ($spamlevel > 3 ||
$spamlevel < 0 ||
$unsurelevel < 0 ||
$unsurelevel > 1) {
757 $page->trigError("Réglage de l'antispam non valide");
759 $this->client
->set_bogo_level($liste, ($spamlevel << 1) +
$unsurelevel);
761 switch($values['moderate']) {
763 $values['generic_nonmember_action'] = 0;
764 $values['default_member_moderation'] = 0;
767 $values['generic_nonmember_action'] = 1;
768 $values['default_member_moderation'] = 0;
771 $values['generic_nonmember_action'] = 1;
772 $values['default_member_moderation'] = 1;
775 unset($values['submit'], $values['bogo_level'], $values['moderate']);
776 $values['send_goodbye_msg'] = !empty($values['send_goodbye_msg']);
777 $values['admin_notify_mchanges'] = !empty($values['admin_notify_mchanges']);
778 $values['subscribe_policy'] = empty($values['subscribe_policy']) ?
0 : 2;
779 if (isset($values['subject_prefix'])) {
780 $values['subject_prefix'] = trim($values['subject_prefix']).' ';
782 $this->client
->set_owner_options($liste, $values);
783 } elseif (isvalid_email(Post
::v('atn_add'))) {
784 S
::assert_xsrf_token();
785 $this->client
->add_to_wl($liste, Post
::v('atn_add'));
786 } elseif (Get
::has('atn_del')) {
787 S
::assert_xsrf_token();
788 $this->client
->del_from_wl($liste, Get
::v('atn_del'));
789 pl_redirect('lists/options/'.$liste);
792 if (list($details,$options) = $this->client
->get_owner_options($liste)) {
793 $page->assign_by_ref('details', $details);
794 $page->assign_by_ref('options', $options);
795 $bogo_level = intval($this->client
->get_bogo_level($liste));
796 $page->assign('unsure_level', $bogo_level & 1);
797 $page->assign('bogo_level', $bogo_level >> 1);
799 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
803 function handler_delete(&$page, $liste = null
)
806 if (is_null($liste)) {
810 $domain = $this->prepare_client($page);
811 if ($domain == $globals->mail
->domain ||
$domain == $globals->mail
->domain2
) {
816 $domain = '@' . $domain;
821 $page->changeTpl('lists/delete.tpl');
822 if (Post
::v('valid') == 'OUI') {
823 S
::assert_xsrf_token();
825 if ($this->client
->delete_list($liste, Post
::b('del_archive'))) {
826 foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) {
827 XDB
::execute("DELETE FROM $table
828 WHERE type={?} AND alias={?}",
829 $type, $liste.$app.$domain);
831 $page->assign('deleted', true
);
832 $page->trigSuccess('La liste a été détruite !');
834 $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
835 . 'Contact les administrateurs du site pour régler le problème : '
836 . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>.');
838 } elseif (list($details,$options) = $this->client
->get_owner_options($liste)) {
839 if (!$details['own']) {
840 $page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
842 $page->assign_by_ref('details', $details);
843 $page->assign_by_ref('options', $options);
844 $page->assign('bogo_level', $this->client
->get_bogo_level($liste));
846 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
850 function handler_soptions(&$page, $liste = null
)
852 if (is_null($liste)) {
856 $this->prepare_client($page);
858 $page->changeTpl('lists/soptions.tpl');
860 if (Post
::has('submit')) {
861 S
::assert_xsrf_token();
864 $values = array_map('utf8_decode', $values);
865 unset($values['submit']);
866 $values['advertised'] = empty($values['advertised']) ? false
: true
;
867 $values['archive'] = empty($values['archive']) ? false
: true
;
868 $this->client
->set_admin_options($liste, $values);
871 if (list($details,$options) = $this->client
->get_admin_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_check(&$page, $liste = null
)
881 if (is_null($liste)) {
885 $this->prepare_client($page);
887 $page->changeTpl('lists/check.tpl');
889 if (Post
::has('correct')) {
890 S
::assert_xsrf_token();
891 $this->client
->check_options($liste, true
);
894 if (list($details,$options) = $this->client
->check_options($liste)) {
895 $page->assign_by_ref('details', $details);
896 $page->assign_by_ref('options', $options);
898 $page->kill("La liste n'existe pas.");
902 function handler_admin_all(&$page)
904 $page->changeTpl('lists/admin_all.tpl');
905 $page->setTitle('Administration - Mailing lists');
907 $this->prepare_client($page);
908 $listes = $this->client
->get_all_lists();
909 $page->assign_by_ref('listes', $listes);
913 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: