From f5774e84588729eb2745b8130f44560183f52deb Mon Sep 17 00:00:00 2001
From: azammitdcarf
Date: Thu, 26 Feb 2009 07:11:08 +0000
Subject: [PATCH] Added link for modifying responses for the case
---
admin/supervisor.php | 13 +++++++
functions/functions.limesurvey.php | 55 ++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/admin/supervisor.php b/admin/supervisor.php
index 36f75f41..c2b3c1a3 100644
--- a/admin/supervisor.php
+++ b/admin/supervisor.php
@@ -50,6 +50,11 @@ include("../functions/functions.xhtml.php");
*/
include("../functions/functions.display.php");
+/**
+ * Limesurvey functions
+ */
+include("../functions/functions.limesurvey.php");
+
/**
* Operator functions
*/
@@ -206,6 +211,14 @@ if ($case_id != false)
+
+ //Modify the case in Limesurvey
+
+ $sid = get_lime_sid($case_id);
+ $id = get_lime_id($case_id);
+ print "";
+
+
//set an outcome
print "" . T_("Set a case outcome") . "
";
diff --git a/functions/functions.limesurvey.php b/functions/functions.limesurvey.php
index 03d5a71e..7c37b879 100644
--- a/functions/functions.limesurvey.php
+++ b/functions/functions.limesurvey.php
@@ -134,7 +134,62 @@ function create_limesurvey_questionnaire($title)
}
+/**
+ * Return the limesurvey id given the case_id
+ *
+ * @param int $case_id The case id
+ * @return bool|int False if no lime_id otherwise the lime_id
+ *
+ */
+function get_lime_id($case_id)
+{
+ global $ldb;
+ $lime_sid = get_lime_sid($case_id);
+ if ($lime_sid == false) return false;
+
+ $sql = "SELECT id
+ FROM " . LIME_PREFIX . "survey_$lime_sid
+ WHERE token = '$case_id'";
+
+ $r = $ldb->GetRow($sql);
+
+ if (!empty($r) && isset($r['id']))
+ return $r['id'];
+
+ return false;
+
+
+}
+
+
+/**
+ * Return the limesurvey tid given the case_id
+ *
+ * @param int $case_id The case id
+ * @return bool|int False if no lime_tid otherwise the lime_tid
+ *
+ */
+function get_lime_tid($case_id)
+{
+ global $ldb;
+
+ $lime_sid = get_lime_sid($case_id);
+ if ($lime_sid == false) return false;
+
+ $sql = "SELECT tid
+ FROM " . LIME_PREFIX . "tokens_$lime_sid
+ WHERE token = '$case_id'";
+
+ $r = $ldb->GetRow($sql);
+
+ if (!empty($r) && isset($r['tid']))
+ return $r['tid'];
+
+ return false;
+
+
+}
/**
* Return the lime_sid given the case_id