7567fb5d436480e752019055a2dc3a06d8539de3
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 on_subscribe($forlife, $uid, $promo, $password)
51 $this->prepare_client(null
);
52 $this->client
->subscribe("promo$promo");
55 function prepare_client(&$page)
59 require_once dirname(__FILE__
).'/lists/lists.inc.php';
61 $this->client
= new MMList(S
::v('uid'), S
::v('password'));
62 return $globals->mail
->domain
;
65 function get_pending_ops($domain, $list)
67 list($subs,$mails) = $this->client
->get_pending_ops($list);
68 $res = XDB
::query("SELECT mid
70 WHERE ml = {?} AND domain = {?}",
72 $mids = $res->fetchColumn();
73 foreach ($mails as $key=>$mail) {
74 if (in_array($mail['id'], $mids)) {
78 return array($subs, $mails);
81 function handler_lists(&$page)
83 function filter_owner($list)
88 function filter_member($list)
93 $domain = $this->prepare_client($page);
95 $page->changeTpl('lists/index.tpl');
96 $page->addJsLink('ajax.js');
97 $page->assign('xorg_title','Polytechnique.org - Listes de diffusion');
100 if (Get
::has('del')) {
101 S
::assert_xsrf_token();
102 $this->client
->unsubscribe(Get
::v('del'));
103 pl_redirect('lists');
105 if (Get
::has('add')) {
106 S
::assert_xsrf_token();
107 $this->client
->subscribe(Get
::v('add'));
108 pl_redirect('lists');
110 if (Post
::has('promo_add')) {
111 S
::assert_xsrf_token();
113 $promo = Post
::i('promo_add');
114 if ($promo >= 1900 and $promo < 2100) {
115 $this->client
->subscribe("promo$promo");
117 $page->trigSuccess("promo incorrecte, il faut une promo sur 4 chiffres.");
121 $listes = $this->client
->get_lists();
122 $owner = array_filter($listes, 'filter_owner');
123 $listes = array_diff_key($listes, $owner);
124 $member = array_filter($listes, 'filter_member');
125 $listes = array_diff_key($listes, $member);
126 foreach ($owner as $key=>$liste) {
127 list($subs,$mails) = $this->get_pending_ops($domain, $liste['list']);
128 $owner[$key]['subscriptions'] = $subs;
129 $owner[$key]['mails'] = $mails;
131 $page->register_modifier('hdc', 'list_header_decode');
132 $page->assign_by_ref('owner', $owner);
133 $page->assign_by_ref('member', $member);
134 $page->assign_by_ref('public', $listes);
137 function handler_ajax(&$page, $list = null
)
139 header('Content-Type: text/html; charset="UTF-8"');
140 $domain = $this->prepare_client($page);
141 $page->changeTpl('lists/liste.inc.tpl', NO_SKIN
);
142 S
::assert_xsrf_token();
144 if (Get
::has('unsubscribe')) {
145 $this->client
->unsubscribe($list);
147 if (Get
::has('subscribe')) {
148 $this->client
->subscribe($list);
150 if (Get
::has('sadd')) { /* 4 = SUBSCRIBE */
151 $this->client
->handle_request($list, Get
::v('sadd'), 4, '');
153 if (Get
::has('mid')) {
154 $this->moderate_mail($domain, $list, Get
::i('mid'));
157 list($liste, $members, $owners) = $this->client
->get_members($list);
159 list($subs,$mails) = $this->get_pending_ops($domain, $list);
160 $liste['subscriptions'] = $subs;
161 $liste['mails'] = $mails;
163 $page->register_modifier('hdc', 'list_header_decode');
164 $page->assign_by_ref('liste', $liste);
167 function handler_create(&$page)
171 $page->changeTpl('lists/create.tpl');
173 $owners = preg_split("/[\s]+/", Post
::v('owners'), -1, PREG_SPLIT_NO_EMPTY
);
174 $members = preg_split("/[\s]+/", Post
::v('members'), -1, PREG_SPLIT_NO_EMPTY
);
176 // click on validate button 'add_owner_sub' or type <enter>
177 if (Post
::has('add_owner_sub') && Post
::has('add_owner')) {
178 require_once('user.func.inc.php');
179 // if we want to add an owner and then type <enter>, then both
180 // add_owner_sub and add_owner are filled.
181 $oforlifes = get_users_forlife_list(Post
::v('add_owner'), true
);
182 $mforlifes = get_users_forlife_list(Post
::v('add_member'), true
);
183 if (!is_null($oforlifes)) {
184 $owners = array_merge($owners, $oforlifes);
186 // if we want to add a member and then type <enter>, then
187 // add_owner_sub is filled, whereas add_owner is empty.
188 if (!is_null($mforlifes)) {
189 $members = array_merge($members, $mforlifes);
193 // click on validate button 'add_member_sub'
194 require_once('user.func.inc.php');
195 if (Post
::has('add_member_sub') && Post
::has('add_member')) {
196 $forlifes = get_users_forlife_list(Post
::v('add_member'), true
);
197 if (!is_null($forlifes)) {
198 $members = array_merge($members, $forlifes);
201 if (Post
::has('add_member_sub') && isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
202 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::v('forlife'), 'list.addmember', true
);
204 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
206 $forlifes = get_users_forlife_list($upload->getContents(), true
);
207 if (!is_null($forlifes)) {
208 $members = array_merge($members, $forlifes);
214 $owners = array_unique($owners);
216 $members = array_unique($members);
218 $page->assign('owners', join("\n", $owners));
219 $page->assign('members', join("\n", $members));
221 if (!Post
::has('submit')) {
224 S
::assert_xsrf_token();
227 $asso = Post
::v('asso');
228 $liste = Post
::v('liste');
231 $page->trigError('Le champ «adresse souhaitée» est vide.');
233 if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) {
234 $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.');
237 if (($asso == "binet") ||
($asso == "alias")) {
238 $promo = Post
::i('promo');
239 $domain = $promo . '.' . $globals->mail
->domain
;
241 if (($promo < 1921) ||
($promo > date('Y'))) {
242 $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.');
245 $new = $liste . '@' . $domain;
246 $res = XDB
::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
249 if ($asso == "groupex") {
250 $groupex_name = Post
::v('groupex_name');
252 $res_groupe = XDB
::query('SELECT mail_domain FROM groupex.asso WHERE nom={?}', $groupex_name);
253 $domain = $res_groupe->fetchOneCell();
256 $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.');
259 $new = $liste . '@' . $domain;
260 $res = XDB
::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new);
262 $res = XDB
::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
263 $domain = $globals->mail
->domain
;
267 $n = $res->fetchOneCell();
270 $page->trigError('L\'«adresse souhaitée» est déjà prise.');
273 if (!Post
::v('desc')) {
274 $page->trigError('Le sujet est vide.');
277 if (!count($owners)) {
278 $page->trigError('Il n\'y a pas de gestionnaire.');
281 if (count($members)<4) {
282 $page->trigError('Il n\'y a pas assez de membres.');
285 if (!$page->nb_errs()) {
286 $page->assign('created', true
);
287 require_once 'validations.inc.php';
288 $req = new ListeReq(S
::v('uid'), $asso, $liste, $domain,
289 Post
::v('desc'), Post
::i('advertise'),
290 Post
::i('modlevel'), Post
::i('inslevel'),
296 function handler_members(&$page, $liste = null
)
298 if (is_null($liste)) {
302 $this->prepare_client($page);
304 $page->changeTpl('lists/members.tpl');
306 if (Get
::has('del')) {
307 S
::assert_xsrf_token();
308 $this->client
->unsubscribe($liste);
309 pl_redirect('lists/members/'.$liste);
312 if (Get
::has('add')) {
313 S
::assert_xsrf_token();
314 $this->client
->subscribe($liste);
315 pl_redirect('lists/members/'.$liste);
318 $members = $this->client
->get_members($liste);
320 $tri_promo = !Env
::b('alpha');
322 if (list($det,$mem,$own) = $members) {
323 $membres = list_sort_members($mem, $tri_promo);
324 $moderos = list_sort_owners($own, $tri_promo);
326 $page->assign_by_ref('details', $det);
327 $page->assign_by_ref('members', $membres);
328 $page->assign_by_ref('owners', $moderos);
329 $page->assign('nb_m', count($mem));
331 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
335 function handler_annu(&$page, $liste = null
, $action = null
, $subaction = null
)
337 if (is_null($liste)) {
341 $this->prepare_client($page);
343 if (Get
::has('del')) {
344 S
::assert_xsrf_token();
345 $this->client
->unsubscribe($liste);
346 pl_redirect('lists/annu/'.$liste);
348 if (Get
::has('add')) {
349 S
::assert_xsrf_token();
350 $this->client
->subscribe($liste);
351 pl_redirect('lists/annu/'.$liste);
354 $owners = $this->client
->get_owners($liste);
355 if (!is_array($owners)) {
356 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
360 list(,$members) = $this->client
->get_members($liste);
362 foreach ($members as $m) {
365 require_once 'userset.inc.php';
366 $view = new ArraySet($users);
367 $view->addMod('trombi', 'Trombinoscope', true
, array('with_promo' => true
));
368 if (empty($GLOBALS['IS_XNET_SITE'])) {
369 $view->addMod('minifiche', 'Mini-fiches', false
);
371 $view->addMod('geoloc', 'Planisphère');
372 $view->apply("lists/annu/$liste", $page, $action, $subaction);
373 if ($action == 'geoloc' && $subaction) {
377 $page->changeTpl('lists/annu.tpl');
378 $moderos = list_sort_owners($owners[1]);
379 $page->assign_by_ref('details', $owners[0]);
380 $page->assign_by_ref('owners', $moderos);
383 function handler_archives(&$page, $liste = null
, $action = null
, $artid = null
)
387 if (is_null($liste)) {
391 $domain = $this->prepare_client($page);
393 $page->changeTpl('lists/archives.tpl');
395 if (list($det) = $this->client
->get_members($liste)) {
396 if (substr($liste,0,5) != 'promo' && ($det['ins'] ||
$det['priv'])
397 && !$det['own'] && ($det['sub'] < 2)) {
398 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
400 $get = Array('listname' => $liste, 'domain' => $domain);
401 if (Post
::has('updateall')) {
402 $get['updateall'] = Post
::v('updateall');
404 require_once 'banana/ml.inc.php';
405 get_banana_params($get, null
, $action, $artid);
406 run_banana($page, 'MLBanana', $get);
408 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter.");
412 function handler_rss(&$page, $liste = null
, $alias = null
, $hash = null
)
414 require_once('rss.inc.php');
415 $uid = init_rss(null
, $alias, $hash);
416 if (!$uid ||
!$liste) {
420 $res = XDB
::query("SELECT user_id AS uid, password, alias AS forlife
421 FROM auth_user_md5 AS u
422 INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie')
423 WHERE u.user_id = {?}", $uid);
424 $row = $res->fetchOneAssoc();
425 $_SESSION = array_merge($row, $_SESSION);
427 $domain = $this->prepare_client($page);
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)) {
433 require_once('banana/ml.inc.php');
434 $banana = new MLBanana(S
::v('forlife'), Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
440 function moderate_mail($domain, $liste, $mid)
442 if (Env
::has('mok')) {
444 } elseif (Env
::has('mno')) {
446 } elseif (Env
::has('mdel')) {
452 return XDB
::execute("INSERT IGNORE INTO ml_moderate
453 VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)",
454 $liste, $domain, $mid, S
::i('uid'), $action, Post
::v('reason'));
457 function handler_moderate(&$page, $liste = null
)
459 if (is_null($liste)) {
463 $domain = $this->prepare_client($page);
465 $page->changeTpl('lists/moderate.tpl');
467 $page->register_modifier('hdc', 'list_header_decode');
469 if (Env
::has('sadd') || Env
::has('sdel')) {
470 S
::assert_xsrf_token();
472 if (Env
::has('sadd')) { /* 4 = SUBSCRIBE */
473 $sub = $this->client
->get_pending_sub($liste, Env
::v('sadd'));
474 $this->client
->handle_request($liste,Env
::v('sadd'),4,'');
477 if (Post
::has('sdel')) { /* 2 = REJECT */
478 $sub = $this->client
->get_pending_sub($liste, Env
::v('sdel'));
479 $this->client
->handle_request($liste, Post
::v('sdel'), 2, utf8_decode(Post
::v('reason')));
483 $mailer = new PlMailer();
484 $mailer->setFrom("$liste-bounces@{$domain}");
485 $mailer->addTo("$liste-owner@{$domain}");
486 $mailer->addHeader('Reply-To', "$liste-owner@{$domain}");
487 $mailer->setSubject("L'inscription de {$sub['name']} a été $info");
488 $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S
::v('prenom') . ' '
489 . S
::v('nom') . '(' . S
::v('promo') . ")\n";
490 if (trim(Post
::v('reason'))) {
491 $text .= "\nLa raison invoquée est :\n" . Post
::v('reason');
493 $mailer->setTxtBody(wordwrap($text, 72));
496 if (Env
::has('sadd')) {
497 pl_redirect('lists/moderate/'.$liste);
501 if (Post
::has('moderate_mails') && Post
::has('select_mails')) {
502 S
::assert_xsrf_token();
504 $mails = array_keys(Post
::v('select_mails'));
505 foreach($mails as $mail) {
506 $this->moderate_mail($domain, $liste, $mail);
508 } elseif (Env
::has('mid')) {
509 if (Get
::has('mid') && !Env
::has('mok') && !Env
::has('mdel')) {
510 $page->changeTpl('lists/moderate_mail.tpl');
511 require_once('banana/moderate.inc.php');
512 $params = array('listname' => $liste, 'domain' => $domain,
513 'artid' => Get
::i('mid'), 'part' => Get
::v('part'), 'action' => Get
::v('action'));
514 $params['client'] = $this->client
;
515 run_banana($page, 'ModerationBanana', $params);
517 $msg = file_get_contents('/etc/mailman/fr/refuse.txt');
518 $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg);
519 $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg);
520 $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg);
521 $msg = str_replace("%(listname)s", $liste, $msg);
522 $page->assign('msg', $msg);
526 $mail = $this->moderate_mail($domain, $liste, Env
::i('mid'));
527 } elseif (Env
::has('sid')) {
528 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
529 foreach($subs as $user) {
530 if ($user['id'] == Env
::v('sid')) {
531 $page->changeTpl('lists/moderate_sub.tpl');
532 $page->assign('del_user', $user);
540 if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) {
541 foreach ($mails as $key=>$mail) {
542 $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']);
543 if ($mail['fromx']) {
544 $page->assign('with_fromx', true
);
546 $page->assign('with_nonfromx', true
);
549 $page->assign_by_ref('subs', $subs);
550 $page->assign_by_ref('mails', $mails);
552 $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer");
556 static public function no_login_callback($login)
558 require_once 'user.func.inc.php';
559 global $list_unregistered, $globals;
561 $users = get_not_registered_user($login, true
);
562 if ($users && $users->total()) {
563 if (!isset($list_unregistered)) {
564 $list_unregistered = array();
566 $list_unregistered[$login] = $users;
568 list($name, $dom) = @explode
('@', $login);
569 if ($dom == $globals->mail
->domain ||
$dom == $globals->mail
->domain2
) {
570 _default_user_callback($login);
575 function handler_admin(&$page, $liste = null
)
579 if (is_null($liste)) {
583 $domain = $this->prepare_client($page);
585 $page->changeTpl('lists/admin.tpl');
587 if (Env
::has('send_mark')) {
588 S
::assert_xsrf_token();
590 $actions = Env
::v('mk_action');
591 $uids = Env
::v('mk_uid');
592 $mails = Env
::v('mk_email');
593 foreach ($actions as $key=>$action) {
598 case 'marketu': case 'markets':
599 require_once 'emails.inc.php';
600 $mail = valide_email($mails[$key]);
601 if (isvalid_email_redirection($mail)) {
602 $from = ($action == 'marketu') ?
'user' : 'staff';
603 $market = Marketing
::get($uids[$key], $mail);
605 $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S
::v('uid'));
612 XDB
::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain)
613 VALUES ({?}, \'list\', {?}, {?})',
614 $uids[$key], $liste, $domain);
619 if (Env
::has('add_member')) {
620 S
::assert_xsrf_token();
622 require_once('user.func.inc.php');
623 $members = get_users_forlife_list(Env
::v('add_member'),
625 array('ListsModule', 'no_login_callback'));
626 $arr = $this->client
->mass_subscribe($liste, $members);
627 if (is_array($arr)) {
628 foreach($arr as $addr) {
629 $page->trigSuccess("{$addr[0]} inscrit.");
634 if (isset($_FILES['add_member_file']) && $_FILES['add_member_file']['tmp_name']) {
635 S
::assert_xsrf_token();
637 $upload =& PlUpload
::get($_FILES['add_member_file'], S
::v('forlife'), 'list.addmember', true
);
639 $page->trigError('Une erreur s\'est produite lors du téléchargement du fichier');
641 $members = get_users_forlife_list($upload->getContents(),
643 array('ListsModule', 'no_login_callback'));
644 $arr = $this->client
->mass_subscribe($liste, $members);
645 if (is_array($arr)) {
646 foreach($arr as $addr) {
647 $page->trigSuccess("{$addr[0]} inscrit.");
653 if (Env
::has('del_member')) {
654 S
::assert_xsrf_token();
656 if (strpos(Env
::v('del_member'), '@') === false
) {
657 $this->client
->mass_unsubscribe(
658 $liste, array(Env
::v('del_member').'@'.$globals->mail
->domain
));
660 $this->client
->mass_unsubscribe($liste, array(Env
::v('del_member')));
662 pl_redirect('lists/admin/'.$liste);
665 if (Env
::has('add_owner')) {
666 S
::assert_xsrf_token();
668 require_once('user.func.inc.php');
669 $owners = get_users_forlife_list(Env
::v('add_owner'), false
, array('ListsModule', 'no_login_callback'));
671 foreach ($owners as $login) {
672 if ($this->client
->add_owner($liste, $login)) {
673 $page->trigSuccess($alias." ajouté aux modérateurs.");
679 if (Env
::has('del_owner')) {
680 S
::assert_xsrf_token();
682 if (strpos(Env
::v('del_owner'), '@') === false
) {
683 $this->client
->del_owner($liste, Env
::v('del_owner').'@'.$globals->mail
->domain
);
685 $this->client
->del_owner($liste, Env
::v('del_owner'));
687 pl_redirect('lists/admin/'.$liste);
690 if (list($det,$mem,$own) = $this->client
->get_members($liste)) {
691 global $list_unregistered;
692 if ($list_unregistered) {
693 $page->assign_by_ref('unregistered', $list_unregistered);
695 $membres = list_sort_members($mem, @$tri_promo);
696 $moderos = list_sort_owners($own, @$tri_promo);
698 $page->assign_by_ref('details', $det);
699 $page->assign_by_ref('members', $membres);
700 $page->assign_by_ref('owners', $moderos);
701 $page->assign('np_m', count($mem));
704 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.<br />"
705 ." Si tu penses qu'il s'agit d'une erreur, "
706 ."<a href='mailto:support@polytechnique.org'>contact le support</a>");
710 function handler_options(&$page, $liste = null
)
712 if (is_null($liste)) {
716 $this->prepare_client($page);
718 $page->changeTpl('lists/options.tpl');
720 if (Post
::has('submit')) {
721 S
::assert_xsrf_token();
724 $values = array_map('utf8_decode', $values);
725 $spamlevel = intval($values['bogo_level']);
726 $unsurelevel = intval($values['unsure_level']);
727 if ($spamlevel == 0) {
730 if ($spamlevel > 3 ||
$spamlevel < 0 ||
$unsurelevel < 0 ||
$unsurelevel > 1) {
731 $page->trigError("Réglage de l'antispam non valide");
733 $this->client
->set_bogo_level($liste, ($spamlevel << 1) +
$unsurelevel);
735 switch($values['moderate']) {
737 $values['generic_nonmember_action'] = 0;
738 $values['default_member_moderation'] = 0;
741 $values['generic_nonmember_action'] = 1;
742 $values['default_member_moderation'] = 0;
745 $values['generic_nonmember_action'] = 1;
746 $values['default_member_moderation'] = 1;
749 unset($values['submit'], $values['bogo_level'], $values['moderate']);
750 $values['send_goodbye_msg'] = !empty($values['send_goodbye_msg']);
751 $values['admin_notify_mchanges'] = !empty($values['admin_notify_mchanges']);
752 $values['subscribe_policy'] = empty($values['subscribe_policy']) ?
0 : 2;
753 if (isset($values['subject_prefix'])) {
754 $values['subject_prefix'] = trim($values['subject_prefix']).' ';
756 $this->client
->set_owner_options($liste, $values);
757 } elseif (isvalid_email(Post
::v('atn_add'))) {
758 S
::assert_xsrf_token();
759 $this->client
->add_to_wl($liste, Post
::v('atn_add'));
760 } elseif (Get
::has('atn_del')) {
761 S
::assert_xsrf_token();
762 $this->client
->del_from_wl($liste, Get
::v('atn_del'));
763 pl_redirect('lists/options/'.$liste);
766 if (list($details,$options) = $this->client
->get_owner_options($liste)) {
767 $page->assign_by_ref('details', $details);
768 $page->assign_by_ref('options', $options);
769 $bogo_level = intval($this->client
->get_bogo_level($liste));
770 $page->assign('unsure_level', $bogo_level & 1);
771 $page->assign('bogo_level', $bogo_level >> 1);
773 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
777 function handler_delete(&$page, $liste = null
)
780 if (is_null($liste)) {
784 $domain = $this->prepare_client($page);
785 if ($domain == $globals->mail
->domain ||
$domain == $globals->mail
->domain2
) {
790 $domain = '@' . $domain;
795 $page->changeTpl('lists/delete.tpl');
796 if (Post
::v('valid') == 'OUI') {
797 S
::assert_xsrf_token();
799 if ($this->client
->delete_list($liste, Post
::b('del_archive'))) {
800 foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) {
801 XDB
::execute("DELETE FROM $table
802 WHERE type={?} AND alias={?}",
803 $type, $liste.$app.$domain);
805 $page->assign('deleted', true
);
807 $page->kill('Une erreur est survenue lors de la suppression de la liste.<br />'
808 . 'Contact les administrateurs du site pour régler le problème : '
809 . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
811 } elseif (list($details,$options) = $this->client
->get_owner_options($liste)) {
812 $page->assign_by_ref('details', $details);
813 $page->assign_by_ref('options', $options);
814 $page->assign('bogo_level', $this->client
->get_bogo_level($liste));
816 $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer");
820 function handler_soptions(&$page, $liste = null
)
822 if (is_null($liste)) {
826 $this->prepare_client($page);
828 $page->changeTpl('lists/soptions.tpl');
830 if (Post
::has('submit')) {
831 S
::assert_xsrf_token();
834 $values = array_map('utf8_decode', $values);
835 unset($values['submit']);
836 $values['advertised'] = empty($values['advertised']) ? false
: true
;
837 $values['archive'] = empty($values['archive']) ? false
: true
;
838 $this->client
->set_admin_options($liste, $values);
841 if (list($details,$options) = $this->client
->get_admin_options($liste)) {
842 $page->assign_by_ref('details', $details);
843 $page->assign_by_ref('options', $options);
845 $page->kill("La liste n'existe pas");
849 function handler_check(&$page, $liste = null
)
851 if (is_null($liste)) {
855 $this->prepare_client($page);
857 $page->changeTpl('lists/check.tpl');
859 if (Post
::has('correct')) {
860 S
::assert_xsrf_token();
861 $this->client
->check_options($liste, true
);
864 if (list($details,$options) = $this->client
->check_options($liste)) {
865 $page->assign_by_ref('details', $details);
866 $page->assign_by_ref('options', $options);
868 $page->kill("La liste n'existe pas");
872 function handler_admin_all(&$page) {
873 $page->changeTpl('lists/admin_all.tpl');
874 $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
876 $client = new MMList(S
::v('uid'), S
::v('password'));
877 $listes = $client->get_all_lists();
878 $page->assign_by_ref('listes', $listes);
882 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: