| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2009 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 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 | |
| 36 | public function __construct($_title, $_description, $_end, $_mode, $_promos, $_questions, User &$_user) |
| 37 | { |
| 38 | parent::__construct($_user, false, 'surveys'); |
| 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 |
| 57 | |
| 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 | { |
| 68 | if ($isok) { |
| 69 | return " Le sondage que tu avais proposé vient d'être validé."; |
| 70 | } else { |
| 71 | return " Le sondage que tu avais proposé a été refusé."; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // }}} |
| 76 | // {{{ function updateReq() |
| 77 | |
| 78 | public function updateReq($_title, $_description, $_end, $_mode, $_promos, $_questions) |
| 79 | { |
| 80 | $this->title = $_title; |
| 81 | $this->description = $_description; |
| 82 | $this->end = $_end; |
| 83 | $this->mode = $_mode; |
| 84 | $this->promos = $_promos; |
| 85 | $this->questions = $_questions; |
| 86 | return $this->update(); |
| 87 | } |
| 88 | |
| 89 | // }}} |
| 90 | // {{{ function commit() |
| 91 | |
| 92 | public function commit() |
| 93 | { |
| 94 | $sql = 'INSERT INTO survey_surveys |
| 95 | SET questions={?}, |
| 96 | title={?}, |
| 97 | description={?}, |
| 98 | author_id={?}, |
| 99 | end={?}, |
| 100 | mode={?}, |
| 101 | promos={?}'; |
| 102 | return XDB::execute($sql, serialize($this->questions), $this->title, $this->description, $this->user->id(), $this->end, $this->mode, $this->promos); |
| 103 | } |
| 104 | |
| 105 | // }}} |
| 106 | } |
| 107 | |
| 108 | // }}} |
| 109 | |
| 110 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
| 111 | ?> |