2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once("xorg.inc.php");
23 new_skinned_page('listes/create.tpl', AUTH_MDP
);
25 $owners = preg_split("/[\r\n]+/",Post
::get('owners'), -1, PREG_SPLIT_NO_EMPTY
);
26 $members = preg_split("/[\r\n]+/",Post
::get('members'), -1, PREG_SPLIT_NO_EMPTY
);
28 // click on validate button 'add_owner_sub' or type <enter>
29 if (Post
::has('add_owner_sub') && Post
::has('add_owner')) {
30 require_once('user.func.inc.php');
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') != "") {
33 if (($forlife = get_user_forlife(Post
::get('add_owner'))) !== false
) {
34 $owners [] = $forlife;
36 // if we want to add a member and then type <enter>, then add_owner_sub is filled, whereas add_owner is empty.
37 } else if (Post
::has('add_member')) {
38 if (($forlife = get_user_forlife(Post
::get('add_member'))) !== false
) {
39 $members[] = $forlife;
44 // click on validate button 'add_member_sub'
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;
52 ksort($owners); array_unique($owners);
53 ksort($members); array_unique($members);
55 if (Post
::has('submit')) {
57 $liste = Post
::get('liste');
60 $page->trig('champs «addresse souhaitée» vide');
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');
66 $res = $globals->xdb
->query("SELECT COUNT(*) FROM aliases WHERE alias={?}", $liste);
67 $n = $res->fetchOneCell();
70 $page->trig('cet alias est déjà pris');
73 if(!Post
::get(desc
)) {
74 $page->trig('le sujet est vide');
78 $page->trig('pas de gestionnaire');
81 if(count($members)<4) {
82 $page->trig('pas assez de membres');
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'),
95 $page->assign('owners', join("\n",$owners));
96 $page->assign('members', join("\n",$members));