3 * GForge Survey Facility
5 * Portions Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
11 * This file is part of GForge.
13 * GForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * GForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 require_once('pre.php');
29 require_once('www/survey/survey_utils.php');
30 require_once('www/survey/admin/survey_utils.php');
33 $group_id = getIntFromRequest('group_id');
34 $survey_id = getIntFromRequest('survey_id');
35 survey_header(array('title'=>$Language->getText('survey_edit','title')));
37 if (!session_loggedin() || !user_ismember($group_id,'A')) {
38 echo "<h1>" .$Language->getText('survey_edit','permission_denied')."</h1>";
39 survey_footer(array());
43 if (getStringFromRequest('post_changes')) {
44 $survey_title = $survey_title;
45 $survey_questions = $survey_questions;
46 $is_active = $is_active;
48 if (!isset($survey_title) || $survey_title == "")
50 $feedback .= $Language->getText('survey_edit','survey_title_required');
52 elseif (!isset($survey_questions) || $survey_questions == "")
54 $feedback .= $Language->getText('survey_edit','survey_question_required');
56 if (!isset($survey_id) || !isset($group_id) || $survey_id == "" || $group_id == "")
58 $feedback .= $Language->getText('survey_edit','missing_date');
67 $sql="UPDATE surveys SET survey_title='".htmlspecialchars($survey_title)."', survey_questions='$survey_questions', is_active='$is_active' ".
68 "WHERE survey_id='$survey_id' AND group_id='$group_id'";
69 $result=db_query($sql);
70 if (db_affected_rows($result) < 1) {
71 $feedback .= $Language->getText('survey_edit','update_failed');
74 $feedback .= $Language->getText('survey_edit','update_successful');
80 Get this survey out of the DB
83 $sql="SELECT * FROM surveys WHERE survey_id='$survey_id' AND group_id='$group_id'";
84 $result=db_query($sql);
85 $survey_title=db_result($result, 0, "survey_title");
86 $survey_questions=db_result($result, 0, "survey_questions");
87 $is_active=db_result($result, 0, "is_active");
90 <script type="text/javascript">
94 function show_questions() {
95 newWindow = open("","occursDialog","height=600,width=500,scrollbars=yes,resizable=yes");
96 newWindow.location=('show_questions.php?group_id=<?php echo $group_id; ?>');
102 <span class="warning"><?php echo $Language->getText('survey_edit','warning_survey_after_response'); ?></span>
104 <p><?php echo $Language->getText('survey_edit','change_after_already_response'); ?>.</p>
106 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
107 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
108 <input type="hidden" name="post_changes" value="y" />
109 <strong><?php echo $Language->getText('survey_edit','name_off_survey'); ?>:</strong>
111 <input type="hidden" name="survey_id" value="<?php echo $survey_id; ?>" />
112 <input type="text" name="survey_title" value="<?php echo $survey_title; ?>" length="60" maxlength="150" />
114 <strong><?php echo $Language->getText('survey_edit','question'); ?>:</strong>
116 <?php echo $Language->getText('survey_edit','list_question_numbers'); ?>
117 <br /><input type="text" name="survey_questions" value="<?php echo $survey_questions; ?>" length="90" maxlength="1500" /></p>
119 <strong><?php echo $Language->getText('survey_edit','is_active'); ?></strong>
120 <br /><input type="radio" name="is_active" value="1"<?php if ($is_active=='1') { echo ' checked="checked"'; } ?> /> <?php echo $Language->getText('survey_edit','yes'); ?>
121 <br /><input type="radio" name="is_active" value="0"<?php if ($is_active=='0') { echo ' hecked="checked"'; } ?> /> <?php echo $Language->getText('survey_edit','no'); ?></p>
123 <input type="submit" name="submit" value="<?php echo $Language->getText('survey_edit','submit_changes'); ?>"></p>
130 Select all surveys from the database
133 $sql="SELECT * FROM surveys WHERE group_id='$group_id'";
135 $result=db_query($sql);
140 <input type="button" name="none" value="<?php echo $Language->getText('survey_edit','show_existing_questions'); ?>" onclick="show_questions()" />
143 <h2><?php echo $Language->getText('survey_edit','existing_surveys'); ?></h2>
146 ShowResultsEditSurvey($result);
148 survey_footer(array());