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';
36 $group_id = getIntFromRequest('group_id');
37 $survey_id = getIntFromRequest('survey_id');
39 /* We need a group_id */
44 $g = group_get_object($group_id);
45 if (!$g || !is_object($g) || $g->isError()) {
50 $sh = new SurveyHTML();
51 $s = new Survey($g, $survey_id);
53 if (!session_loggedin() || !forge_check_perm('project_admin', $group_id)) {
55 echo $HTML->error_msg(_('Permission denied.'));
60 if (getStringFromRequest('post')=="Y") {
61 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
62 exit_form_double_submit('surveys');
64 $survey_title = getStringFromRequest('survey_title');
65 $to_add = getStringFromRequest('to_add');
66 $to_del = getStringFromRequest('to_del');
67 $is_active = getStringFromRequest('is_active');
69 if ($survey_id) { /* Modify */
70 $s->update($survey_title, $to_add, $to_del, $is_active);
71 $feedback = _('Successfully Updated');
73 $s->create($survey_title, $to_add, $is_active);
74 $feedback = _('Survey Added');
79 if (getStringFromRequest('updown')=="Y") {
80 $question_id = getIntFromRequest('question_id');
81 $is_up = getStringFromRequest('is_up');
82 $s->updateOrder($question_id, $is_up);
83 $feedback = _('Successfully Updated');
86 /* Error on previous transactions? */
88 $error_msg = $s->getErrorMessage();
89 form_release_key(getStringFromRequest("form_key"));
92 $title = $survey_id ? _('Edit a Survey') : _('Add a Survey');
93 $sh->header(array('title'=>$title, 'modal'=>1));
95 echo $sh->showAddSurveyForm($s);
97 /* Show list of Survey */
98 $sf = new SurveyFactory($g);
99 $ss = & $sf->getSurveys();
101 echo $HTML->information(_('No Survey is found'));
103 echo $sh->showSurveys($ss, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1);