diff --git a/CHANGELOG b/CHANGELOG index bce65ec0..44940fce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +ALTER TABLE `questionnaire` ADD `remote_id` INT NOT NULL , +ADD INDEX ( `remote_id` ) ; + + queXS 1.14.4 - Changes since 1.14.3 Fourth bug fix release. diff --git a/admin/new.php b/admin/new.php index fa778177..802ded3e 100644 --- a/admin/new.php +++ b/admin/new.php @@ -26,6 +26,11 @@ include ("../functions/functions.xhtml.php"); */ include("../functions/functions.input.php"); +/** + * Limesurvey functions + */ +include("../functions/functions.limesurvey.php"); + $css = array( "../include/bootstrap/css/bootstrap.min.css", "../include/bootstrap/css/bootstrap-theme.min.css", @@ -72,14 +77,10 @@ if (isset($_POST['import_file'])) $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']); - } + //use existing lime instrument + $tmp = explode(';',$_POST['select']); + $lime_sid = bigintval($tmp[0]); + $remote = intval($tmp[1]); //** get default coma-separated outcomes list and use it for new questionnaire as initial set $sql = "SELECT o.outcome_id @@ -97,26 +98,14 @@ if (isset($_POST['import_file'])) //** - end - $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,outcomes) - 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,'$do')"; + $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,outcomes,remote_id) + 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,'$do','$remote')"; $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,

" . T_("linked to survey") . "  $lime_sid "; @@ -167,12 +156,11 @@ $_POST['import_file'] = false; ',sl.surveyls_title) AS title - FROM " . LIME_PREFIX . "surveys AS s - LEFT JOIN " . LIME_PREFIX . "surveys_languagesettings AS sl ON ( s.sid = sl.surveyls_survey_id) - WHERE s.active = 'Y'"; -$surveys = $db->GetAll($sql); +//get list of surveys via RPC + +$surveys = get_survey_list(); + if (!empty($surveys)){?> @@ -191,13 +179,9 @@ if (!empty($surveys)){?>
-
- - -
@@ -206,10 +190,6 @@ if (!empty($surveys)){?>
@@ -242,63 +222,6 @@ if (!empty($surveys)){?> -
- -
- " data-off="" data-width="80"/> -
-
- - - - array(array("tokens","-","Source"), else { ?>

- -

-
diff --git a/functions/functions.limesurvey.php b/functions/functions.limesurvey.php index a3bbf8e1..8bca70f2 100644 --- a/functions/functions.limesurvey.php +++ b/functions/functions.limesurvey.php @@ -72,6 +72,42 @@ function limerpc_init ($url,$user,$pass) } +function get_survey_list () +{ + global $db; + global $limeRPC; + global $limeKey; + + //get a list of surveys from each possible remote + + $sql = "SELECT id, rpc_url, username, password, description + FROM remote"; + + $rs = $db->GetAll($sql); + + $ret = array(); + + foreach($rs as $r) { + if (limerpc_init($r['rpc_url'],$r['username'],$r['password']) === true) { + $l = $limeRPC->list_surveys($limeKey); + if (isset($l['status'])) { + //none available + } else if (is_array($l)) { + foreach ($l as $s) { + if ($s["active"] == "Y") { + $ret[] = array("sid" => $s['sid'], + "description" => $s['surveyls_title'], + "host" => $r['description'], + "remote_id" => $r['id']); + } + } + } + } + } + + return $ret; +} + /**