diff --git a/admin/new.php b/admin/new.php index add4bff5..daab6d46 100644 --- a/admin/new.php +++ b/admin/new.php @@ -1,231 +1,378 @@ - - * @copyright Deakin University 2007,2008 - * @package queXS - * @subpackage admin - * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include ("../config.inc.php"); - -/** - * Database file - */ -include ("../db.inc.php"); - -/** - * XHTML functions - */ -include ("../functions/functions.xhtml.php"); - -/** - * Input functions - */ -include("../functions/functions.input.php"); - -/** - * CKEditor - */ -include("../include/ckeditor/ckeditor.php"); - -global $db; - -xhtml_head(T_("New: Create new questionnaire"),true,false,array("../js/new.js")); - -if (isset($_POST['import_file'])) -{ - //file has been submitted - global $db; - - $ras =0; - $rws = 0; - $testing = 0; - $referral = 0; - $rs = 0; - $lime_sid = 0; - $respsc = 0; - $lime_rs_sid = "NULL"; - if (isset($_POST['ras'])) $ras = 1; - if (isset($_POST['rws'])) $rws = 1; - if (isset($_POST['testing'])) $testing = 1; - if (isset($_POST['respsc'])) $respsc = 1; - if (isset($_POST['referral'])) $respsc = 1; - if ($_POST['selectrs'] != "none") $rs = 1; - - $name = $db->qstr($_POST['description']); - $rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8')); - $rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8')); - $rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8')); - $rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8')); - $rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8')); - $info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8')); - - //use existing lime instrument - $lime_sid = bigintval($_POST['select']); - - - if (is_numeric($_POST['selectrs'])) - { - $lime_rs_sid = bigintval($_POST['selectrs']); - } - - $sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info,self_complete,referral) - VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info,$respsc,$referral)"; - - $rs = $db->Execute($sql); - - if ($rs) - { - $qid = $db->Insert_ID(); - if ($respsc == 1) - { - $lime_mode = $db->qstr($_POST['lime_mode']); - $lime_template = $db->qstr($_POST['lime_template']); - $lime_endurl = $db->qstr($_POST['lime_endurl']); - - $sql = "UPDATE questionnaire - SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl - WHERE questionnaire_id = $qid"; - - $db->Execute($sql); - } - print "
" . T_("Successfully inserted") . " $name " . T_("as questionnaire") . " $qid, " . T_("linked to") . " $lime_sid
"; - }else - { - print "" . T_("Error: Failed to insert questionnaire") . "
"; - } - - -} - - -//create new questionnaire -?> - - +qstr($_POST['description']); + $rs_intro = $db->qstr(html_entity_decode($_POST['rs_intro'],ENT_QUOTES,'UTF-8')); + $rs_project_intro = $db->qstr(html_entity_decode($_POST['rs_project_intro'],ENT_QUOTES,'UTF-8')); + $rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8')); + $rs_callback = $db->qstr(html_entity_decode($_POST['rs_callback'],ENT_QUOTES,'UTF-8')); + $rs_answeringmachine = $db->qstr(html_entity_decode($_POST['rs_answeringmachine'],ENT_QUOTES,'UTF-8')); + $info = $db->qstr(html_entity_decode($_POST['info'],ENT_QUOTES,'UTF-8')); + + //use existing lime instrument + $lime_sid = bigintval($_POST['select']); + + + if (is_numeric($_POST['selectrs'])) + { + $lime_rs_sid = bigintval($_POST['selectrs']); + } + + $sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info,self_complete,referral) + VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info,$respsc,$referral)"; + + $rs = $db->Execute($sql); + + if ($rs) + { + $qid = $db->Insert_ID(); + if ($respsc == 1) + { + $lime_mode = $db->qstr($_POST['lime_mode']); + $lime_template = $db->qstr($_POST['lime_template']); + $lime_endurl = $db->qstr($_POST['lime_endurl']); + + $sql = "UPDATE questionnaire + SET lime_mode = $lime_mode, lime_template = $lime_template, lime_endurl = $lime_endurl + WHERE questionnaire_id = $qid"; + + $db->Execute($sql); + } + $cl = info; + $message = T_("Successfully inserted") . " " . T_("with ID") . " $qid,