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 $sh->header(array('title'=>_('Add A Survey')));
39 if (!session_loggedin() || !user_ismember($group_id,'A')) {
40 echo "<h1>". _('Permission denied')."</h1>";
45 if (getStringFromRequest('post')=="Y") {
46 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
47 exit_form_double_submit();
49 $survey_title = getStringFromRequest('survey_title');
50 $to_add = getStringFromRequest('to_add');
51 $to_del = getStringFromRequest('to_del');
52 $is_active = getStringFromRequest('is_active');
54 if ($survey_id) { /* Modify */
55 $s->update($survey_title, $to_add, $to_del, $is_active);
56 $feedback = _('UPDATE SUCCESSFUL');
58 $s->create($survey_title, $to_add, $is_active);
59 $feedback = _('Survey Inserted');
64 if (getStringFromRequest('updown')=="Y") {
65 $question_id = getIntFromRequest('question_id');
66 $is_up = getStringFromRequest('is_up');
68 $s->updateOrder($question_id, $is_up);
69 $feedback = _('UPDATE SUCCESSFUL');
72 /* Error on previous transactions? */
74 $feedback = $s->getErrorMessage();
75 form_release_key(getStringFromRequest("form_key"));
78 echo ($sh->ShowAddSurveyForm($s));
80 /* Show list of Servey */
81 $sf = new SurveyFactory($g);
82 $ss = & $sf->getSurveys();
84 echo (_('No Survey Question is found'));
86 echo($sh->ShowSurveys($ss, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1));