3 * GForge Survey Facility
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge 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
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 require_once('../../env.inc.php');
27 require_once $gfwww.'include/pre.php';
28 require_once $gfwww.'survey/survey_utils.php';
29 require_once $gfwww.'survey/admin/survey_utils.php';
32 $group_id = getIntFromRequest('group_id');
33 $survey_id = getIntFromRequest('survey_id');
34 survey_header(array('title'=>_('Edit A Survey')));
36 if (!session_loggedin() || !user_ismember($group_id,'A')) {
37 echo '<div class="error">'._('Permission denied').'</div>';
38 survey_footer(array());
42 if (getStringFromRequest('post_changes')) {
43 $survey_title = $survey_title;
44 $survey_questions = $survey_questions;
45 $is_active = $is_active;
47 if (!isset($survey_title) || $survey_title == "")
49 $feedback .= _('Update Failed: Survey Title Required');
51 elseif (!isset($survey_questions) || $survey_questions == "")
53 $feedback .= _('Update Failed: Survey Questions Required');
55 if (!isset($survey_id) || !isset($group_id) || $survey_id == "" || $group_id == "")
57 $feedback .= _('Update Failed: Missing Data');
66 $result = db_query_params ('UPDATE surveys SET survey_title=$1, survey_questions=$2, is_active=$3
67 WHERE survey_id=$4 AND group_id=$5',
68 array (htmlspecialchars($survey_title),
73 if (db_affected_rows($result) < 1) {
74 $feedback .= _('Update Failed');
77 $feedback .= _('Update Successful');
83 Get this survey out of the DB
86 $result = db_query_params ('SELECT * FROM surveys WHERE survey_id=$1 AND group_id=$2',
89 $survey_title=db_result($result, 0, "survey_title");
90 $survey_questions=db_result($result, 0, "survey_questions");
91 $is_active=db_result($result, 0, "is_active");
94 <script type="text/javascript">
98 function show_questions() {
99 newWindow = open("","occursDialog","height=600,width=500,scrollbars=yes,resizable=yes");
100 newWindow.location=('show_questions.php?group_id=<?php echo $group_id; ?>');
106 <span class="warning"><?php echo _('WARNING! It is a bad idea to edit a survey after responses have been posted'); ?></span>
108 <p><?php echo _('If you change a survey after you already have responses, your results pages could be misleading or messed up'); ?>.</p>
109 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
110 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
111 <input type="hidden" name="post_changes" value="y" />
112 <strong><?php echo _('Name of Survey'); ?>:</strong>
114 <input type="hidden" name="survey_id" value="<?php echo $survey_id; ?>" />
115 <input type="text" name="survey_title" value="<?php echo $survey_title; ?>" size="60" maxlength="150" />
117 <strong><?php echo _('Questions'); ?>:</strong>
119 <?php echo _('List question numbers, in desired order, separated by commas. <strong>Refer to your list of questions</strong> so you can view the question id\'s. Do <strong>not</strong> include spaces or end your list with a comma.<br /> Ex: 1,2,3,4,5,6,7'); ?>
120 <br /><input type="text" name="survey_questions" value="<?php echo $survey_questions; ?>" length="90" maxlength="1500" /></p>
122 <strong><?php echo _('Is Active'); ?></strong>
123 <br /><input type="radio" name="is_active" value="1"<?php if ($is_active=='1') { echo ' checked="checked"'; } ?> /> <?php echo _('Yes'); ?>
124 <br /><input type="radio" name="is_active" value="0"<?php if ($is_active=='0') { echo ' checked="checked"'; } ?> /> <?php echo _('No'); ?></p>
126 <input type="submit" name="submit" value="<?php echo _('Submit Changes'); ?>"></p>
133 Select all surveys from the database
135 $result = db_query_params ('SELECT * FROM surveys WHERE group_id=$1',
137 $numrows=db_numrows($result);
142 <input type="button" name="none" value="<?php echo _('Show Existing Questions'); ?>" onclick="show_questions()" />
145 <h2><?php echo ngettext('Existing Survey', 'Existing Surveys', $numrows) ?></h2>
148 ShowResultsEditSurvey($result);
150 survey_footer(array());
154 // c-file-style: "bsd"