5 * GForge Survey Facility: Question handle program
7 * Copyright 2004 (c) GForge
12 require_once('../../env.inc.php');
13 require_once $gfwww.'include/pre.php';
14 require_once $gfcommon.'survey/Survey.class.php';
15 require_once $gfcommon.'survey/SurveyFactory.class.php';
16 require_once $gfcommon.'survey/SurveyQuestion.class.php';
17 require_once $gfcommon.'survey/SurveyQuestionFactory.class.php';
18 require_once $gfwww.'survey/include/SurveyHTML.class.php';
20 $group_id = getIntFromRequest('group_id');
21 $survey_id = getIntFromRequest('survey_id');
23 /* We need a group_id */
28 $g =& group_get_object($group_id);
29 if (!$g || !is_object($g) || $g->isError()) {
34 $sh = new SurveyHtml();
35 $s = new Survey($g, $survey_id);
37 if (!session_loggedin() || !user_ismember($group_id,'A')) {
39 echo '<div class="error">' . _('Permission denied') . '</div>';
44 if (getStringFromRequest('post')=="Y") {
45 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
46 exit_form_double_submit();
48 $survey_title = getStringFromRequest('survey_title');
49 $to_add = getStringFromRequest('to_add');
50 $to_del = getStringFromRequest('to_del');
51 $is_active = getStringFromRequest('is_active');
53 if ($survey_id) { /* Modify */
54 $s->update($survey_title, $to_add, $to_del, $is_active);
55 $feedback = _('Update Successful');
57 $s->create($survey_title, $to_add, $is_active);
58 $feedback = _('Survey Inserted');
63 if (getStringFromRequest('updown')=="Y") {
64 $question_id = getIntFromRequest('question_id');
65 $is_up = getStringFromRequest('is_up');
67 $s->updateOrder($question_id, $is_up);
68 $feedback = _('Update Successful');
71 /* Error on previous transactions? */
73 $feedback = $s->getErrorMessage();
74 form_release_key(getStringFromRequest("form_key"));
77 echo ($sh->ShowAddSurveyForm($s));
79 /* Show list of Servey */
80 $sf = new SurveyFactory($g);
81 $ss = & $sf->getSurveys();
83 echo (_('No Survey Question is found'));
85 echo($sh->ShowSurveys($ss, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1));