<?php
/**
- *
- * SourceForge Survey Facility
- *
- * SourceForge: Breaking Down the Barriers to Open Source Development
- * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
- *
- * @version $Id$
- *
- */
-
-
-require_once('pre.php');
-require_once('www/survey/survey_utils.php');
+ * GForge Survey Facility
+ *
+ * Portions Copyright 1999-2001 (c) VA Linux Systems
+ * The rest Copyright 2002-2004 (c) GForge Team
+ * http://gforge.org/
+ *
+ * This file is part of GForge.
+ *
+ * GForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+require_once('../../env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfwww.'survey/survey_utils.php';
+require_once $gfwww.'survey/admin/survey_utils.php';
$is_admin_page='y';
-survey_header(array('title'=>'Edit A Survey','pagename'=>'survey_admin_edit_survey'));
+$group_id = getIntFromRequest('group_id');
+$survey_id = getIntFromRequest('survey_id');
+survey_header(array('title'=>_('Edit A Survey')));
-if (!user_isloggedin() || !user_ismember($group_id,'A')) {
- echo "<H1>Permission Denied</H1>";
+if (!session_loggedin() || !user_ismember($group_id,'A')) {
+ echo '<div class="error">'._('Permission denied').'</div>';
survey_footer(array());
exit;
}
-if ($post_changes) {
- $sql="UPDATE surveys SET survey_title='$survey_title', survey_questions='$survey_questions', is_active='$is_active' ".
- "WHERE survey_id='$survey_id' AND group_id='$group_id'";
- $result=db_query($sql);
- if (db_affected_rows($result) < 1) {
- $feedback .= ' UPDATE FAILED ';
- echo db_error();
- } else {
- $feedback .= ' UPDATE SUCCESSFUL ';
+if (getStringFromRequest('post_changes')) {
+ $survey_title = $survey_title;
+ $survey_questions = $survey_questions;
+ $is_active = $is_active;
+
+ if (!isset($survey_title) || $survey_title == "")
+ {
+ $feedback .= _('Update Failed: Survey Title Required');
+ }
+ elseif (!isset($survey_questions) || $survey_questions == "")
+ {
+ $feedback .= _('Update Failed: Survey Questions Required');
+ }
+ if (!isset($survey_id) || !isset($group_id) || $survey_id == "" || $group_id == "")
+ {
+ $feedback .= _('Update Failed: Missing Data');
+ }
+ else
+ {
+ if ($is_active) {
+ $is_active = 1;
+ } else {
+ $is_active = 0;
+ }
+ $result = db_query_params ('UPDATE surveys SET survey_title=$1, survey_questions=$2, is_active=$3
+WHERE survey_id=$4 AND group_id=$5',
+ array (htmlspecialchars($survey_title),
+ $survey_questions,
+ $is_active,
+ $survey_id,
+ $group_id));
+ if (db_affected_rows($result) < 1) {
+ $feedback .= _('Update Failed');
+ echo db_error();
+ } else {
+ $feedback .= _('Update Successful');
+ }
}
}
Get this survey out of the DB
*/
if ($survey_id) {
- $sql="SELECT * FROM surveys WHERE survey_id='$survey_id' AND group_id='$group_id'";
- $result=db_query($sql);
+ $result = db_query_params ('SELECT * FROM surveys WHERE survey_id=$1 AND group_id=$2',
+ array ($survey_id,
+ $group_id));
$survey_title=db_result($result, 0, "survey_title");
$survey_questions=db_result($result, 0, "survey_questions");
$is_active=db_result($result, 0, "is_active");
}
?>
-<SCRIPT LANGUAGE="JavaScript">
+<script type="text/javascript">
<!--
var timerID2 = null;
// -->
</script>
-<H3><FONT COLOR="RED">WARNING! It is a bad idea to edit a survey after responses have been posted</FONT></H3>
-<P>
-If you change a survey after you already have responses, your results pages could be misleading or messed up.
-<P>
-<FORM ACTION="<?php echo $PHP_SELF; ?>" METHOD="POST">
-<INPUT TYPE="HIDDEN" NAME="group_id" VALUE="<?php echo $group_id; ?>">
-<INPUT TYPE="HIDDEN" NAME="post_changes" VALUE="y">
-<B>Name of Survey:</B>
-<BR>
-<INPUT TYPE="HIDDEN" NAME="survey_id" VALUE="<?php echo $survey_id; ?>">
-<INPUT TYPE="TEXT" NAME="survey_title" VALUE="<?php echo $survey_title; ?>" LENGTH="60" MAXLENGTH="150">
-<P>
-<B>Questions:</B>
-<BR>
-List question numbers, in desired order, separated by commas. <B>Refer to your list of questions</B> so you can view
-the question id's. Do <B>not</B> include spaces or end your list with a comma.
-<BR>
-Ex: 1,2,3,4,5,6,7
-<BR><INPUT TYPE="TEXT" NAME="survey_questions" VALUE="<?php echo $survey_questions; ?>" LENGTH="90" MAXLENGTH="1500"><P>
-<B>Is Active</B>
-<BR><INPUT TYPE="RADIO" NAME="is_active" VALUE="1"<?php if ($is_active=='1') { echo ' CHECKED'; } ?>> Yes
-<BR><INPUT TYPE="RADIO" NAME="is_active" VALUE="0"<?php if ($is_active=='0') { echo ' CHECKED'; } ?>> No
-<P>
-<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Submit Changes">
-</FORM>
+<span class="warning"><?php echo _('WARNING! It is a bad idea to edit a survey after responses have been posted'); ?></span>
+
+<p><?php echo _('If you change a survey after you already have responses, your results pages could be misleading or messed up'); ?>.</p>
+<form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
+<input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
+<input type="hidden" name="post_changes" value="y" />
+<strong><?php echo _('Name of Survey'); ?>:</strong>
+<br />
+<input type="hidden" name="survey_id" value="<?php echo $survey_id; ?>" />
+<input type="text" name="survey_title" value="<?php echo $survey_title; ?>" size="60" maxlength="150" />
+<p>
+<strong><?php echo _('Questions'); ?>:</strong>
+<br />
+<?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'); ?>
+<br /><input type="text" name="survey_questions" value="<?php echo $survey_questions; ?>" length="90" maxlength="1500" /></p>
+<p>
+<strong><?php echo _('Is Active'); ?></strong>
+<br /><input type="radio" name="is_active" value="1"<?php if ($is_active=='1') { echo ' checked="checked"'; } ?> /> <?php echo _('Yes'); ?>
+<br /><input type="radio" name="is_active" value="0"<?php if ($is_active=='0') { echo ' checked="checked"'; } ?> /> <?php echo _('No'); ?></p>
+<p>
+<input type="submit" name="submit" value="<?php echo _('Submit Changes'); ?>"></p>
+</form>
<?php
-Function ShowResultsEditSurvey($result) {
- global $group_id,$PHP_SELF;
- $rows = db_NumRows($result);
- $cols = db_NumFields($result);
- echo "<h3>$rows Found</h3>";
-
- echo /*"<TABLE BGCOLOR=\"NAVY\"><TR><TD BGCOLOR=\"NAVY\">*/ "<table border=0>\n";
- /* Create the headers */
- echo "<tr BGCOLOR=\"$GLOBALS[COLOR_MENUBARBACK]\">\n";
- for ($i = 0; $i < $cols; $i++) {
- printf( "<th><FONT COLOR=\"WHITE\"><B>%s</th>\n", db_fieldname($result,$i));
- }
- echo "</tr>";
- for ($j=0; $j<$rows; $j++) {
-
- if ($j%2==0) {
- $row_bg="#FFFFFF";
- } else {
- $row_bg="$GLOBALS[COLOR_LTBACK1]";
- }
-
- echo "<tr BGCOLOR=\"$row_bg\">\n";
-
- echo "<TD><A HREF=\"$PHP_SELF?group_id=$group_id&survey_id=".
- db_result($result,$j,0)."\">".db_result($result,$j,0)."</A></TD>";
- for ($i = 1; $i < $cols; $i++) {
- printf("<TD>%s</TD>\n",db_result($result,$j,$i));
- }
-
- echo "</tr>";
- }
- echo "</table>"; //</TD></TR></TABLE>";
-}
/*
Select all surveys from the database
*/
-
-$sql="SELECT * FROM surveys WHERE group_id='$group_id'";
-
-$result=db_query($sql);
+$result = db_query_params ('SELECT * FROM surveys WHERE group_id=$1',
+ array ($group_id));
+$numrows=db_numrows($result);
?>
-<P>
-<FORM>
-<INPUT TYPE="BUTTON" NAME="none" VALUE="Show Existing Questions" ONCLICK="show_questions()">
-</FORM>
-<P>
-<H2>Existing Surveys</H2>
+
+<form>
+<input type="button" name="none" value="<?php echo _('Show Existing Questions'); ?>" onclick="show_questions()" />
+</form>
+<p> </p>
+<h2><?php echo ngettext('Existing Survey', 'Existing Surveys', $numrows) ?></h2>
<?php
ShowResultsEditSurvey($result);
survey_footer(array());
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
?>