Bug 335 suppression sans validation du statut orange. Rajout de quelques tests supplé...
[platal.git] / htdocs / carnet / notifs.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2004 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 require_once("xorg.inc.php");
23 new_skinned_page('carnet/notifs.tpl', AUTH_COOKIE);
24 require_once('notifs.inc.php');
25
26 $watch = new Watch(Session::getInt('uid'));
27
28 $res = $globals->xdb->query("SELECT promo_sortie FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid', -1));
29 $promo_sortie = $res->fetchOneCell();
30 $page->assign('promo_sortie', $promo_sortie);
31
32 if(Env::has('promo')) {
33 if(preg_match('!^ *(\d{4}) *$!', Env::get('promo'), $matches)) {
34 $p = intval($matches[1]);
35 if($p<1900 || $p>2100) {
36 $page->trig("la promo entrée est invalide");
37 } else {
38 if (Env::has('add_promo')) $watch->_promos->add($p);
39 if (Env::has('del_promo')) $watch->_promos->del($p);
40 }
41 } elseif (preg_match('!^ *(\d{4}) *- *(\d{4}) *$!', Env::get('promo'), $matches)) {
42 $p1 = intval($matches[1]);
43 $p2 = intval($matches[2]);
44 if($p1<1900 || $p1>2100) {
45 $page->trig('la première promo de la plage entrée est invalide');
46 } elseif($p2<1900 || $p2>2100) {
47 $page->trig('la seconde promo de la plage entrée est invalide');
48 } else {
49 if (Env::has('add_promo')) $watch->_promos->addRange($p1,$p2);
50 if (Env::has('del_promo')) $watch->_promos->delRange($p1,$p2);
51 }
52 } else {
53 $page->trig("La promo (ou la plage de promo) entrée est dans un format incorrect.");
54 }
55 }
56
57 if (Env::has('del_nonins')) $watch->_nonins->del(Env::get('del_nonins'));
58 if (Env::has('add_nonins')) $watch->_nonins->add(Env::get('add_nonins'));
59 if (Env::has('subs')) $watch->_subs->update('sub');
60 if (Env::has('flags_contacts')) {
61 $watch->watch_contacts = Env::getBool('contacts');
62 $watch->saveFlags();
63 }
64 if (Env::has('flags_mail')) {
65 $watch->watch_mail = Env::getBool('mail');
66 $watch->saveFlags();
67 }
68
69 $page->assign_by_ref('watch', $watch);
70 $page->run();
71
72 // vim:set et sws=4 sw=4 sts=4:
73 ?>