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