3 * Survey Facility: Question handle program
5 * Copyright 2004 (c) GForge Team
6 * Copyright 2010 (c) FusionForge Team
7 * Copyright (C) 2010-2011 Alain Peyrat - Alcatel-Lucent
8 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once('../../env.inc.php');
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'survey/Survey.class.php';
29 require_once $gfcommon.'survey/SurveyFactory.class.php';
30 require_once $gfcommon.'survey/SurveyQuestion.class.php';
31 require_once $gfcommon.'survey/SurveyQuestionFactory.class.php';
32 require_once $gfwww.'survey/include/SurveyHTML.class.php';
34 $group_id = getIntFromRequest('group_id');
35 $survey_id = getIntFromRequest('survey_id');
37 /* We need a group_id */
42 $g = group_get_object($group_id);
43 if (!$g || !is_object($g) || $g->isError()) {
48 $sh = new SurveyHtml();
49 $s = new Survey($g, $survey_id);
51 if (!session_loggedin() || !user_ismember($group_id,'A')) {
53 echo '<div class="error">' . _('Permission denied') . '</div>';
58 if (getStringFromRequest('post')=="Y") {
59 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
60 exit_form_double_submit('surveys');
62 $survey_title = getStringFromRequest('survey_title');
63 $to_add = getStringFromRequest('to_add');
64 $to_del = getStringFromRequest('to_del');
65 $is_active = getStringFromRequest('is_active');
67 if ($survey_id) { /* Modify */
68 $s->update($survey_title, $to_add, $to_del, $is_active);
69 $feedback = _('Update Successful');
71 $s->create($survey_title, $to_add, $is_active);
72 $feedback = _('Survey Added');
77 if (getStringFromRequest('updown')=="Y") {
78 $question_id = getIntFromRequest('question_id');
79 $is_up = getStringFromRequest('is_up');
81 $s->updateOrder($question_id, $is_up);
82 $feedback = _('Update Successful');
85 /* Error on previous transactions? */
87 $error_msg = $s->getErrorMessage();
88 form_release_key(getStringFromRequest("form_key"));
91 $title = $survey_id ? _('Edit a Survey') : _('Add a Survey');
92 $sh->header(array('title'=>$title));
94 echo ($sh->ShowAddSurveyForm($s));
96 /* Show list of Survey */
97 $sf = new SurveyFactory($g);
98 $ss = & $sf->getSurveys();
100 echo '<p class="warning_msg">' . _('No Survey Question is found') . '</p>';
102 echo($sh->showSurveys($ss, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1));
105 $sh->footer(array());