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('../../env.inc.php');
29 require_once('pre.php');
30 require_once('www/survey/survey_utils.php');
31 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_add_survey','title')));
37 if (!session_loggedin() || !user_ismember($group_id,'A')) {
38 echo "<h1>". $Language->getText('survey_add_question','permission_denied')."</h1>";
39 survey_footer(array());
43 if (getStringFromRequest('post_changes')) {
44 $survey_title = getStringFromRequest('survey_title');
45 $survey_questions = getStringFromRequest('survey_questions');
48 $feedback .= $Language->getText('survey_add_question','title_is_required');
50 $sql="insert into surveys (survey_title,group_id,survey_questions) values ('".htmlspecialchars($survey_title)."','$group_id','$survey_questions')";
51 $result=db_query($sql);
53 $feedback .= $Language->getText('survey_add_question','survey_inserted');
55 $feedback .= $Language->getText('survey_add_question','error_in_insert');
61 <script type="text/javascript">
65 function show_questions() {
66 newWindow = open("","occursDialog","height=600,width=500,scrollbars=yes,resizable=yes");
67 newWindow.location=('show_questions.php?group_id=<?php echo $group_id; ?>');
74 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
76 <strong><?php echo $Language->getText('survey_add_survey','name_of_survey') ?></strong><?php echo utils_requiredField(); ?>
78 <input type="text" name="survey_title" value="" length="60" maxlength="150" /><p>
79 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
80 <input type="hidden" name="post_changes" value="y" />
81 <?php echo $Language->getText('survey_add_survey','list_questions_numbers'); ?>
82 <br /><input type="text" name="survey_questions" value="" length="90" maxlength="1500" /></p>
83 <p><strong><?php echo $Language->getText('survey_add_survey','is_active') ?></strong>
84 <br /><input type="radio" name="is_active" value="1" checked="checked" /> <?php echo $Language->getText('survey_add_survey','yes'); ?>
85 <br /><input type="radio" name="is_active" value="0" /> <?php echo $Language->getText('survey_add_survey','no'); ?></p>
87 <input type="submit" name="SUBMIT" value="<?php echo $Language->getText('survey_add_survey','add_this_survey'); ?>" /></p>
92 Select this survey from the database
95 $sql="SELECT * FROM surveys WHERE group_id='$group_id'";
97 $result=db_query($sql);
101 <input type="button" name="none" value="<?php echo $Language->getText('survey_add_survey','show_existing_question'); ?>" onclick="show_questions()" />
105 <h2><?php echo $Language->getText('survey_add_survey','existing_surveys') ?></h2>
108 ShowResultsEditSurvey($result);
110 survey_footer(array());