<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2008 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
'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),
+ '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),
return $globals->mail->domain;
}
+ function get_pending_ops($domain, $list)
+ {
+ 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)
{
function filter_owner($list)
return $list['sub'];
}
- $this->prepare_client($page);
+ $domain = $this->prepare_client($page);
$page->changeTpl('lists/index.tpl');
$page->addJsLink('ajax.js');
$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;
}
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;
}
$page->trig('cet alias est déjà pris');
}
- if (!Post::v(desc)) {
+ if (!Post::v('desc')) {
$page->trig('le sujet est vide');
}
}
}
- 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;
- 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
- INNER JOIN photo AS p ON p.uid = u.user_id
- WHERE a.alias = {?}", $m);
- if ($tmp = $res->fetchOneAssoc()) {
- $membres[$tmp['nom']] = $tmp;
- } else {
- $total--;
- }
- }
- uasort($membres, array($this, 'compare'));
- 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;
$this->prepare_client($page);
- $page->changeTpl('lists/trombi.tpl');
-
if (Get::has('del')) {
$this->client->unsubscribe($liste);
- pl_redirect('lists/trombi/'.$liste);
+ pl_redirect('lists/annu/'.$liste);
}
if (Get::has('add')) {
$this->client->subscribe($liste);
- pl_redirect('lists/trombi/'.$liste);
+ pl_redirect('lists/annu/'.$liste);
}
$owners = $this->client->get_owners($liste);
-
- 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 {
+ if (!is_array($owners)) {
$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, $action = null, $artid = null)
if (list($det) = $this->client->get_members($liste)) {
if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv'])
&& !$det['own'] && ($det['sub'] < 2)) {
- exit;
+ exit;
}
require_once('banana/ml.inc.php');
$banana = new MLBanana(S::v('forlife'), Array('listname' => $liste, 'domain' => $domain, 'action' => 'rss2'));
function moderate_mail($domain, $liste, $mid)
{
- $mail = $this->client->get_pending_mail($liste, $mid);
- $reason = '';
-
- $prenom = S::v('prenom');
- $nom = S::v('nom');
-
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 (Env::has('sadd')) {
pl_redirect('lists/moderate/'.$liste);
- }
+ }
}
if (Post::has('moderate_mails') && Post::has('select_mails')) {
$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('lists/moderate_sub.tpl');
}
- 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']);
}
global $list_unregistered;
$users = get_not_registered_user($login, true);
- if ($users->total()) {
+ if ($users && $users->total()) {
if (!isset($list_unregistered)) {
$list_unregistered = array();
}
$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);