0337d704 |
1 | <?php |
2 | require 'xnet.inc.php'; |
3 | |
4 | new_groupadmin_page('xnet/groupe/listes-create.tpl'); |
5 | $page->assign('force_list_super', may_update()); |
6 | |
7 | if (Post::has('submit')) { |
8 | if (!Post::has('liste')) { |
9 | $page->trig_run('champs «addresse souhaitée» vide'); |
10 | } |
11 | |
12 | $liste = Post::get('liste'); |
13 | |
14 | if (!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) { |
15 | $page->trig_run('le nom de la liste ne doit contenir que des lettres, chiffres et tirets'); |
16 | } |
17 | |
18 | $new = $liste.'@'.$globals->asso('mail_domain'); |
19 | $res = $globals->xdb->query('SELECT COUNT(*) FROM x4dat.virtual WHERE alias={?}', $new); |
20 | $n = $res->fetchOneCell(); |
21 | |
22 | if($n) { |
23 | $page->trig_run('cet alias est déjà pris'); |
24 | } |
25 | if(!Post::get('desc')) { |
26 | $page->trig_run('le sujet est vide'); |
27 | } |
28 | |
03a5279f |
29 | require_once('platal/xmlrpc-client.inc.php'); |
0337d704 |
30 | require_once('lists.inc.php'); |
31 | $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'), $globals->asso('mail_domain')); |
32 | $ret = $client->create_list($liste, Post::get('desc'), Post::get('advertise'), Post::get('modlevel'), Post::get('inslevel'), array(Session::get('forlife')), array()); |
33 | |
34 | $dom = strtolower($globals->asso("mail_domain")); |
35 | $red = $dom.'_'.$liste; |
36 | |
37 | if($ret) { |
38 | $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'@'.$dom, 'list'); |
39 | $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+post@listes.polytechnique.org"); |
40 | $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-owner@'.$dom, 'list'); |
41 | $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+owner@listes.polytechnique.org"); |
42 | $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-admin@'.$dom, 'list'); |
43 | $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+admin@listes.polytechnique.org"); |
44 | $globals->xdb->execute('INSERT INTO x4dat.virtual (alias,type) VALUES({?},{?})', $liste.'-bounces@'.$dom, 'list'); |
45 | $globals->xdb->execute('INSERT INTO x4dat.virtual_redirect (vid,redirect) VALUES ({?}, {?})', mysql_insert_id(), "$red+bounces@listes.polytechnique.org"); |
fa36e526 |
46 | redirect("listes-admin.php?liste=$liste"); |
0337d704 |
47 | } else { |
48 | $page->kill("Un problème est survenu, contacter <a href='mailto:support@m4x.org'>support@m4x.org</a>"); |
49 | } |
50 | } |
51 | |
52 | $page->run() |
53 | |
54 | ?> |