Fixes deprecated features in PHP 5.3.x.
[platal.git] / modules / survey.php
CommitLineData
8fe81c50 1<?php
2/***************************************************************************
12262f13 3 * Copyright (C) 2003-2011 Polytechnique.org *
8fe81c50 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
22class SurveyModule extends PLModule
23{
24 // {{{ function handlers() : registers the different handlers
25 function handlers()
26 {
27 return array(
eb5a266d
SJ
28 'survey' => $this->make_hook('index', AUTH_PUBLIC),
29 'survey/vote' => $this->make_hook('vote', AUTH_PUBLIC),
30 'survey/result' => $this->make_hook('result', AUTH_PUBLIC),
31 'survey/edit' => $this->make_hook('edit', AUTH_COOKIE),
32 'survey/ajax' => $this->make_hook('ajax', AUTH_COOKIE),
33 'survey/admin' => $this->make_hook('admin', AUTH_MDP, 'admin'),
34 'survey/admin/edit' => $this->make_hook('adminEdit', AUTH_MDP, 'admin'),
8fe81c50 35 'survey/admin/valid' => $this->make_hook('adminValidate', AUTH_MDP, 'admin'),
eb5a266d 36 'survey/admin/del' => $this->make_hook('adminDelete', AUTH_MDP, 'admin'),
8fe81c50 37 );
38 }
39 // }}}
40
41 // {{{ function handler_index() : lists all available surveys
26ba053e 42 function handler_index($page, $action = null)
8fe81c50 43 {
460d8f55 44 $this->load('survey.inc.php');
8fe81c50 45 $page->changeTpl('survey/index.tpl');
5c6e38d7 46 $page->assign('survey_current', Survey::retrieveList('c'));
47 $page->assign('survey_old', Survey::retrieveList('o'));
48 $page->assign('survey_modes', Survey::getModes(false));
49 }
50 // }}}
51
9f01f40b 52 // {{{ function handler_vote() : handles the vote to a survey
26ba053e 53 function handler_vote($page, $id = -1)
5c6e38d7 54 {
55 if (Post::has('survey_cancel')) { // if the user cancels, returns to index
26ba053e 56 return $this->handler_index($page);
5c6e38d7 57 }
58 $id = intval($id);
59 if ($id == -1) {
cd723c19 60 return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
5c6e38d7 61 }
460d8f55 62 $this->load('survey.inc.php');
5c6e38d7 63 $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
64 if ($survey == null || !$survey->isValid()) {
797d27db 65 return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
5c6e38d7 66 } elseif ($survey->isEnded()) {
cd723c19 67 return $this->show_error($page, "Le sondage ".$survey->getTitle()." est terminé.", 'survey');
5c6e38d7 68 }
9f01f40b 69 if (!$this->check_surveyPerms($page, $survey)) {
6997b099 70 return PL_DO_AUTH;
5c6e38d7 71 }
72 if (Post::has('survey_submit')) { // checks if the survey has already been filled in
95fb3c74
PC
73 // admins can see the survey but not vote
74 if (!$this->check_surveyPerms($page, $survey, false, false)) {
75 return PL_DO_AUTH;
76 }
5c6e38d7 77 $uid = 0;
78 if (!$survey->isMode(Survey::MODE_ALL)) { // if survey is restriced to alumni
79 $uid = S::v('uid');
80 if ($survey->hasVoted($uid)) { // checks whether the user has already voted
cd723c19 81 return $this->show_error($page, "Tu as déjà voté à ce sondage.", 'survey');
5c6e38d7 82 }
83 }
84 $survey->vote($uid, Post::v('survey'.$id)); // performs vote
cd723c19 85 $this->show_success($page, "Ta réponse a bien été prise en compte. Merci d'avoir participé à ce sondage.", 'survey');
5c6e38d7 86 } else { // offers to fill in the survey
87 if ($survey->isMode(Survey::MODE_ALL) || !$survey->hasVoted(S::v('uid'))) {
88 $page->assign('survey_votemode', true);
89 } else {
cd723c19 90 $page->assign('survey_warning', "Tu as déjà voté à ce sondage.");
5c6e38d7 91 }
92 //$page->assign('survey_id', $id);
93 $this->show_survey($page, $survey);
94 }
8fe81c50 95 }
96 // }}}
97
9f01f40b 98 // {{{ function handler_result() : show the results of the votes to a survey
4b8c8634 99 function handler_result($page, $id = -1, $show = 'all')
9f01f40b 100 {
101 $id = intval($id);
102 if ($id == -1) {
cd723c19 103 return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
9f01f40b 104 }
460d8f55 105 $this->load('survey.inc.php');
9f01f40b 106 $survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
107 if ($survey == null || !$survey->isValid()) {
797d27db 108 return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
dd36cc0d 109 } elseif (!$survey->isEnded() && !$survey->canSeeEarlyResults(S::user())) {
cd723c19 110 return $this->show_error($page, "Le sondage ".$survey->getTitle()." n'est pas encore terminé.", 'survey');
9f01f40b 111 }
ad9285e2 112 if (!$survey->canSeeEarlyResults(S::user()) && !$this->check_surveyPerms($page, $survey)) {
6997b099 113 return PL_DO_AUTH;
9f01f40b 114 }
4b8c8634 115 if ($show == 'csv') {
3cb500d5 116 pl_content_headers("text/csv");
3cf01f9e 117 header('Content-Disposition: attachment; filename="'.addslashes($survey->getTitle()).'.csv"');
4b8c8634 118 echo $survey->toCSV();
119 exit;
120 } else {
121 $page->assign('survey_resultmode', true);
122 $this->show_survey($page, $survey);
123 }
9f01f40b 124 }
125 // }}}
126
8fe81c50 127 // {{{ function handler_admin() : index of admin mode
26ba053e 128 function handler_admin($page, $id = -1)
8fe81c50 129 {
460d8f55 130 $this->load('survey.inc.php');
56c6950a 131 $this->clear_session();
132 if ($id == -1) {
133 $page->changeTpl('survey/admin.tpl');
5c6e38d7 134 $page->assign('survey_waiting', Survey::retrieveList('w'));
135 $page->assign('survey_current', Survey::retrieveList('c'));
136 $page->assign('survey_old', Survey::retrieveList('o'));
137 $page->assign('survey_modes', Survey::getModes(false));
56c6950a 138 } else {
cd129064 139 $id = intval($id);
5c6e38d7 140 $survey = Survey::retrieveSurvey($id); // retrieves all survey object structure
56c6950a 141 if ($survey == null) {
797d27db 142 $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
56c6950a 143 }
56c6950a 144 $page->assign('survey_adminmode', true);
56c6950a 145 $this->show_survey($page, $survey);
146 }
8fe81c50 147 }
148 // }}}
149
150 // {{{ function handler_adminEdit() : edits a survey in admin mode
26ba053e 151 function handler_adminEdit($page, $id = -1, $req = -1)
8fe81c50 152 {
797d27db 153 if ($id == -1 || ($id == 'req' && $req == -1)) {
cd723c19 154 return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
56c6950a 155 }
460d8f55 156 $this->load('survey.inc.php');
56c6950a 157 $this->clear_session(); // cleans session (in case there would have been a problem before)
797d27db 158 if ($id == 'req') {
159 $survey = Survey::retrieveSurveyReq($req);
160 if ($survey == null) {
161 return $this->show_error($page, "Sondage introuvable.", 'survey/admin');
162 }
163 $this->store_session($survey, $req, true);
164 } else {
165 $id = intval($id);
166 $survey = Survey::retrieveSurvey($id); // retrieves the survey in database
167 if ($survey == null) {
168 return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
169 }
170 $this->store_session($survey, $id);
171 }
8fe81c50 172 $this->handler_edit($page, 'show'); // calls handler_edit, but in admin mode since 'survey_id' is in session
173 }
174 // }}}
175
176 // {{{ function handler_adminValidate() : validates a survey (admin mode)
26ba053e 177 function handler_adminValidate($page, $id = -1)
8fe81c50 178 {
5c6e38d7 179 $id = Post::i('survey_id', $id);
8fe81c50 180 if (Post::has('survey_cancel')) { // if the admin cancels the validation, returns to the admin index
56c6950a 181 $this->clear_session();
26ba053e 182 return $this->handler_admin($page, $id);
8fe81c50 183 }
8fe81c50 184 if ($id == -1) {
cd723c19 185 return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
8fe81c50 186 }
cd129064 187 $id = intval($id);
460d8f55 188 $this->load('survey.inc.php');
5c6e38d7 189 $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
8fe81c50 190 if ($surveyInfo == null) {
797d27db 191 return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
8fe81c50 192 }
193 if (Post::has('survey_submit')) { // needs a confirmation before validation
5c6e38d7 194 if (Survey::validateSurvey($id)) { // validates the survey (in the database)
cd723c19 195 $this->show_success($page, "Le sondage \"".$surveyInfo['title']."\" a bien été validé, les votes sont maintenant ouverts.", 'survey/admin');
8fe81c50 196 } else {
797d27db 197 $this->show_error($page, '', 'survey/admin');
8fe81c50 198 }
199 } else { // asks for a confirmation
cd723c19 200 $this->show_confirm($page, "Êtes-vous certain de vouloir valider le sondage \"".$surveyInfo['title']."\" ? "
201 ."Les votes seront immédiatement ouverts.", 'admin/valid', array('id' => $id));
8fe81c50 202 }
203 }
204 // }}}
205
206 // {{{ function handler_adminDelete() : deletes a survey (admin mode)
26ba053e 207 function handler_adminDelete($page, $id = -1)
8fe81c50 208 {
5c6e38d7 209 $id = Post::i('survey_id', $id);
8fe81c50 210 if (Post::has('survey_cancel')) { // if the admin cancels the suppression, returns to the admin index
26ba053e 211 return $this->handler_admin($page, $id);
8fe81c50 212 }
8fe81c50 213 if ($id == -1) {
cd723c19 214 return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
8fe81c50 215 }
cd129064 216 $id = intval($id);
460d8f55 217 $this->load('survey.inc.php');
5c6e38d7 218 $surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
8fe81c50 219 if ($surveyInfo == null) {
797d27db 220 return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
8fe81c50 221 }
222 if (Post::has('survey_submit')) { // needs a confirmation before suppression
5c6e38d7 223 if (Survey::deleteSurvey($id)) { // deletes survey in database
cd723c19 224 $this->show_success($page, "Le sondage \"".$surveyInfo['title']."\" a bien été supprimé, ainsi que tous les votes le concernant.", 'survey/admin');
8fe81c50 225 } else {
797d27db 226 $this->show_error($page, '', 'survey/admin');
8fe81c50 227 }
228 } else { // asks for a confirmation
cd723c19 229 $this->show_confirm($page, "Êtes-vous certain de vouloir supprimer le sondage \"".$surveyInfo['title']."\" ?", 'admin/del', array('id' => $id));
8fe81c50 230 }
231 }
232 // }}}
233
234 // {{{ function handler_edit() : edits a survey (in normal mode unless called by handler_adminEdit() )
26ba053e 235 function handler_edit($page, $action = 'show', $qid = 'root')
8fe81c50 236 {
460d8f55 237 $this->load('survey.inc.php');
8fe81c50 238 $action = Post::v('survey_action', $action);
239 $qid = Post::v('survey_qid', $qid);
240 if (Post::has('survey_cancel')) { // after cancelling changes, shows the survey
241 if (S::has('survey')) {
242 $action = 'show';
243 } else { // unless no editing has been done at all (shows to the surveys index page)
244 return $this->handler_index($page);
245 }
246 }
56c6950a 247 $page->assign('survey_editmode', true);
8fe81c50 248 if (S::has('survey_id')) { // if 'survey_id' is in session, it means we are modifying a survey in admin mode
56c6950a 249 $page->assign('survey_updatemode', true);
8fe81c50 250 }
251 if ($action == 'show' && !S::has('survey')) {
252 $action = 'new';
253 }
254 if ($action == 'question') { // {{{ modifies an existing question
255 if (Post::has('survey_submit')) { // if the form has been submitted, makes the modifications
256 $survey = unserialize(S::v('survey'));
257 $args = Post::v('survey_question');
5c6e38d7 258 if (!$survey->editQuestion($qid, $args)) { // update the survey object structure
797d27db 259 return $this->show_error($page, '', 'survey/edit');
8fe81c50 260 }
261 $this->show_survey($page, $survey);
56c6950a 262 $this->store_session($survey);
8fe81c50 263 } else { // if a form has not been submitted, shows modification form
264 $survey = unserialize(S::v('survey'));
5c6e38d7 265 $current = $survey->toArray($qid); // gets the current parameters of the question
8fe81c50 266 if ($current == null) {
797d27db 267 return $this->show_error($page, '', 'survey/edit');
8fe81c50 268 }
269 $this->show_form($page, $action, $qid, $current['type'], $current);
270 } // }}}
271 } elseif ($action == 'new') { // {{{ create a new survey : actually store the root question
272 if (Post::has('survey_submit')) { // if the form has been submitted, creates the survey
56c6950a 273 $this->clear_session();
5c6e38d7 274 $survey = new Survey(Post::v('survey_question')); // creates the object structure
8fe81c50 275 $this->show_survey($page, $survey);
56c6950a 276 $this->store_session($survey);
8fe81c50 277 } else {
56c6950a 278 $this->clear_session();
8602c852 279 $this->show_form($page, $action, 'root', 'newsurvey');
8fe81c50 280 } // }}}
5c6e38d7 281 } elseif ($action == 'add') { // {{{ adds a new question
8fe81c50 282 if (Post::has('survey_submit')) { // if the form has been submitted, adds the question
283 $survey = unserialize(S::v('survey'));
5c6e38d7 284 if (!$survey->addQuestion($qid, $survey->factory(Post::v('survey_type'), Post::v('survey_question')))) {
797d27db 285 return $this->show_error($page, '', 'survey/edit');
8fe81c50 286 }
287 $this->show_survey($page, $survey);
56c6950a 288 $this->store_session($survey);
8fe81c50 289 } else {
290 $this->show_form($page, $action, $qid);
291 } // }}}
292 } elseif ($action == 'del') { // {{{ deletes a question
293 if (Post::has('survey_submit')) { // if a confirmation has been sent, deletes the question
294 $survey = unserialize(S::v('survey'));
5c6e38d7 295 if (!$survey->delQuestion(Post::v('survey_qid'))) { // deletes the node in the survey object structure
797d27db 296 return $this->show_error($page, '', 'survey/edit');
8fe81c50 297 }
298 $this->show_survey($page, $survey);
56c6950a 299 $this->store_session($survey);
8fe81c50 300 } else { // if user has not confirmed, shows a confirmation form
301 $survey = unserialize(S::v('survey'));
5c6e38d7 302 $current = $survey->toArray($qid); // needed to get the title of the question to delete (more user-friendly than an id)
8fe81c50 303 if ($current == null) {
797d27db 304 return $this->show_error($page, '', 'survey/edit');
8fe81c50 305 }
cd723c19 306 $this->show_confirm($page, 'Êtes-vous certain de vouloir supprimer la question intitulé "'.$current['question'].'" ? '
307 .'Attention, cela supprimera en même temps toutes les questions qui dépendent de celle-ci.',
8fe81c50 308 'edit', array('action' => 'del', 'qid' => $qid));
309 } // }}}
310 } elseif ($action == 'show') { // {{{ simply shows the survey in its current state
311 $this->show_survey($page, unserialize(S::v('survey'))); // }}}
312 } elseif ($action == 'valid') { // {{{ validates the proposition, i.e stores the proposition in the database
313 // but an admin will still need to validate the survey before it is activated
314 if (Post::has('survey_submit')) { // needs a confirmation before storing the proposition
315 $survey = unserialize(S::v('survey'));
316 if (S::has('survey_id')) { // if 'survey_id' is in session, we are modifying an existing survey (in admin mode) instead of proposing a new one
797d27db 317 $link = (S::has('survey_validate'))? 'admin/validate' : 'survey/admin';
5c6e38d7 318 if ($survey->updateSurvey()) { // updates the database according the new survey object structure
cd723c19 319 $this->show_success($page, "Les modifications sur le sondage ont bien été enregistrées.", $link);
8fe81c50 320 } else {
797d27db 321 $this->show_error($page, '', $link);
8fe81c50 322 }
323 } else { // if no 'survey_id' is in session, we are indeed proposing a new survey
5c6e38d7 324 if ($survey->proposeSurvey()) { // stores the survey object structure in database
cd723c19 325 $this->show_success($page, "Votre proposition de sondage a bien été enregistrée,
d1fa9d16 326 elle est en attente de validation par un administrateur du site.", 'survey');
8fe81c50 327 } else {
797d27db 328 $this->show_error($page, '', 'survey');
8fe81c50 329 }
330 }
56c6950a 331 $this->clear_session();
8fe81c50 332 } else { // asks for a confirmation if it has not been sent
333 $survey = unserialize(S::v('survey'));
334 $errors = $survey->checkSyntax();
335 if (!is_null($errors)) {
797d27db 336 $this->show_error($page, "", 'survey/edit', $errors);
8fe81c50 337 } else {
338 if (S::has('survey_id')) {
88339f38 339 $this->show_confirm($page, "Veuillez confirmer l'enregistrement des modifications apportées à ce sondage.", 'edit', array('action' => 'valid'));
8fe81c50 340 } else {
341 $this->show_confirm($page, "Veuillez confirmer l'envoi de cette proposition de sondage.", 'edit', array('action' => 'valid'));
342 }
343 }
344 } // }}}
345 } elseif ($action == 'cancel') { // {{{ cancels the creation/modification of a survey
346 if (Post::has('survey_submit')) { // needs a confirmation
797d27db 347 if (S::has('survey_id')) { // only possible when modifying a survey in admin mode
348 if (S::has('survey_validate')) { // if a link has been supplied, uses it
349 $this->clear_session();
cd723c19 350 return $this->show_success($page, "Les modifications effectuées ont été annulées", 'admin/validate');
797d27db 351 } else { // else shows the admin index
352 $this->clear_session();
353 return $this->handler_admin($page);
354 }
8fe81c50 355 } else {
797d27db 356 $this->clear_session();
8fe81c50 357 return $this->handler_index($page); // else shows the 'normal' index
358 }
359 } else { // asks for a confirmation if it has not been sent
26ba053e 360 $this->show_confirm($page, "Êtes-vous certain de vouloir annuler totalement l'édition de ce sondage ? Attention, "
cd723c19 361 ."toutes les données éditées jusque là seront définitivement perdues.",
8fe81c50 362 'edit', array('action' => $action));
363 }
364 } // }}}
365 }
366 // }}}
eaf30d86 367
8fe81c50 368 // {{{ function handler_ajax() : some ajax in editing a new question (for now, there may be a little more later)
26ba053e 369 function handler_ajax($page, $type)
8fe81c50 370 {
460d8f55 371 $this->load('survey.inc.php');
3cb500d5 372 pl_content_headers("text/html");
5c6e38d7 373 if (Survey::isType($type)) { // when type has been chosen, the form is updated to fit exactly the type of question chosen
8fe81c50 374 $page->changeTpl('survey/edit_new.tpl', NO_SKIN);
5c6e38d7 375 $page->assign('survey_types', Survey::getTypes());
8fe81c50 376 $page->assign('survey_type', $type);
377 }
378 }
379 // }}}
380
56c6950a 381 // {{{ function clear_session() : clears the data stored in session
382 function clear_session()
383 {
384 S::kill('survey');
385 S::kill('survey_id');
797d27db 386 S::kill('survey_validate');
56c6950a 387 }
388 // }}}
389
390 // {{{ function store_session() : serializes and stores survey (and survey_id) in session
797d27db 391 function store_session($survey, $survey_id = -1, $survey_validate = false)
56c6950a 392 {
393 $_SESSION['survey'] = serialize($survey);
394 if ($survey_id != -1) {
395 $_SESSION['survey_id'] = $survey_id;
396 }
797d27db 397 if ($survey_validate) {
398 $_SESSION['survey_validate'] = true;
399 }
56c6950a 400 }
401 // }}}
402
9f01f40b 403 // {{{ function check_surveyPerms() : checks the particular surveys access permissions
26ba053e 404 function check_surveyPerms($page, $survey, $silent = false, $admin_allowed = true)
9f01f40b 405 {
460d8f55 406 $this->load('survey.inc.php');
12678e90
PC
407 if ($survey->isMode(Survey::MODE_ALL)) { // if the survey is not reserved to alumni
408 return true;
409 }
410 if (!S::logged()) {
411 return false;
412 }
413 $profile = S::user()->profile();
414 if (!$profile) {
415 return false;
416 }
417 // checks promotion
418 $allowed = false;
419 foreach ($profile->yearspromo() as $p) {
420 if ($survey->checkPromo($p)) {
421 $allowed = true;
422 break;
9f01f40b 423 }
424 }
12678e90
PC
425 if ($allowed) {
426 return true;
427 }
95fb3c74
PC
428 if (S::admin() && $admin_allowed) {
429 if (!$silent) {
430 $page->trigWarning('Tu as accès à ce sondage car tu es administrateur du site.');
431 }
432 return true;
433 }
12678e90
PC
434 if (!$silent) {
435 $page->kill("Tu n'as pas accès à ce sondage car il est réservé à d'autres promotions.");
436 }
437 return false;
9f01f40b 438 }
439 // }}}
440
8fe81c50 441 // {{{ function show_survey() : calls the template to display a survey, for editing, voting, or consulting the results
26ba053e 442 function show_survey($page, $survey)
8fe81c50 443 {
56c6950a 444 $page->changeTpl('survey/show_root.tpl');
8fe81c50 445 $page->assign('survey', $survey->toArray());
5c6e38d7 446 $page->assign('survey_modes', Survey::getModes());
8fe81c50 447 }
448 // }}}
449
450 // {{{ function show_form() : calls the template to display the editing form
26ba053e 451 function show_form($page, $action, $qid, $type = 'new', $current = null)
8fe81c50 452 {
453 $page->changeTpl('survey/edit_survey.tpl');
454 $page->assign('survey_action', $action);
455 $page->assign('survey_qid', $qid);
456 $page->assign('survey_formaction', './survey/edit');
457 $page->assign('survey_type', $type);
458 if (!is_null($current) && is_array($current)) {
459 $page->assign('survey_current', $current);
460 } elseif ($type == 'new') {
461 $page->addJsLink('ajax.js');
5c6e38d7 462 $page->assign('survey_types', Survey::getTypes());
463 }
8602c852 464 if ($type == 'root' || $type == 'newsurvey') {
5c6e38d7 465 $page->assign('survey_modes', Survey::getModes());
8fe81c50 466 }
467 }
468 // }}}
eaf30d86 469
8fe81c50 470 // {{{ function show_confirm() : calls the template to display a confirm form
26ba053e 471 function show_confirm($page, $message, $formaction, $formhidden = null)
8fe81c50 472 {
473 $page->changeTpl('survey/confirm.tpl');
474 $page->assign('survey_message', $message);
475 $page->assign('survey_formaction', './survey/'.$formaction);
476 $page->assign('survey_formhidden', $formhidden);
477 }
478 // }}}
479
480 // {{{ function show_error() : calls the template to display an error message
26ba053e 481 function show_error($page, $message, $link = "", $errArray = null)
8fe81c50 482 {
483 $page->changeTpl('survey/error.tpl');
484 $page->assign('survey_message', $message);
797d27db 485 $page->assign('survey_link', $link); // 'return' link to let the user leave the page
8fe81c50 486 if (!is_null($errArray)) {
487 $page->assign('survey_errors', $errArray);
488 }
6997b099 489
8fe81c50 490 }
491 // }}}
492
493 // {{{ function show_success() : calls the template to display a success message
26ba053e 494 function show_success($page, $message = "", $link = "")
8fe81c50 495 {
496 $page->changeTpl('survey/success.tpl');
497 $page->assign('survey_message', $message);
797d27db 498 $page->assign('survey_link', $link); // 'return' link to let the user leave the page
8fe81c50 499 }
500 // }}}
501}
502
8602c852 503// vim:set et sw=4 sts=4 ts=4 foldmethod=marker enc=utf-8:
8fe81c50 504?>