X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=16d7de9de70d42d7f024eb21a39f70c0ceec698a;hb=59887c4a8a1f014c1f4107c43deda0d1be994f5d;hp=8266f502d8e6b2dcd7d0013a0fbf38a9ceb9a07b;hpb=383eaddda17da5a11b67b82306248e7b2ebe4457;p=platal.git diff --git a/modules/lists.php b/modules/lists.php index 8266f50..16d7de9 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -1,6 +1,6 @@ $this->make_hook('lists', AUTH_MDP), - 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, '', NO_AUTH), + 'lists/ajax' => $this->make_hook('ajax', AUTH_MDP, 'user', NO_AUTH), 'lists/create' => $this->make_hook('create', AUTH_MDP), 'lists/members' => $this->make_hook('members', AUTH_COOKIE), - 'lists/trombi' => $this->make_hook('trombi', AUTH_COOKIE), + 'lists/annu' => $this->make_hook('annu', AUTH_COOKIE), 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE), + 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS), 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP), 'lists/admin' => $this->make_hook('admin', AUTH_MDP), @@ -41,7 +42,7 @@ class ListsModule extends PLModule 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP), 'lists/check' => $this->make_hook('check', AUTH_MDP), - 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'), + 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'), ); } @@ -61,15 +62,20 @@ class ListsModule extends PLModule return $globals->mail->domain; } - function clean_html($res) + function get_pending_ops($domain, $list) { - $res = html_entity_decode($res); - $res = preg_replace('@]*href=["\']([^ >]+)["\'][^>]*>([^<]*)@ie', - "'\\2 [' . htmlentities('\\1') . ']'", $res); - $res = preg_replace("@<(/br|p|/div)[^>]*>(\\s*\n)?@i", "\n", $res); - $res = trim(strip_tags($res)); - $res = preg_replace("/\n(\\s*\n)+/", "\n\n", $res); - return $res; + list($subs,$mails) = $this->client->get_pending_ops($list); + $res = XDB::query("SELECT mid + FROM ml_moderate + WHERE ml = {?} AND domain = {?}", + $list, $domain); + $mids = $res->fetchColumn(); + foreach ($mails as $key=>$mail) { + if (in_array($mail['id'], $mids)) { + unset($mails[$key]); + } + } + return array($subs, $mails); } function handler_lists(&$page) @@ -84,9 +90,9 @@ class ListsModule extends PLModule return $list['sub']; } - $this->prepare_client($page); + $domain = $this->prepare_client($page); - $page->changeTpl('listes/index.tpl'); + $page->changeTpl('lists/index.tpl'); $page->addJsLink('ajax.js'); $page->assign('xorg_title','Polytechnique.org - Listes de diffusion'); @@ -104,7 +110,7 @@ class ListsModule extends PLModule if ($promo >= 1900 and $promo < 2100) { $this->client->subscribe("promo$promo"); } else { - $page->trig("promo incorrecte, il faut une promo sur 4 chiffres."); + $page->trigSuccess("promo incorrecte, il faut une promo sur 4 chiffres."); } } $listes = $this->client->get_lists(); @@ -113,7 +119,7 @@ class ListsModule extends PLModule $member = array_filter($listes, 'filter_member'); $listes = array_diff_key($listes, $member); foreach ($owner as $key=>$liste) { - list($subs,$mails) = $this->client->get_pending_ops($liste['list']); + list($subs,$mails) = $this->get_pending_ops($domain, $liste['list']); $owner[$key]['subscriptions'] = $subs; $owner[$key]['mails'] = $mails; } @@ -125,9 +131,9 @@ class ListsModule extends PLModule function handler_ajax(&$page, $list = null) { - header('Content-Type: text/html; charset="iso-8859-15"'); + header('Content-Type: text/html; charset="UTF-8"'); $domain = $this->prepare_client($page); - $page->changeTpl('listes/liste.inc.tpl', NO_SKIN); + $page->changeTpl('lists/liste.inc.tpl', NO_SKIN); if (Get::has('unsubscribe')) { $this->client->unsubscribe($list); } @@ -143,7 +149,7 @@ class ListsModule extends PLModule list($liste, $members, $owners) = $this->client->get_members($list); if ($liste['own']) { - list($subs,$mails) = $this->client->get_pending_ops($list); + list($subs,$mails) = $this->get_pending_ops($domain, $list); $liste['subscriptions'] = $subs; $liste['mails'] = $mails; } @@ -153,7 +159,7 @@ class ListsModule extends PLModule function handler_create(&$page) { - $page->changeTpl('listes/create.tpl'); + $page->changeTpl('lists/create.tpl'); $owners = preg_split("/[\s]+/", Post::v('owners'), -1, PREG_SPLIT_NO_EMPTY); $members = preg_split("/[\s]+/", Post::v('members'), -1, PREG_SPLIT_NO_EMPTY); @@ -196,38 +202,68 @@ class ListsModule extends PLModule return; } + $asso = Post::v('asso'); $liste = Post::v('liste'); if (empty($liste)) { - $page->trig('champs «addresse souhaitée» vide'); + $page->trigError('Le champ «adresse souhaitée» est vide.'); } if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) { - $page->trig('le nom de la liste ne doit contenir que des lettres, chiffres et tirets'); + $page->trigError('Le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets.'); + } + + if (($asso == "binet") || ($asso == "alias")) { + $promo = Post::i('promo'); + $domain = $promo . '.polytechnique.org'; + + if (($promo < 1921) || ($promo > date('Y'))) { + $page->trigError('La promotion est mal renseignée, elle doit être du type : 2004.'); + } + + $new = $liste . '@' . $domain; + $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); + + } else { + if ($asso == "groupex") { + $groupex_name = Post::v('groupex_name'); + + $res_groupe = XDB::query('SELECT mail_domain FROM groupex.asso WHERE nom={?}', $groupex_name); + $domain = $res_groupe->fetchOneCell(); + + if (!$domain) { + $page->trigError('Il n\'y a aucun groupe de ce nom sur Polytechnique.net.'); + } + + $new = $liste . '@' . $domain; + $res = XDB::query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); + } else { + $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); + $domain = "polytechnique.org"; + } } - $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); - $n = $res->fetchOneCell(); + $n = $res->fetchOneCell(); if ($n) { - $page->trig('cet alias est déjà pris'); + $page->trigError('Cette «adresse souhaitée» est déjà prise.'); } - if (!Post::v(desc)) { - $page->trig('le sujet est vide'); + if (!Post::v('desc')) { + $page->trigError('Le sujet est vide.'); } if (!count($owners)) { - $page->trig('pas de gestionnaire'); + $page->trigError('Il n\'y a pas de gestionnaire.'); } if (count($members)<4) { - $page->trig('pas assez de membres'); + $page->trigError('Il n\'y a pas assez de membres.'); } if (!$page->nb_errs()) { $page->assign('created', true); require_once 'validations.inc.php'; - $req = new ListeReq(S::v('uid'), $liste, + $req = new ListeReq(S::v('uid'), $asso, $liste, $domain, Post::v('desc'), Post::i('advertise'), Post::i('modlevel'), Post::i('inslevel'), $owners, $members); @@ -243,7 +279,7 @@ class ListsModule extends PLModule $this->prepare_client($page); - $page->changeTpl('listes/members.tpl'); + $page->changeTpl('lists/members.tpl'); if (Get::has('del')) { $this->client->unsubscribe($liste); @@ -268,33 +304,11 @@ class ListsModule extends PLModule $page->assign_by_ref('owners', $moderos); $page->assign('nb_m', count($mem)); } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); - } - } - - function _get_list($offset, $limit) - { - global $platal; - list($total, $members) = $this->client->get_members_limit($platal->argv[1], $offset, $limit); - - $membres = Array(); - foreach ($members as $member) { - list($m) = explode('@',$member[1]); - $res = XDB::query("SELECT prenom,if (nom_usage='', nom, nom_usage) AS nom, - promo, a.alias AS forlife - FROM auth_user_md5 AS u - INNER JOIN aliases AS a ON u.user_id = a.id - WHERE a.alias = {?}", $m); - if ($tmp = $res->fetchOneAssoc()) { - $membres[$tmp['nom']] = $tmp; - } else { - $membres[$member[0]] = array('addr' => $member[0]); - } + $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); } - return array($total, $membres); } - function handler_trombi(&$page, $liste = null) + function handler_annu(&$page, $liste = null, $action = null, $subaction = null) { if (is_null($liste)) { return PL_NOT_FOUND; @@ -302,33 +316,45 @@ class ListsModule extends PLModule $this->prepare_client($page); - $page->changeTpl('listes/trombi.tpl'); - if (Get::has('del')) { $this->client->unsubscribe($liste); - pl_redirect('lists/tromi/'.$liste); + pl_redirect('lists/annu/'.$liste); } if (Get::has('add')) { $this->client->subscribe($liste); - pl_redirect('lists/tromi/'.$liste); + pl_redirect('lists/annu/'.$liste); } $owners = $this->client->get_owners($liste); + if (!is_array($owners)) { + $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); + } - if (is_array($owners)) { - $moderos = list_sort_owners($owners[1]); - - $page->assign_by_ref('details', $owners[0]); - $page->assign_by_ref('owners', $moderos); - - $trombi = new Trombi(array(&$this, '_get_list')); - $page->assign('trombi', $trombi); - } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); + global $platal; + list(,$members) = $this->client->get_members($liste); + $users = array(); + foreach ($members as $m) { + $users[] = $m[1]; + } + require_once 'userset.inc.php'; + $view = new ArraySet($users); + $view->addMod('trombi', 'Trombinoscope', true, array('with_promo' => true)); + if (empty($GLOBALS['IS_XNET_SITE'])) { + $view->addMod('minifiche', 'Minifiches', false); + } + $view->addMod('geoloc', 'Planisphère'); + $view->apply("lists/annu/$liste", $page, $action, $subaction); + if ($action == 'geoloc' && $subaction) { + return; } + + $page->changeTpl('lists/annu.tpl'); + $moderos = list_sort_owners($owners[1]); + $page->assign_by_ref('details', $owners[0]); + $page->assign_by_ref('owners', $moderos); } - function handler_archives(&$page, $liste = null) + function handler_archives(&$page, $liste = null, $action = null, $artid = null) { global $globals; @@ -338,105 +364,110 @@ class ListsModule extends PLModule $domain = $this->prepare_client($page); - $page->changeTpl('listes/archives.tpl'); + $page->changeTpl('lists/archives.tpl'); - $page->addCssLink('lists.archives.css'); if (list($det) = $this->client->get_members($liste)) { if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv']) - && !$det['own'] && ($det['sub'] < 2)) - { - $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); - } elseif (Get::has('file')) { - $file = Get::v('file'); - $rep = Get::v('rep'); - if (strstr('/', $file)!==false || !preg_match(',^\d+/\d+$,', $rep)) { - $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); - } else { - $page->assign('archives', $globals->lists->spool - ."/{$domain}{$globals->lists->vhost_sep}$liste/$rep/$file"); - } - } else { - $archs = Array(); - foreach (glob($globals->lists->spool - ."/{$domain}{$globals->lists->vhost_sep}$liste/*/*") as $rep) - { - if (preg_match(",/(\d*)/(\d*)$,", $rep, $matches)) { - $archs[intval($matches[1])][intval($matches[2])] = true; - } - } - $page->assign('archs', $archs); - $page->assign('range', range(1,12)); + && !$det['own'] && ($det['sub'] < 2)) { + $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter."); + } + $get = Array('listname' => $liste, 'domain' => $domain); + if (Post::has('updateall')) { + $get['updateall'] = Post::v('updateall'); } + require_once 'banana/ml.inc.php'; + get_banana_params($get, null, $action, $artid); + run_banana($page, 'MLBanana', $get); } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); + $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter."); } } - function moderate_mail($domain, $liste, $mid) + function handler_rss(&$page, $liste = null, $alias = null, $hash = null) { - $mail = $this->client->get_pending_mail($liste, $mid); - $reason = ''; + require_once('rss.inc.php'); + $uid = init_rss(null, $alias, $hash); + if (!$uid || !$liste) { + exit; + } - $prenom = S::v('prenom'); - $nom = S::v('nom'); + $res = XDB::query("SELECT user_id AS uid, password, alias AS forlife + FROM auth_user_md5 AS u + INNER JOIN aliases AS a ON (a.id = u.user_id AND a.type = 'a_vie') + WHERE u.user_id = {?}", $uid); + $row = $res->fetchOneAssoc(); + $_SESSION = array_merge($row, $_SESSION); + $domain = $this->prepare_client($page); + if (list($det) = $this->client->get_members($liste)) { + if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv']) + && !$det['own'] && ($det['sub'] < 2)) { + exit; + } + require_once('banana/ml.inc.php'); + $banana = new MLBanana(S::v('forlife'), Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2')); + $banana->run(); + } + exit; + } + + function moderate_mail($domain, $liste, $mid) + { if (Env::has('mok')) { - $action = 1; /** 2 = ACCEPT **/ - $subject = "Message accepté"; - $append .= "a été accepté par $prenom $nom.\n"; + $action = 'accept'; } elseif (Env::has('mno')) { - $action = 2; /** 2 = REJECT **/ - $subject = "Message refusé"; - $reason = Post::v('reason'); - $append = "a été refusé par $prenom $nom avec la raison :\n\n" - . $reason; + $action = 'refuse'; } elseif (Env::has('mdel')) { - $action = 3; /** 3 = DISCARD **/ - $subject = "Message supprimé"; - $append = "a été supprimé par $prenom $nom.\n\n" - . "Rappel: il ne faut utiliser cette opération " - . "que dans le cas de spams ou de virus !\n"; - } - - if (isset($action) && $this->client->handle_request($liste, $mid, $action, $reason)) { - $texte = "le message suivant :\n\n" - ." Auteur: {$mail['sender']}\n" - ." Sujet : « {$mail['subj']} »\n" - ." Date : ".strftime("le %d %b %Y à %H:%M:%S", (int)$mail['stamp'])."\n\n" - .$append; - $mailer = new PlMailer(); - $mailer->addTo("$liste-owner@{$domain}"); - $mailer->setFrom("$liste-bounces@{$domain}"); - $mailer->addHeader('Reply-To', "$liste-owner@{$domain}"); - $mailer->setSubject($subject); - $mailer->setTxtBody(wordwrap($texte,72)); - $mailer->send(); - Get::kill('mid'); - } - - return $mail; + $action = 'delete'; + } else { + return false; + } + Get::kill('mid'); + return XDB::execute("INSERT IGNORE INTO ml_moderate + VALUES ({?}, {?}, {?}, {?}, {?}, NOW(), {?}, NULL)", + $liste, $domain, $mid, S::i('uid'), $action, Post::v('reason')); } function handler_moderate(&$page, $liste = null) { if (is_null($liste)) { - return PL_NOT_FOUND; + return PL_NOT_FOUND; } $domain = $this->prepare_client($page); - $page->changeTpl('listes/moderate.tpl'); + $page->changeTpl('lists/moderate.tpl'); - $page->register_modifier('qpd', 'quoted_printable_decode'); $page->register_modifier('hdc', 'list_header_decode'); - $page->register_modifier('clean_html', array($this, 'clean_html')); - if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ - $this->client->handle_request($liste,Env::v('sadd'),4,''); - pl_redirect('lists/moderate/'.$liste); - } - if (Post::has('sdel')) { /* 2 = REJECT */ - $this->client->handle_request($liste,Post::v('sdel'),2,Post::v('reason')); + if (Env::has('sadd') || Env::has('sdel')) { + if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ + $sub = $this->client->get_pending_sub($liste, Env::v('sadd')); + $this->client->handle_request($liste,Env::v('sadd'),4,''); + $info = "validée"; + } + if (Post::has('sdel')) { /* 2 = REJECT */ + $sub = $this->client->get_pending_sub($liste, Env::v('sdel')); + $this->client->handle_request($liste, Post::v('sdel'), 2, utf8_decode(Post::v('reason'))); + $info = "refusée"; + } + if ($sub) { + $mailer = new PlMailer(); + $mailer->setFrom("$liste-bounces@{$domain}"); + $mailer->addTo("$liste-owner@{$domain}"); + $mailer->addHeader('Reply-To', "$liste-owner@{$domain}"); + $mailer->setSubject("L'inscription de {$sub['name']} a été $info"); + $text = "L'inscription de {$sub['name']} à la liste $liste@{$domain} a été $info par " . S::v('prenom') . ' ' + . S::v('nom') . '(' . S::v('promo') . ")\n"; + if (trim(Post::v('reason'))) { + $text .= "\nLa raison invoquée est :\n" . Post::v('reason'); + } + $mailer->setTxtBody(wordwrap($text, 72)); + $mailer->send(); + } + if (Env::has('sadd')) { + pl_redirect('lists/moderate/'.$liste); + } } if (Post::has('moderate_mails') && Post::has('select_mails')) { @@ -445,27 +476,29 @@ class ListsModule extends PLModule $this->moderate_mail($domain, $liste, $mail); } } elseif (Env::has('mid')) { - $mail = $this->moderate_mail($domain, $liste, Env::i('mid')); + if (Get::has('mid') && !Env::has('mok') && !Env::has('mdel')) { + $page->changeTpl('lists/moderate_mail.tpl'); + require_once('banana/moderate.inc.php'); + $params = array('listname' => $liste, 'domain' => $domain, + 'artid' => Get::i('mid'), 'part' => Get::v('part'), 'action' => Get::v('action')); + $params['client'] = $this->client; + run_banana($page, 'ModerationBanana', $params); - if (Get::has('mid') && is_array($mail)) { $msg = file_get_contents('/etc/mailman/fr/refuse.txt'); $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg); $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg); $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg); $msg = str_replace("%(listname)s", $liste, $msg); - - $mail['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']); $page->assign('msg', $msg); - - $page->changeTpl('listes/moderate_mail.tpl'); - $page->assign_by_ref('mail', $mail); return; - } + } + + $mail = $this->moderate_mail($domain, $liste, Env::i('mid')); } elseif (Env::has('sid')) { - if (list($subs,$mails) = $this->client->get_pending_ops($liste)) { + if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) { foreach($subs as $user) { if ($user['id'] == Env::v('sid')) { - $page->changeTpl('listes/moderate_sub.tpl'); + $page->changeTpl('lists/moderate_sub.tpl'); $page->assign('del_user', $user); return; } @@ -474,14 +507,38 @@ class ListsModule extends PLModule } - if (list($subs,$mails) = $this->client->get_pending_ops($liste)) { + if (list($subs,$mails) = $this->get_pending_ops($domain, $liste)) { foreach ($mails as $key=>$mail) { $mails[$key]['stamp'] = strftime("%Y%m%d%H%M%S", $mail['stamp']); + if ($mail['fromx']) { + $page->assign('with_fromx', true); + } else { + $page->assign('with_nonfromx', true); + } } $page->assign_by_ref('subs', $subs); $page->assign_by_ref('mails', $mails); } else { - $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer"); + $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer"); + } + } + + static public function no_login_callback($login) + { + require_once 'user.func.inc.php'; + global $list_unregistered, $globals; + + $users = get_not_registered_user($login, true); + if ($users && $users->total()) { + if (!isset($list_unregistered)) { + $list_unregistered = array(); + } + $list_unregistered[$login] = $users; + } else { + list($name, $dom) = @explode('@', $login); + if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) { + _default_user_callback($login); + } } } @@ -493,17 +550,49 @@ class ListsModule extends PLModule return PL_NOT_FOUND; } - $this->prepare_client($page); + $domain = $this->prepare_client($page); - $page->changeTpl('listes/admin.tpl'); + $page->changeTpl('lists/admin.tpl'); + + if (Env::has('send_mark')) { + $actions = Env::v('mk_action'); + $uids = Env::v('mk_uid'); + $mails = Env::v('mk_email'); + foreach ($actions as $key=>$action) { + switch ($action) { + case 'none': + break; + + case 'marketu': case 'markets': + require_once 'emails.inc.php'; + $mail = valide_email($mails[$key]); + if (isvalid_email_redirection($mail)) { + $from = ($action == 'marketu') ? 'user' : 'staff'; + $market = Marketing::get($uids[$key], $mail); + if (!$market) { + $market = new Marketing($uids[$key], $mail, 'list', "$liste@$domain", $from, S::v('uid')); + $market->add(); + break; + } + } + + default: + XDB::execute('INSERT IGNORE INTO register_subs (uid, type, sub, domain) + VALUES ({?}, \'list\', {?}, {?})', + $uids[$key], $liste, $domain); + } + } + } if (Env::has('add_member')) { require_once('user.func.inc.php'); - $members = get_users_forlife_list(Env::v('add_member')); + $members = get_users_forlife_list(Env::v('add_member'), + false, + array('ListsModule', 'no_login_callback')); $arr = $this->client->mass_subscribe($liste, $members); if (is_array($arr)) { foreach($arr as $addr) { - $page->trig("{$addr[0]} inscrit."); + $page->trigSuccess("{$addr[0]} inscrit."); } } } @@ -520,11 +609,11 @@ class ListsModule extends PLModule if (Env::has('add_owner')) { require_once('user.func.inc.php'); - $owners = get_users_forlife_list(Env::v('add_owner')); + $owners = get_users_forlife_list(Env::v('add_owner'), false, array('ListsModule', 'no_login_callback')); if ($owners) { foreach ($owners as $login) { if ($this->client->add_owner($liste, $login)) { - $page->trig($alias." ajouté aux modérateurs."); + $page->trigSuccess($alias." ajouté aux modérateurs."); } } } @@ -540,6 +629,10 @@ class ListsModule extends PLModule } if (list($det,$mem,$own) = $this->client->get_members($liste)) { + global $list_unregistered; + if ($list_unregistered) { + $page->assign_by_ref('unregistered', $list_unregistered); + } $membres = list_sort_members($mem, @$tri_promo); $moderos = list_sort_owners($own, @$tri_promo); @@ -563,11 +656,21 @@ class ListsModule extends PLModule $this->prepare_client($page); - $page->changeTpl('listes/options.tpl'); + $page->changeTpl('lists/options.tpl'); if (Post::has('submit')) { $values = $_POST; - $this->client->set_bogo_level($liste, intval($values['bogo_level'])); + $values = array_map('utf8_decode', $values); + $spamlevel = intval($values['bogo_level']); + $unsurelevel = intval($values['unsure_level']); + if ($spamlevel == 0) { + $unsurelevel = 0; + } + if ($spamlevel > 3 || $spamlevel < 0 || $unsurelevel < 0 || $unsurelevel > 1) { + $page->trigError("Réglage de l'antispam non valide"); + } else { + $this->client->set_bogo_level($liste, ($spamlevel << 1) + $unsurelevel); + } switch($values['moderate']) { case '0': $values['generic_nonmember_action'] = 0; @@ -600,7 +703,9 @@ class ListsModule extends PLModule if (list($details,$options) = $this->client->get_owner_options($liste)) { $page->assign_by_ref('details', $details); $page->assign_by_ref('options', $options); - $page->assign('bogo_level', $this->client->get_bogo_level($liste)); + $bogo_level = intval($this->client->get_bogo_level($liste)); + $page->assign('unsure_level', $bogo_level & 1); + $page->assign('bogo_level', $bogo_level >> 1); } else { $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer"); } @@ -624,10 +729,10 @@ class ListsModule extends PLModule $type = 'list'; } - $page->changeTpl('listes/delete.tpl'); + $page->changeTpl('lists/delete.tpl'); if (Post::v('valid') == 'OUI') { if ($this->client->delete_list($liste, Post::b('del_archive'))) { - foreach (array('', '-owner', '-admin', '-bounces') as $app) { + foreach (array('', '-owner', '-admin', '-bounces', '-unsubscribe') as $app) { XDB::execute("DELETE FROM $table WHERE type={?} AND alias={?}", $type, $liste.$app.$domain); @@ -635,7 +740,7 @@ class ListsModule extends PLModule $page->assign('deleted', true); } else { $page->kill('Une erreur est survenue lors de la suppression de la liste.
' - . 'Contact les administrateurs du site pour régler le problème : ' + . 'Contact les administrateurs du site pour régler le problème : ' . 'support@polytechnique.org'); } } elseif (list($details,$options) = $this->client->get_owner_options($liste)) { @@ -655,10 +760,11 @@ class ListsModule extends PLModule $this->prepare_client($page); - $page->changeTpl('listes/soptions.tpl'); + $page->changeTpl('lists/soptions.tpl'); if (Post::has('submit')) { $values = $_POST; + $values = array_map('utf8_decode', $values); unset($values['submit']); $values['advertised'] = empty($values['advertised']) ? false : true; $values['archive'] = empty($values['archive']) ? false : true; @@ -681,7 +787,7 @@ class ListsModule extends PLModule $this->prepare_client($page); - $page->changeTpl('listes/check.tpl'); + $page->changeTpl('lists/check.tpl'); if (Post::has('correct')) { $this->client->check_options($liste, true); @@ -696,7 +802,7 @@ class ListsModule extends PLModule } function handler_admin_all(&$page) { - $page->changeTpl('listes/admin_all.tpl'); + $page->changeTpl('lists/admin_all.tpl'); $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists'); $client = new MMList(S::v('uid'), S::v('password')); @@ -705,4 +811,5 @@ class ListsModule extends PLModule } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>