9cca8b5312b80394e24041aa01583b74a4edf40d
[platal.git] / include / validations / evts.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2007 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 // {{{ class EvtReq
23
24 class EvtReq extends Validate
25 {
26 // {{{ properties
27
28 public $evtid;
29 public $titre;
30 public $texte;
31 public $pmin;
32 public $pmax;
33 public $peremption;
34 public $comment;
35
36 // }}}
37 // {{{ constructor
38
39 public function __construct($_titre, $_texte, $_pmin, $_pmax, $_peremption, $_comment, $_uid)
40 {
41 parent::__construct($_uid, false, 'evts');
42 $this->titre = $_titre;
43 $this->texte = $_texte;
44 $this->pmin = $_pmin;
45 $this->pmax = $_pmax;
46 $this->peremption = $_peremption;
47 $this->comment = $_comment;
48 }
49
50 // }}}
51 // {{{ function formu()
52
53 public function formu()
54 {
55 return 'include/form.valid.evts.tpl';
56 }
57
58 // }}}
59 // {{{ functon editor()
60
61 public function editor()
62 {
63 return 'include/form.valid.edit-evts.tpl';
64 }
65
66 // }}}
67 // {{{ function handle_editor()
68
69 protected function handle_editor()
70 {
71 $this->titre = Env::v('titre');
72 $this->texte = Env::v('texte');
73 $this->pmin = Env::i('promo_min');
74 $this->pmax = Env::i('promo_max');
75 $this->peremption = Env::v('peremption');
76 return true;
77 }
78
79 // }}}
80 // {{{ function _mail_subj
81
82 protected function _mail_subj()
83 {
84 return "[Polytechnique.org/EVENEMENTS] Proposition d'événement";
85 }
86
87 // }}}
88 // {{{ function _mail_body
89
90 protected function _mail_body($isok)
91 {
92 if ($isok) {
93 return " L'annonce que tu avais proposée ({$this->titre}) vient d'être validée.";
94 } else {
95 return " L'annonce que tu avais proposée ({$this->titre}) a été refusée.";
96 }
97 }
98
99 // }}}
100 // {{{ function commit()
101
102 public function commit()
103 {
104 return XDB::execute(
105 "INSERT INTO evenements
106 SET user_id = {?}, creation_date=NOW(), titre={?}, texte={?},
107 peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide')",
108 $this->uid, $this->titre, $this->texte,
109 $this->peremption, $this->pmin, $this->pmax);
110 }
111
112 // }}}
113 }
114
115 // }}}
116
117 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
118 ?>