Commit | Line | Data |
---|---|---|
797d27db | 1 | <?php |
2 | /*************************************************************************** | |
ba6ae046 | 3 | * Copyright (C) 2003-2013 Polytechnique.org * |
797d27db | 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 SurveyReq | |
23 | ||
24 | class SurveyReq extends Validate | |
25 | { | |
26 | // {{{ properties | |
27 | public $title; | |
28 | public $description; | |
29 | public $end; | |
30 | public $mode; | |
31 | public $promos; | |
32 | public $questions; | |
33 | // }}} | |
34 | // {{{ constructor | |
35 | ||
26ba053e | 36 | public function __construct($_title, $_description, $_end, $_mode, $_promos, $_questions, User $_user) |
797d27db | 37 | { |
5daf68f6 | 38 | parent::__construct($_user, false, 'surveys'); |
797d27db | 39 | $this->title = $_title; |
40 | $this->description = $_description; | |
41 | $this->end = $_end; | |
42 | $this->mode = $_mode; | |
43 | $this->promos = $_promos; | |
44 | $this->questions = $_questions; | |
45 | } | |
46 | ||
47 | // }}} | |
48 | // {{{ function formu() | |
49 | ||
50 | public function formu() | |
51 | { | |
52 | return 'include/form.valid.surveys.tpl'; | |
53 | } | |
54 | ||
55 | // }}} | |
56 | // {{{ function _mail_subj | |
eaf30d86 | 57 | |
797d27db | 58 | protected function _mail_subj() |
59 | { | |
60 | return "[Polytechnique.org/SONDAGES] Proposition de sondage"; | |
61 | } | |
62 | ||
63 | // }}} | |
64 | // {{{ function _mail_body | |
65 | ||
66 | protected function _mail_body($isok) | |
67 | { | |
a3923909 | 68 | $you_have = ($this->formal ? 'vous aviez' : 'tu avais'); |
797d27db | 69 | if ($isok) { |
a3923909 | 70 | return " Le sondage que $you_have proposé vient d'être validé."; |
797d27db | 71 | } else { |
a3923909 | 72 | return " Le sondage que $you_have proposé a été refusé."; |
797d27db | 73 | } |
74 | } | |
75 | ||
76 | // }}} | |
77 | // {{{ function updateReq() | |
78 | ||
79 | public function updateReq($_title, $_description, $_end, $_mode, $_promos, $_questions) | |
80 | { | |
81 | $this->title = $_title; | |
82 | $this->description = $_description; | |
83 | $this->end = $_end; | |
84 | $this->mode = $_mode; | |
85 | $this->promos = $_promos; | |
86 | $this->questions = $_questions; | |
87 | return $this->update(); | |
88 | } | |
89 | ||
90 | // }}} | |
91 | // {{{ function commit() | |
92 | ||
93 | public function commit() | |
94 | { | |
7f376ae0 SJ |
95 | $sql = 'INSERT INTO surveys |
96 | SET questions = {?}, title = {?}, description = {?}, | |
97 | uid = {?}, end = {?},mode = {?}, promos = {?}'; | |
5daf68f6 | 98 | return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->user->id(), $this->end, $this->mode, $this->promos); |
797d27db | 99 | } |
100 | ||
101 | // }}} | |
102 | } | |
103 | ||
104 | // }}} | |
105 | ||
106 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
107 | ?> |