bc4ad6aa |
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 | class ListsModule extends PLModule |
23 | { |
24 | var $client; |
25 | |
26 | function handlers() |
27 | { |
28 | return array( |
29 | 'lists' => $this->make_hook('lists', AUTH_MDP), |
30 | 'lists/create' => $this->make_hook('create', AUTH_MDP), |
31 | |
32 | 'lists/members' => $this->make_hook('members', AUTH_COOKIE), |
33 | 'lists/trombi' => $this->make_hook('trombi', AUTH_COOKIE), |
34 | 'lists/archives' => $this->make_hook('archives', AUTH_COOKIE), |
35 | |
36 | 'lists/moderate' => $this->make_hook('moderate', AUTH_MDP), |
37 | 'lists/admin' => $this->make_hook('admin', AUTH_MDP), |
38 | 'lists/options' => $this->make_hook('options', AUTH_MDP), |
39 | 'lists/delete' => $this->make_hook('delete', AUTH_MDP), |
40 | |
41 | 'lists/soptions' => $this->make_hook('soptions', AUTH_MDP), |
42 | 'lists/check' => $this->make_hook('check', AUTH_MDP), |
92423144 |
43 | 'admin/lists' => $this->make_hook('admin_all', AUTH_MDP, 'admin'), |
bc4ad6aa |
44 | ); |
45 | } |
46 | |
7b9d64a8 |
47 | function prepare_client(&$page) |
bc4ad6aa |
48 | { |
49 | require_once 'lists.inc.php'; |
50 | |
cab08090 |
51 | $this->client =& lists_xmlrpc(S::v('uid'), S::v('password')); |
bc4ad6aa |
52 | } |
53 | |
54 | function handler_lists(&$page) |
55 | { |
7b9d64a8 |
56 | $this->prepare_client($page); |
bc4ad6aa |
57 | |
58 | $page->changeTpl('listes/index.tpl'); |
59 | $page->assign('xorg_title','Polytechnique.org - Listes de diffusion'); |
60 | |
61 | |
62 | if (Get::has('del')) { |
5e2307dc |
63 | $this->client->unsubscribe(Get::v('del')); |
8b00e0e0 |
64 | pl_redirect('lists'); |
bc4ad6aa |
65 | } |
66 | if (Get::has('add')) { |
5e2307dc |
67 | $this->client->subscribe(Get::v('add')); |
8b00e0e0 |
68 | pl_redirect('lists'); |
bc4ad6aa |
69 | } |
70 | if (Post::has('promo_add')) { |
5e2307dc |
71 | $promo = Post::i('promo_add'); |
bc4ad6aa |
72 | if ($promo >= 1900 and $promo < 2100) { |
73 | $this->client->subscribe("promo$promo"); |
74 | } else { |
75 | $page->trig("promo incorrecte, il faut une promo sur 4 chiffres."); |
76 | } |
77 | } |
78 | $listes = $this->client->get_lists(); |
79 | $page->assign_by_ref('listes', $listes); |
80 | } |
81 | |
82 | function handler_create(&$page) |
83 | { |
bc4ad6aa |
84 | $page->changeTpl('listes/create.tpl'); |
85 | |
5e2307dc |
86 | $owners = preg_split("/[\s]+/", Post::v('owners'), -1, PREG_SPLIT_NO_EMPTY); |
87 | $members = preg_split("/[\s]+/", Post::v('members'), -1, PREG_SPLIT_NO_EMPTY); |
bc4ad6aa |
88 | |
89 | // click on validate button 'add_owner_sub' or type <enter> |
90 | if (Post::has('add_owner_sub') && Post::has('add_owner')) { |
91 | require_once('user.func.inc.php'); |
92 | // if we want to add an owner and then type <enter>, then both |
93 | // add_owner_sub and add_owner are filled. |
5e2307dc |
94 | if (Post::v('add_owner') != "") { |
95 | if (($forlife = get_user_forlife(Post::v('add_owner'))) !== false) { |
bc4ad6aa |
96 | $owners [] = $forlife; |
97 | } |
98 | // if we want to add a member and then type <enter>, then |
99 | // add_owner_sub is filled, whereas add_owner is empty. |
100 | } else if (Post::has('add_member')) { |
5e2307dc |
101 | if (($forlife = get_user_forlife(Post::v('add_member'))) !== false) { |
bc4ad6aa |
102 | $members[] = $forlife; |
103 | } |
104 | } |
105 | } |
106 | |
107 | // click on validate button 'add_member_sub' |
108 | if (Post::has('add_member_sub') && Post::has('add_member')) { |
109 | require_once('user.func.inc.php'); |
5e2307dc |
110 | if (($forlife = get_user_forlife(Post::v('add_member'))) !== false) { |
bc4ad6aa |
111 | $members[] = $forlife; |
112 | } |
113 | } |
114 | |
115 | ksort($owners); array_unique($owners); |
116 | ksort($members); array_unique($members); |
117 | |
118 | $page->assign('owners', join(' ', $owners)); |
119 | $page->assign('members', join(' ', $members)); |
120 | |
121 | if (!Post::has('submit')) { |
122 | return; |
123 | } |
124 | |
5e2307dc |
125 | $liste = Post::v('liste'); |
bc4ad6aa |
126 | |
127 | if (empty($liste)) { |
089a5801 |
128 | $page->trig('champs «addresse souhaitée» vide'); |
bc4ad6aa |
129 | } |
130 | if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) { |
131 | $page->trig('le nom de la liste ne doit contenir que des lettres, chiffres et tirets'); |
132 | } |
133 | |
08cce2ff |
134 | $res = XDB::query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); |
bc4ad6aa |
135 | $n = $res->fetchOneCell(); |
136 | |
137 | if ($n) { |
089a5801 |
138 | $page->trig('cet alias est déjà pris'); |
bc4ad6aa |
139 | } |
140 | |
5e2307dc |
141 | if (!Post::v(desc)) { |
bc4ad6aa |
142 | $page->trig('le sujet est vide'); |
143 | } |
144 | |
145 | if (!count($owners)) { |
146 | $page->trig('pas de gestionnaire'); |
147 | } |
148 | |
149 | if (count($members)<4) { |
150 | $page->trig('pas assez de membres'); |
151 | } |
152 | |
153 | if (!$page->nb_errs()) { |
154 | $page->assign('created', true); |
155 | require_once 'validations.inc.php'; |
cab08090 |
156 | $req = new ListeReq(S::v('uid'), $liste, |
5e2307dc |
157 | Post::v('desc'), Post::i('advertise'), |
158 | Post::i('modlevel'), Post::i('inslevel'), |
bc4ad6aa |
159 | $owners, $members); |
160 | $req->submit(); |
161 | } |
162 | } |
163 | |
164 | function handler_members(&$page, $liste = null) |
165 | { |
bc4ad6aa |
166 | if (is_null($liste)) { |
167 | return PL_NOT_FOUND; |
168 | } |
169 | |
7b9d64a8 |
170 | $this->prepare_client($page); |
bc4ad6aa |
171 | |
172 | $page->changeTpl('listes/members.tpl'); |
173 | |
174 | if (Get::has('del')) { |
175 | $this->client->unsubscribe($liste); |
8b00e0e0 |
176 | pl_redirect('lists/members/'.$liste); |
bc4ad6aa |
177 | } |
178 | |
179 | if (Get::has('add')) { |
180 | $this->client->subscribe($liste); |
8b00e0e0 |
181 | pl_redirect('lists/members/'.$liste); |
bc4ad6aa |
182 | } |
183 | |
184 | $members = $this->client->get_members($liste); |
185 | |
5e2307dc |
186 | $tri_promo = !Env::b('alpha'); |
bc4ad6aa |
187 | |
188 | if (list($det,$mem,$own) = $members) { |
189 | $membres = list_sort_members($mem, $tri_promo); |
190 | $moderos = list_sort_owners($own, $tri_promo); |
191 | |
192 | $page->assign_by_ref('details', $det); |
193 | $page->assign_by_ref('members', $membres); |
194 | $page->assign_by_ref('owners', $moderos); |
195 | $page->assign('nb_m', count($mem)); |
196 | } else { |
089a5801 |
197 | $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); |
bc4ad6aa |
198 | } |
199 | } |
200 | |
201 | function _get_list($offset, $limit) |
202 | { |
a3a049fc |
203 | global $platal; |
bc4ad6aa |
204 | list($total, $members) = $this->client->get_members_limit($platal->argv[1], $offset, $limit); |
205 | |
206 | $membres = Array(); |
207 | foreach ($members as $member) { |
208 | list($m) = explode('@',$member[1]); |
08cce2ff |
209 | $res = XDB::query("SELECT prenom,if (nom_usage='', nom, nom_usage) AS nom, |
bc4ad6aa |
210 | promo, a.alias AS forlife |
211 | FROM auth_user_md5 AS u |
212 | INNER JOIN aliases AS a ON u.user_id = a.id |
213 | WHERE a.alias = {?}", $m); |
214 | if ($tmp = $res->fetchOneAssoc()) { |
215 | $membres[$tmp['nom']] = $tmp; |
216 | } else { |
217 | $membres[$member[0]] = array('addr' => $member[0]); |
218 | } |
219 | } |
220 | return array($total, $membres); |
221 | } |
222 | |
223 | function handler_trombi(&$page, $liste = null) |
224 | { |
bc4ad6aa |
225 | if (is_null($liste)) { |
226 | return PL_NOT_FOUND; |
227 | } |
228 | |
7b9d64a8 |
229 | $this->prepare_client($page); |
bc4ad6aa |
230 | |
231 | $page->changeTpl('listes/trombi.tpl'); |
232 | |
233 | if (Get::has('del')) { |
234 | $this->client->unsubscribe($liste); |
8b00e0e0 |
235 | pl_redirect('lists/tromi/'.$liste); |
bc4ad6aa |
236 | } |
237 | if (Get::has('add')) { |
238 | $this->client->subscribe($liste); |
8b00e0e0 |
239 | pl_redirect('lists/tromi/'.$liste); |
bc4ad6aa |
240 | } |
241 | |
242 | $owners = $this->client->get_owners($liste); |
243 | |
244 | if (is_array($owners)) { |
245 | require_once 'trombi.inc.php'; |
246 | $moderos = list_sort_owners($owners[1]); |
247 | |
248 | $page->assign_by_ref('details', $owners[0]); |
249 | $page->assign_by_ref('owners', $moderos); |
250 | |
251 | $trombi = new Trombi(array(&$this, '_get_list')); |
252 | $page->assign('trombi', $trombi); |
253 | } else { |
089a5801 |
254 | $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails"); |
bc4ad6aa |
255 | } |
256 | } |
257 | |
258 | function handler_archives(&$page, $liste = null) |
259 | { |
260 | global $globals; |
261 | |
262 | if (is_null($liste)) { |
263 | return PL_NOT_FOUND; |
264 | } |
265 | |
7b9d64a8 |
266 | $this->prepare_client($page); |
bc4ad6aa |
267 | |
268 | $page->changeTpl('listes/archives.tpl'); |
269 | |
270 | $page->addCssLink('css/lists.archives.css'); |
271 | if (list($det) = $this->client->get_members($liste)) { |
272 | if (substr($liste,0,5) != 'promo' && ($det['ins'] || $det['priv']) |
273 | && !$det['own'] && ($det['sub'] < 2)) |
274 | { |
275 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); |
276 | } elseif (Get::has('file')) { |
5e2307dc |
277 | $file = Get::v('file'); |
278 | $rep = Get::v('rep'); |
bc4ad6aa |
279 | if (strstr('/', $file)!==false || !preg_match(',^\d+/\d+$,', $rep)) { |
280 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); |
281 | } else { |
282 | $page->assign('archives', $globals->lists->spool |
283 | ."/{$domain}{$globals->lists->vhost_sep}$liste/$rep/$file"); |
284 | } |
285 | } else { |
286 | $archs = Array(); |
287 | foreach (glob($globals->lists->spool |
288 | ."/{$domain}{$globals->lists->vhost_sep}$liste/*/*") as $rep) |
289 | { |
290 | if (preg_match(",/(\d*)/(\d*)$,", $rep, $matches)) { |
291 | $archs[intval($matches[1])][intval($matches[2])] = true; |
292 | } |
293 | } |
294 | $page->assign('archs', $archs); |
295 | $page->assign('range', range(1,12)); |
296 | } |
297 | } else { |
298 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de la consulter"); |
299 | } |
300 | } |
301 | |
302 | function handler_moderate(&$page, $liste = null) |
303 | { |
bc4ad6aa |
304 | if (is_null($liste)) { |
305 | return PL_NOT_FOUND; |
306 | } |
307 | |
7b9d64a8 |
308 | $this->prepare_client($page); |
bc4ad6aa |
309 | |
310 | $page->changeTpl('listes/moderate.tpl'); |
311 | |
312 | $page->register_modifier('qpd', 'quoted_printable_decode'); |
313 | |
314 | if (Env::has('sadd')) { /* 4 = SUBSCRIBE */ |
5e2307dc |
315 | $this->client->handle_request($liste,Env::v('sadd'),4,''); |
8b00e0e0 |
316 | pl_redirect('lists/moderate/'.$liste); |
bc4ad6aa |
317 | } |
318 | |
319 | if (Post::has('sdel')) { /* 2 = REJECT */ |
5e2307dc |
320 | $this->client->handle_request($liste,Post::v('sdel'),2,Post::v('reason')); |
bc4ad6aa |
321 | } |
322 | |
323 | if (Env::has('mid')) { |
5e2307dc |
324 | $mid = Env::v('mid'); |
bc4ad6aa |
325 | $mail = $this->client->get_pending_mail($liste, $mid); |
326 | $reason = ''; |
327 | |
cab08090 |
328 | $prenom = S::v('prenom'); |
329 | $nom = S::v('nom'); |
bc4ad6aa |
330 | |
331 | if (Env::has('mok')) { |
332 | $action = 1; /** 2 = ACCEPT **/ |
089a5801 |
333 | $subject = "Message accepté"; |
334 | $append .= "a été accepté par $prenom $nom.\n"; |
bc4ad6aa |
335 | } elseif (Env::has('mno')) { |
336 | $action = 2; /** 2 = REJECT **/ |
089a5801 |
337 | $subject = "Message refusé"; |
5e2307dc |
338 | $reason = Post::v('reason'); |
089a5801 |
339 | $append = "a été refusé par $prenom $nom avec la raison :\n\n" |
bc4ad6aa |
340 | . $reason; |
341 | } elseif (Env::has('mdel')) { |
342 | $action = 3; /** 3 = DISCARD **/ |
089a5801 |
343 | $subject = "Message supprimé"; |
344 | $append = "a été supprimé par $prenom $nom.\n\n" |
345 | . "Rappel: il ne faut utiliser cette opération " |
bc4ad6aa |
346 | . "que dans le cas de spams ou de virus !\n"; |
347 | } |
348 | |
349 | if (isset($action) && $this->client->handle_request($liste, $mid, $action, $reason)) { |
350 | $texte = "le message suivant :\n\n" |
351 | ." Auteur: {$mail['sender']}\n" |
089a5801 |
352 | ." Sujet : « {$mail['subj']} »\n" |
353 | ." Date : ".strftime("le %d %b %Y à %H:%M:%S", (int)$mail['stamp'])."\n\n" |
bc4ad6aa |
354 | .$append; |
355 | require_once 'diogenes/diogenes.hermes.inc.php'; |
356 | $mailer = new HermesMailer(); |
357 | $mailer->addTo("$liste-owner@{$domain}"); |
358 | $mailer->setFrom("$liste-bounces@{$domain}"); |
359 | $mailer->addHeader('Reply-To', "$liste-owner@{$domain}"); |
360 | $mailer->setSubject($subject); |
361 | $mailer->setTxtBody(wordwrap($texte,72)); |
362 | $mailer->send(); |
363 | Get::kill('mid'); |
364 | } |
365 | |
366 | if (Get::has('mid') && is_array($mail)) { |
367 | $msg = file_get_contents('/etc/mailman/fr/refuse.txt'); |
368 | $msg = str_replace("%(adminaddr)s", "$liste-owner@{$domain}", $msg); |
369 | $msg = str_replace("%(request)s", "<< SUJET DU MAIL >>", $msg); |
370 | $msg = str_replace("%(reason)s", "<< TON EXPLICATION >>", $msg); |
371 | $msg = str_replace("%(listname)s", $liste, $msg); |
372 | $page->assign('msg', $msg); |
373 | |
374 | $page->changeTpl('listes/moderate_mail.tpl'); |
375 | $page->assign_by_ref('mail', $mail); |
6a20c6a3 |
376 | return; |
bc4ad6aa |
377 | } |
378 | |
379 | } elseif (Env::has('sid')) { |
380 | |
381 | if (list($subs,$mails) = $this->client->get_pending_ops($liste)) { |
382 | foreach($subs as $user) { |
5e2307dc |
383 | if ($user['id'] == Env::v('sid')) { |
bc4ad6aa |
384 | $page->changeTpl('listes/moderate_sub.tpl'); |
6a20c6a3 |
385 | $page->assign('del_user', $user); |
386 | return; |
bc4ad6aa |
387 | } |
388 | } |
389 | } |
390 | |
391 | } |
392 | |
393 | if (list($subs,$mails) = $this->client->get_pending_ops($liste)) { |
394 | $page->assign_by_ref('subs', $subs); |
395 | $page->assign_by_ref('mails', $mails); |
396 | } else { |
089a5801 |
397 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de la modérer"); |
bc4ad6aa |
398 | } |
399 | } |
400 | |
401 | function handler_admin(&$page, $liste = null) |
402 | { |
403 | global $globals; |
404 | |
405 | if (is_null($liste)) { |
406 | return PL_NOT_FOUND; |
407 | } |
408 | |
7b9d64a8 |
409 | $this->prepare_client($page); |
bc4ad6aa |
410 | |
411 | $page->changeTpl('listes/admin.tpl'); |
412 | |
413 | if (Env::has('add_member')) { |
414 | |
415 | require_once('user.func.inc.php'); |
5e2307dc |
416 | $members = explode(' ', Env::v('add_member')); |
bc4ad6aa |
417 | if ($members) foreach ($members as $i => $alias) { |
418 | if (($login = get_user_forlife($alias)) !== false) {; |
419 | $members[$i] = $login; |
420 | } |
421 | } |
422 | |
423 | $arr = $this->client->mass_subscribe($liste, $members); |
424 | if (is_array($arr)) { |
425 | foreach($arr as $addr) { |
426 | $page->trig("{$addr[0]} inscrit."); |
427 | } |
428 | } |
429 | } |
430 | |
431 | if (Env::has('del_member')) { |
5e2307dc |
432 | if (strpos(Env::v('del_member'), '@') === false) { |
bc4ad6aa |
433 | $this->client->mass_unsubscribe( |
5e2307dc |
434 | $liste, array(Env::v('del_member').'@'.$globals->mail->domain)); |
bc4ad6aa |
435 | } else { |
5e2307dc |
436 | $this->client->mass_unsubscribe($liste, array(Env::v('del_member'))); |
bc4ad6aa |
437 | } |
8b00e0e0 |
438 | pl_redirect('lists/admin/'.$liste); |
bc4ad6aa |
439 | } |
440 | |
441 | if (Env::has('add_owner')) { |
442 | require_once('user.func.inc.php'); |
443 | |
5e2307dc |
444 | $owners = explode(' ', Env::v('add_owner')); |
bc4ad6aa |
445 | |
446 | if ($owners) foreach ($owners as $alias) { |
447 | if (($login = get_user_forlife($alias)) === false) {; |
448 | $login = $alias; |
449 | } |
450 | |
451 | if ($this->client->add_owner($liste, $login)) { |
089a5801 |
452 | $page->trig($alias." ajouté aux modérateurs."); |
bc4ad6aa |
453 | } |
454 | } |
455 | } |
456 | |
457 | if (Env::has('del_owner')) { |
5e2307dc |
458 | if (strpos(Env::v('del_owner'), '@') === false) { |
459 | $this->client->del_owner($liste, Env::v('del_owner').'@'.$globals->mail->domain); |
bc4ad6aa |
460 | } else { |
5e2307dc |
461 | $this->client->del_owner($liste, Env::v('del_owner')); |
bc4ad6aa |
462 | } |
8b00e0e0 |
463 | pl_redirect('lists/admin/'.$liste); |
bc4ad6aa |
464 | } |
465 | |
466 | if (list($det,$mem,$own) = $this->client->get_members($liste)) { |
467 | |
468 | $membres = list_sort_members($mem, $tri_promo); |
469 | $moderos = list_sort_owners($own, $tri_promo); |
470 | |
471 | $page->assign_by_ref('details', $det); |
472 | $page->assign_by_ref('members', $membres); |
473 | $page->assign_by_ref('owners', $moderos); |
474 | $page->assign('np_m', count($mem)); |
475 | |
476 | } else { |
477 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer"); |
478 | } |
479 | } |
480 | |
481 | function handler_options(&$page, $liste = null) |
482 | { |
bc4ad6aa |
483 | if (is_null($liste)) { |
484 | return PL_NOT_FOUND; |
485 | } |
486 | |
7b9d64a8 |
487 | $this->prepare_client($page); |
bc4ad6aa |
488 | |
489 | $page->changeTpl('listes/options.tpl'); |
490 | |
491 | if (Post::has('submit')) { |
492 | $values = $_POST; |
493 | $this->client->set_bogo_level($liste, intval($values['bogo_level'])); |
494 | switch($values['moderate']) { |
495 | case '0': |
496 | $values['generic_nonmember_action'] = 0; |
497 | $values['default_member_moderation'] = 0; |
498 | break; |
499 | case '1': |
500 | $values['generic_nonmember_action'] = 1; |
501 | $values['default_member_moderation'] = 0; |
502 | break; |
503 | case '2': |
504 | $values['generic_nonmember_action'] = 1; |
505 | $values['default_member_moderation'] = 1; |
506 | break; |
507 | } |
508 | unset($values['submit'], $values['bogo_level'], $values['moderate']); |
509 | $values['send_goodbye_msg'] = !empty($values['send_goodbye_msg']); |
510 | $values['admin_notify_mchanges'] = !empty($values['admin_notify_mchanges']); |
511 | $values['subscribe_policy'] = empty($values['subscribe_policy']) ? 0 : 2; |
512 | if (isset($values['subject_prefix'])) { |
513 | $values['subject_prefix'] = trim($values['subject_prefix']).' '; |
514 | } |
515 | $this->client->set_owner_options($liste, $values); |
5e2307dc |
516 | } elseif (isvalid_email(Post::v('atn_add'))) { |
517 | $this->client->add_to_wl($liste, Post::v('atn_add')); |
bc4ad6aa |
518 | } elseif (Get::has('atn_del')) { |
5e2307dc |
519 | $this->client->del_from_wl($liste, Get::v('atn_del')); |
8b00e0e0 |
520 | pl_redirect('lists/options/'.$liste); |
bc4ad6aa |
521 | } |
522 | |
523 | if (list($details,$options) = $this->client->get_owner_options($liste)) { |
524 | $page->assign_by_ref('details', $details); |
525 | $page->assign_by_ref('options', $options); |
526 | $page->assign('bogo_level', $this->client->get_bogo_level($liste)); |
527 | } else { |
528 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer"); |
529 | } |
530 | } |
531 | |
532 | function handler_delete(&$page, $liste = null) |
533 | { |
bc4ad6aa |
534 | if (is_null($liste)) { |
535 | return PL_NOT_FOUND; |
536 | } |
537 | |
7b9d64a8 |
538 | $this->prepare_client($page); |
bc4ad6aa |
539 | |
540 | $page->changeTpl('listes/delete.tpl'); |
541 | |
5e2307dc |
542 | if (Post::v('valid') == 'OUI' |
543 | && $this->client->delete_list($liste, Post::b('del_archive'))) |
bc4ad6aa |
544 | { |
545 | foreach (array('', '-owner', '-admin', '-bounces') as $app) { |
08cce2ff |
546 | XDB::execute("DELETE FROM aliases |
bc4ad6aa |
547 | WHERE type='liste' AND alias='{?}'", |
80f44cfe |
548 | $liste.$app); |
bc4ad6aa |
549 | } |
550 | $page->assign('deleted', true); |
551 | } elseif (list($details,$options) = $this->client->get_owner_options($liste)) { |
552 | $page->assign_by_ref('details', $details); |
553 | $page->assign_by_ref('options', $options); |
554 | $page->assign('bogo_level', $this->client->get_bogo_level($liste)); |
555 | } else { |
556 | $page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer"); |
557 | } |
558 | } |
559 | |
560 | function handler_soptions(&$page, $liste = null) |
561 | { |
bc4ad6aa |
562 | if (is_null($liste)) { |
563 | return PL_NOT_FOUND; |
564 | } |
565 | |
7b9d64a8 |
566 | $this->prepare_client($page); |
bc4ad6aa |
567 | |
568 | $page->changeTpl('listes/soptions.tpl'); |
569 | |
570 | if (Post::has('submit')) { |
571 | $values = $_POST; |
572 | unset($values['submit']); |
573 | $values['advertised'] = empty($values['advertised']) ? false : true; |
574 | $values['archive'] = empty($values['archive']) ? false : true; |
575 | $this->client->set_admin_options($liste, $values); |
576 | } |
577 | |
578 | if (list($details,$options) = $this->client->get_admin_options($liste)) { |
579 | $page->assign_by_ref('details', $details); |
580 | $page->assign_by_ref('options', $options); |
581 | } else { |
582 | $page->kill("La liste n'existe pas"); |
583 | } |
584 | } |
585 | |
586 | function handler_check(&$page, $liste = null) |
587 | { |
bc4ad6aa |
588 | if (is_null($liste)) { |
589 | return PL_NOT_FOUND; |
590 | } |
591 | |
7b9d64a8 |
592 | $this->prepare_client($page); |
bc4ad6aa |
593 | |
594 | $page->changeTpl('listes/check.tpl'); |
595 | |
596 | if (Post::has('correct')) { |
597 | $this->client->check_options($liste, true); |
598 | } |
599 | |
600 | if (list($details,$options) = $this->client->check_options($liste)) { |
601 | $page->assign_by_ref('details', $details); |
602 | $page->assign_by_ref('options', $options); |
603 | } else { |
604 | $page->kill("La liste n'existe pas"); |
605 | } |
606 | } |
92423144 |
607 | |
608 | function handler_admin_all(&$page) { |
163eddd2 |
609 | $page->changeTpl('listes/admin_all.tpl'); |
92423144 |
610 | $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists'); |
611 | require_once 'lists.inc.php'; |
612 | |
613 | $client =& lists_xmlrpc(S::v('uid'), S::v('password')); |
614 | $listes = $client->get_all_lists(); |
615 | $page->assign_by_ref('listes',$listes); |
616 | } |
617 | |
bc4ad6aa |
618 | } |
619 | |
620 | ?> |