Bug 130: Les pages ont toutes un titre different.
[platal.git] / htdocs / marketing / private.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_admin_page('marketing/private.tpl');
24
25 $uid = Env::get('uid');
26 $res = $globals->xdb->query("SELECT nom, prenom, promo, matricule FROM auth_user_md5 WHERE user_id={?} AND perms='pending'", $uid);
27
28 if (list($nom, $prenom, $promo, $matricule) = $res->fetchOneRow()) {
29 require_once('register.inc.php');
30 $matricule_X = get_X_mat($matricule);
31 $page->gassign('nom');
32 $page->gassign('prenom');
33 $page->gassign('promo');
34 $page->gassign('matricule');
35 $page->assign('matricule_X',$matricule_X);
36 } else {
37 $page->kill('uid invalide');
38 }
39
40 if (Env::has('del')) {
41 $globals->xdb->execute('DELETE FROM register_marketing WHERE uid={?} AND email={?}', $uid, Env::get('del'));
42 }
43
44 if (Env::has('rel') && !Env::has('valider')) {
45 require_once('marketing.inc.php');
46 list($to, $title, $text) = mark_text_mail($uid, Env::get('rel'));
47 $from = mark_from_mail($uid, Env::get('rel'));
48 $page->assign('rel_from_user', $from);
49 $page->assign('rel_from_staff', "\"Equipe Polytechnique.org\" <register@polytechnique.org>");
50 $page->assign('rel_to', $to);
51 $page->assign('rel_title', $title);
52 $page->assign('rel_text', $text);
53 }
54
55 if (Env::get('valider') == 'Envoyer') {
56 require_once('marketing.inc.php');
57 mark_send_mail($uid, Env::get('rel'), Env::get('from'), Env::get('to'), Env::get('title'), Env::get('message'));
58 $page->trig("Mail envoyé");
59 }
60
61 if (Env::has('relance')) {
62 require_once('marketing.inc.php');
63 if (relance($uid)) {
64 $page->trig('relance faite');
65 }
66 }
67
68 if (Env::get('action') == 'ajouter') {
69 $globals->xdb->execute(
70 "INSERT INTO register_marketing
71 SET uid = {?}, sender = {?}, email = {?},
72 date = NOW(), type = {?}",
73 $uid, Session::get('uid'), Env::get('email'), Env::get('type'));
74 }
75
76 $res = $globals->xdb->iterator(
77 "SELECT r.*, a.alias
78 FROM register_marketing AS r
79 INNER JOIN aliases AS a ON (r.sender=a.id AND a.type = 'a_vie')
80 WHERE uid={?}
81 ORDER BY date", $uid);
82 $page->assign('addr', $res);
83
84 $res = $globals->xdb->query("SELECT date, relance FROM register_pending WHERE uid = {?}", $uid);
85 if (list($pending, $relance) = $res->fetchOneCell()) {
86 $page->gassign('pending');
87 $page->gassign('relance');
88 }
89
90
91 $page->run();
92
93 // vim:set et sw=4 sws=4 sts=4:
94 ?>