X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=009950b005805ae7c166d3165b39784c86cb4b21;hb=c144f2e51e27431ae770661216906997c5dbd725;hp=68467292f2479512ca809933085332a33b927608;hpb=c8f17b03b9323a7601e469d97033fc5f4c886d67;p=platal.git diff --git a/modules/lists.php b/modules/lists.php index 6846729..009950b 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -27,12 +27,13 @@ class ListsModule extends PLModule { return array( 'lists' => $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/archives' => $this->make_hook('archives', AUTH_COOKIE), + 'lists/archives/rss' => $this->make_hook('rss', AUTH_PUBLIC), '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'), ); } @@ -191,7 +192,7 @@ class ListsModule extends PLModule $page->trig('champs «addresse souhaitée» 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->trig('le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets'); } $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); @@ -271,6 +272,17 @@ class ListsModule extends PLModule } } + function compare($a, $b) + { + if ($a['promo'] == $b['promo']) { + if ($a['nom'] == $b['nom']) { + return strcmp($a['prenom'], $b['prenom']); + } + return strcmp($a['nom'], $b['nom']); + } + return $a['promo'] - $b['promo']; + } + function _get_list($offset, $limit) { global $platal; @@ -291,9 +303,7 @@ class ListsModule extends PLModule $total--; } } - uasort($membres, create_function('$a,$b', 'return $a["promo"] > $b["promo"] || ' - . '($a["promo"] == $b["promo"] && (strcmp($a["nom"], $b["nom"]) > 0 || ' - . '($a["nom"] == $b["nom"] && strcmp($a["prenom"], $b["prenom"]) > 0)));')); + uasort($membres, array($this, 'compare')); return array($total, $membres); } @@ -352,42 +362,42 @@ class ListsModule extends PLModule if (Post::has('updateall')) { $get['updateall'] = Post::v('updateall'); } - if (!is_null($action)) { - if ($action == 'new') { - $get['action'] = 'new'; - } elseif (!is_null($artid)) { - $get['artid'] = $artid; - if ($action == 'reply') { - $get['action'] = 'new'; - } elseif ($action == 'cancel') { - $get['action'] = $action; - } elseif ($action == 'from') { - $get['first'] = $artid; - unset($get['artid']); - } elseif ($action == 'read') { - $get['part'] = @$_GET['part']; - } elseif ($action == 'source') { - $get['part'] = 'source'; - } elseif ($action == 'xface') { - $get['part'] = 'xface'; - } elseif ($action) { - $get['part'] = str_replace('.', '/', $action); - } - if (Get::v('action') == 'showext') { - $get['action'] = 'showext'; - } - } - } - require_once('banana/ml.inc.php'); - $banana = new MLBanana($get); - $page->assign('banana', $banana->run()); - $page->addCssInline($banana->css()); - $page->addCssLink('banana.css'); + 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"); } } + function handler_rss(&$page, $liste = null, $alias = null, $hash = null) + { + require_once('rss.inc.php'); + $uid = init_rss(null, $alias, $hash); + if (!$uid || !$liste) { + exit; + } + + $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) { $mail = $this->client->get_pending_mail($liste, $mid); @@ -436,7 +446,7 @@ class ListsModule extends PLModule function handler_moderate(&$page, $liste = null) { if (is_null($liste)) { - return PL_NOT_FOUND; + return PL_NOT_FOUND; } $domain = $this->prepare_client($page); @@ -445,12 +455,34 @@ class ListsModule extends PLModule $page->register_modifier('hdc', 'list_header_decode'); - 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, 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')) { @@ -460,12 +492,12 @@ class ListsModule extends PLModule } } elseif (Env::has('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')); - $banana = new ModerationBanana($params, $this->client); - $res = $banana->run(); - $page->addCssInline($banana->css()); + $params['client'] = $this->client; + run_banana($page, 'ModerationBanana', $params); $msg = file_get_contents('/etc/mailman/fr/refuse.txt'); $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg); @@ -473,10 +505,6 @@ class ListsModule extends PLModule $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg); $msg = str_replace("%(listname)s", $liste, $msg); $page->assign('msg', $msg); - - $page->addCssLink('banana.css'); - $this->changeTpl('lists/moderate_mail.tpl'); - $page->assign_by_ref('mail', $res); return; }