X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Flists.php;h=6ed325ce01b8312fd54e28e2e61162a08daf8fc2;hb=16594a1ac8d7cbff8a51e422a6a6d9e575129d9c;hp=8dbf7694c1679e86a3b9df5fc644d7ecab041b72;hpb=1490093c909c086ce8eba3c0f5c24b62ef20cfb3;p=platal.git diff --git a/modules/lists.php b/modules/lists.php index 8dbf769..6ed325c 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -1,6 +1,6 @@ $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), @@ -62,6 +62,22 @@ class ListsModule extends PLModule 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) @@ -74,7 +90,7 @@ class ListsModule extends PLModule return $list['sub']; } - $this->prepare_client($page); + $domain = $this->prepare_client($page); $page->changeTpl('lists/index.tpl'); $page->addJsLink('ajax.js'); @@ -103,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; } @@ -133,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; } @@ -189,7 +205,7 @@ class ListsModule extends PLModule $liste = Post::v('liste'); if (empty($liste)) { - $page->trig('champs «addresse souhaitée» vide'); + $page->trig('champs «adresse souhaitée» vide'); } if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) { $page->trig('le nom de la liste ne doit contenir que des lettres non accentuées, chiffres et tirets'); @@ -202,7 +218,7 @@ class ListsModule extends PLModule $page->trig('cet alias est déjà pris'); } - if (!Post::v(desc)) { + if (!Post::v('desc')) { $page->trig('le sujet est vide'); } @@ -262,42 +278,7 @@ 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; - 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; @@ -305,30 +286,42 @@ class ListsModule extends PLModule $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) @@ -346,7 +339,7 @@ class ListsModule extends PLModule 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"); + $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')) { @@ -356,7 +349,7 @@ class ListsModule extends PLModule 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."); } } @@ -379,7 +372,7 @@ class ListsModule extends PLModule 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')); @@ -390,47 +383,19 @@ class ListsModule extends PLModule 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) @@ -472,7 +437,7 @@ class ListsModule extends PLModule } if (Env::has('sadd')) { pl_redirect('lists/moderate/'.$liste); - } + } } if (Post::has('moderate_mails') && Post::has('select_mails')) { @@ -500,7 +465,7 @@ class ListsModule extends PLModule $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'); @@ -512,9 +477,14 @@ 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); @@ -526,16 +496,19 @@ class ListsModule extends PLModule static public function no_login_callback($login) { require_once 'user.func.inc.php'; - global $list_unregistered; + global $list_unregistered, $globals; $users = get_not_registered_user($login, true); - if ($users->total()) { + if ($users && $users->total()) { if (!isset($list_unregistered)) { $list_unregistered = array(); } $list_unregistered[$login] = $users; } else { - _default_user_callback($login); + list($name, $dom) = @explode('@', $login); + if ($dom == $globals->mail->domain || $dom == $globals->mail->domain2) { + _default_user_callback($login); + } } } @@ -583,7 +556,9 @@ class ListsModule extends PLModule if (Env::has('add_member')) { require_once('user.func.inc.php'); - $members = get_users_forlife_list(Env::v('add_member'), false, array('ListsModule', 'no_login_callback')); + $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) { @@ -716,7 +691,7 @@ class ListsModule extends PLModule $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);