4 * SourceForge Survey Facility
6 * SourceForge: Breaking Down the Barriers to Open Source Development
7 * Copyright 1999-2001 (c) VA Linux Systems
8 * http://sourceforge.net
15 require_once('pre.php');
16 require_once('www/survey/survey_utils.php');
17 require_once('www/survey/admin/survey_utils.php');
20 survey_header(array('title'=>$Language->getText('survey_edit','tilte'),'pagename'=>'survey_admin_edit_survey'));
22 if (!session_loggedin() || !user_ismember($group_id,'A')) {
23 echo "<h1>" .$Language->getText('survey_edit','permission_denied')."</h1>";
24 survey_footer(array());
29 if (!isset($survey_title) || $survey_title == "")
31 $feedback .= $Language->getText('survey_edit','survey_title_required');
33 elseif (!isset($survey_questions) || $survey_questions == "")
35 $feedback .= $Language->getText('survey_edit','survey_question_required');
37 if (!isset($survey_id) || !isset($group_id) || $survey_id == "" || $group_id == "")
39 $feedback .= $Language->getText('survey_edit','missing_date');
48 $sql="UPDATE surveys SET survey_title='".htmlspecialchars($survey_title)."', survey_questions='$survey_questions', is_active='$is_active' ".
49 "WHERE survey_id='$survey_id' AND group_id='$group_id'";
50 $result=db_query($sql);
51 if (db_affected_rows($result) < 1) {
52 $feedback .= $Language->getText('survey_edit','update_failed');
55 $feedback .= $Language->getText('survey_edit','update_successful');
61 Get this survey out of the DB
64 $sql="SELECT * FROM surveys WHERE survey_id='$survey_id' AND group_id='$group_id'";
65 $result=db_query($sql);
66 $survey_title=db_result($result, 0, "survey_title");
67 $survey_questions=db_result($result, 0, "survey_questions");
68 $is_active=db_result($result, 0, "is_active");
71 <script type="text/javascript">
75 function show_questions() {
76 newWindow = open("","occursDialog","height=600,width=500,scrollbars=yes,resizable=yes");
77 newWindow.location=('show_questions.php?group_id=<?php echo $group_id; ?>');
83 <h3><span style="color:red"><?php echo $Language->getText('survey_edit','warning_survey_after_response'); ?></span></h3>
85 <p><?php echo $Language->getText('survey_edit','change_after_already_response'); ?>.</p>
87 <form action="<?php echo $PHP_SELF; ?>" method="post">
88 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
89 <input type="hidden" name="post_changes" value="y" />
90 <strong><?php echo $Language->getText('survey_edit','name_off_survey'); ?>:</strong>
92 <input type="hidden" name="survey_id" value="<?php echo $survey_id; ?>" />
93 <input type="text" name="survey_title" value="<?php echo $survey_title; ?>" length="60" maxlength="150" />
95 <strong><?php echo $Language->getText('survey_edit','question'); ?>:</strong>
97 <?php echo $Language->getText('survey_edit','list_question_numbers'); ?>
98 <br /><input type="text" name="survey_questions" value="<?php echo $survey_questions; ?>" length="90" maxlength="1500" /></p>
100 <strong><?php echo $Language->getText('survey_edit','is_active'); ?></strong>
101 <br /><input type="radio" name="is_active" value="1"<?php if ($is_active=='1') { echo ' checked="checked"'; } ?> /> <?php echo $Language->getText('survey_edit','yes'); ?>
102 <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>
104 <input type="submit" name="submit" value="<?php echo $Language->getText('survey_edit','submit_changes'); ?>"></p>
111 Select all surveys from the database
114 $sql="SELECT * FROM surveys WHERE group_id='$group_id'";
116 $result=db_query($sql);
121 <input type="button" name="none" value="<?php echo $Language->getText('survey_edit','show_existing_questions'); ?>" onclick="show_questions()" />
124 <h2><?php echo $Language->getText('survey_edit','existing_surveys'); ?></h2>
127 ShowResultsEditSurvey($result);
129 survey_footer(array());