From c29005e5af117af73e8efe59f49b75138a496d97 Mon Sep 17 00:00:00 2001 From: Adam Zammit Date: Mon, 16 Jan 2017 15:38:45 +1100 Subject: [PATCH] Remove direct limesurvey database call --- nocaseavailable.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nocaseavailable.php b/nocaseavailable.php index 82cb4875..49da0c33 100644 --- a/nocaseavailable.php +++ b/nocaseavailable.php @@ -184,23 +184,25 @@ else //no link to limesurvey echo "

" . T_("Limesurvey links:") . "

"; -$sql = "SELECT q.lime_sid, q.description - FROM questionnaire as q, operator_questionnaire as oq +$sql = "SELECT q.lime_sid, q.description, r.rpc_url, r.username, r.password + FROM questionnaire as q, operator_questionnaire as oq, remote as r WHERE oq.operator_id = '$operator_id' AND q.questionnaire_id = oq.questionnaire_id - AND q.enabled = 1"; + AND q.enabled = 1 + AND r.id = q.remote_id"; $rs = $db->GetAll($sql); if (!empty($rs)) { foreach($rs as $r) - { - $sql = "SELECT count(*) - FROM " . LIME_PREFIX ."tokens_{$r['lime_sid']}"; - $rs2 = $db->GetRow($sql); + { + //interrogate server for tokens table + lime_rpc_init($r['rpc_url'],$r['username'],$r['password']); - if (empty($rs2)) + $l = $limeRPC->get_summary($limeKey,$r['lime_sid'],'token_count'); //get number of tokens + + if (isset($l['status'])) print "

" . T_("ERROR: No tokens table defined for LimeSurvey questionnaire") . " {$r['lime_sid']} " . T_("from questionnaire:") . " {$r['description']}

"; else print "

{$r['description']}: " . T_("Tokens table exists for Limesurvey questionnaire:") . " {$r['lime_sid']}

";