| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2006 Polytechnique.org * |
| 4 | * http://opensource.polytechnique.org/ * |
| 5 | * * |
| 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. * |
| 10 | * * |
| 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. * |
| 15 | * * |
| 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 * |
| 18 | * Foundation, Inc., * |
| 19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | if (!$page) { |
| 23 | require_once("xorg.inc.php"); |
| 24 | if (!Env::has('liste')) redirect('index.php'); |
| 25 | $liste = strtolower(Env::get('liste')); |
| 26 | $domain = $globals->mail->domain; |
| 27 | |
| 28 | if (preg_match("!(?:[a-z0-9]+\\.)?{$domain}_(.*)!", $liste, $matches)) { |
| 29 | redirect("{$_SERVER['PHP_SELF']}?liste={$matches[1]}"); |
| 30 | } |
| 31 | |
| 32 | new_skinned_page('listes/moderate.tpl', AUTH_MDP); |
| 33 | require_once('lists.inc.php'); |
| 34 | |
| 35 | $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password')); |
| 36 | } |
| 37 | |
| 38 | $page->register_modifier('qpd','quoted_printable_decode'); |
| 39 | |
| 40 | if(Env::has('sadd')) { |
| 41 | $client->handle_request($liste,Env::get('sadd'),4,''); /* 4 = SUBSCRIBE */ |
| 42 | redirect("{$_SERVER['PHP_SELF']}?liste=$liste"); |
| 43 | } |
| 44 | |
| 45 | if(Post::has('sdel')) { |
| 46 | $client->handle_request($liste,Post::get('sdel'),2,Post::get('reason')); /* 2 = REJECT */ |
| 47 | } |
| 48 | |
| 49 | if(Env::has('mid')) { |
| 50 | $mid = Env::get('mid'); |
| 51 | $mail = $client->get_pending_mail($liste, $mid); |
| 52 | $reason = ''; |
| 53 | |
| 54 | $prenom = Session::get('prenom'); |
| 55 | $nom = Session::get('nom'); |
| 56 | |
| 57 | |
| 58 | if (Env::has('mok')) { |
| 59 | $action = 1; /** 2 = ACCEPT **/ |
| 60 | $subject = "Message accepté"; |
| 61 | $append .= "a été accepté par $prenom $nom.\n"; |
| 62 | } elseif (Env::has('mno')) { |
| 63 | $action = 2; /** 2 = REJECT **/ |
| 64 | $subject = "Message refusé"; |
| 65 | $reason = Post::get('reason'); |
| 66 | $append = "a été refusé par $prenom $nom avec la raison :\n\n" |
| 67 | . $reason; |
| 68 | } elseif (Env::has('mdel')) { |
| 69 | $action = 3; /** 3 = DISCARD **/ |
| 70 | $subject = "Message supprimé"; |
| 71 | $append = "a été supprimé par $prenom $nom.\n\n" |
| 72 | . "Rappel: il ne faut utiliser cette opération que dans le cas de spams ou de virus !\n"; |
| 73 | } |
| 74 | |
| 75 | if (isset($action) && $client->handle_request($liste, $mid, $action, $reason)) { |
| 76 | $texte = "le message suivant :\n\n" |
| 77 | ." Auteur: {$mail['sender']}\n" |
| 78 | ." Sujet : « {$mail['subj']} »\n" |
| 79 | ." Date : ".strftime("le %d %b %Y à %H:%M:%S", (int)$mail['stamp'])."\n\n" |
| 80 | .$append; |
| 81 | require_once('diogenes/diogenes.hermes.inc.php'); |
| 82 | $mailer = new HermesMailer(); |
| 83 | $mailer->addTo("$liste-owner@{$domain}"); |
| 84 | $mailer->setFrom("$liste-bounces@{$domain}"); |
| 85 | $mailer->addHeader('Reply-To', "$liste-owner@{$domain}"); |
| 86 | $mailer->setSubject($subject); |
| 87 | $mailer->setTxtBody(wordwrap($texte,72)); |
| 88 | $mailer->send(); |
| 89 | Get::kill('mid'); |
| 90 | } |
| 91 | |
| 92 | if(Get::has('mid') && is_array($mail)) { |
| 93 | $msg = file_get_contents('/etc/mailman/fr/refuse.txt'); |
| 94 | $msg = str_replace("%(adminaddr)s","$liste-owner@{$domain}", $msg); |
| 95 | $msg = str_replace("%(request)s","<< SUJET DU MAIL >>", $msg); |
| 96 | $msg = str_replace("%(reason)s","<< TON EXPLICATION >>", $msg); |
| 97 | $msg = str_replace("%(listname)s","$liste", $msg); |
| 98 | $page->assign('msg', $msg); |
| 99 | |
| 100 | $page->changeTpl('listes/moderate_mail.tpl'); |
| 101 | $page->assign_by_ref('mail', $mail); |
| 102 | $page->run(); |
| 103 | } |
| 104 | |
| 105 | } elseif (Env::has('sid')) { |
| 106 | |
| 107 | if(list($subs,$mails) = $client->get_pending_ops($liste)) { |
| 108 | foreach($subs as $user) { |
| 109 | if ($user['id'] == Env::get('sid')) { |
| 110 | $page->changeTpl('listes/moderate_sub.tpl'); |
| 111 | $page->assign('del_user',$user); |
| 112 | $page->run(); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | } |
| 118 | |
| 119 | if(list($subs,$mails) = $client->get_pending_ops($liste)) { |
| 120 | $page->assign_by_ref('subs', $subs); |
| 121 | $page->assign_by_ref('mails', $mails); |
| 122 | } else { |
| 123 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer"); |
| 124 | } |
| 125 | |
| 126 | $page->run(); |
| 127 | ?> |