0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
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 | require_once("xorg.inc.php"); |
23 | new_skinned_page('listes/create.tpl', AUTH_MDP); |
24 | |
d4f2d5b6 |
25 | $owners = preg_split("/[\s]+/", Post::get('owners'), -1, PREG_SPLIT_NO_EMPTY); |
26 | $members = preg_split("/[\s]+/", Post::get('members'), -1, PREG_SPLIT_NO_EMPTY); |
0337d704 |
27 | |
4c196900 |
28 | // click on validate button 'add_owner_sub' or type <enter> |
0337d704 |
29 | if (Post::has('add_owner_sub') && Post::has('add_owner')) { |
30 | require_once('user.func.inc.php'); |
4c196900 |
31 | // if we want to add an owner and then type <enter>, then both add_owner_sub and add_owner are filled. |
32 | if (Post::get('add_owner') != "") { |
d4f2d5b6 |
33 | if (($forlife = get_user_forlife(Post::get('add_owner'))) !== false) { |
34 | $owners [] = $forlife; |
35 | } |
36 | // if we want to add a member and then type <enter>, then add_owner_sub is filled, whereas add_owner is empty. |
4c196900 |
37 | } else if (Post::has('add_member')) { |
d4f2d5b6 |
38 | if (($forlife = get_user_forlife(Post::get('add_member'))) !== false) { |
39 | $members[] = $forlife; |
40 | } |
0337d704 |
41 | } |
42 | } |
43 | |
4c196900 |
44 | // click on validate button 'add_member_sub' |
0337d704 |
45 | if (Post::has('add_member_sub') && Post::has('add_member')) { |
46 | require_once('user.func.inc.php'); |
47 | if (($forlife = get_user_forlife(Post::get('add_member'))) !== false) { |
48 | $members[] = $forlife; |
49 | } |
50 | } |
51 | |
52 | ksort($owners); array_unique($owners); |
53 | ksort($members); array_unique($members); |
54 | |
55 | if (Post::has('submit')) { |
56 | |
57 | $liste = Post::get('liste'); |
58 | |
59 | if(empty($liste)) { |
60 | $page->trig('champs «addresse souhaitée» vide'); |
61 | } |
62 | if(!preg_match("/^[a-zA-Z0-9\-]*$/", $liste)) { |
63 | $page->trig('le nom de la liste ne doit contenir que des lettres, chiffres et tirets'); |
64 | } |
65 | |
66 | $res = $globals->xdb->query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste); |
67 | $n = $res->fetchOneCell(); |
68 | |
69 | if($n) { |
70 | $page->trig('cet alias est déjà pris'); |
71 | } |
72 | |
73 | if(!Post::get(desc)) { |
74 | $page->trig('le sujet est vide'); |
75 | } |
76 | |
77 | if(!count($owners)) { |
78 | $page->trig('pas de gestionnaire'); |
79 | } |
80 | |
81 | if(count($members)<4) { |
82 | $page->trig('pas assez de membres'); |
83 | } |
84 | |
85 | if (!$page->nb_errs()) { |
86 | $page->assign('created', true); |
87 | require_once('validations.inc.php'); |
88 | $req = new ListeReq(Session::getInt('uid'), $liste, Post::get('desc'), |
89 | Post::getInt('advertise'), Post::getInt('modlevel'), Post::getInt('inslevel'), |
90 | $owners, $members); |
91 | $req->submit(); |
92 | } |
93 | } |
94 | |
d4f2d5b6 |
95 | $page->assign('owners', join(' ', $owners)); |
96 | $page->assign('members', join(' ', $members)); |
0337d704 |
97 | $page->run(); |
98 | ?> |