mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Ensure only one data record per token. Applies to newly activated surveys
This commit is contained in:
@@ -408,8 +408,8 @@ function activateSurvey($postsid,$surveyid, $scriptname='admin.php')
|
|||||||
|
|
||||||
$execresult=$dict->ExecuteSQLArray($sqlarray,1);
|
$execresult=$dict->ExecuteSQLArray($sqlarray,1);
|
||||||
|
|
||||||
//queXS Addition - add an index on the token
|
//queXS Addition - add a UNIQUE index on the token
|
||||||
$createtokenindex = $dict->CreateIndexSQL("{$tabname}_idx", $tabname, array('token'));
|
$createtokenindex = $dict->CreateIndexSQL("{$tabname}_idx", $tabname, array('token'),array('UNIQUE'));
|
||||||
$dict->ExecuteSQLArray($createtokenindex, false) or safe_die ("Failed to create token index<br />$createtokenindex<br /><br />".$connect->ErrorMsg());
|
$dict->ExecuteSQLArray($createtokenindex, false) or safe_die ("Failed to create token index<br />$createtokenindex<br /><br />".$connect->ErrorMsg());
|
||||||
|
|
||||||
if ($execresult==0 || $execresult==1)
|
if ($execresult==0 || $execresult==1)
|
||||||
|
|||||||
@@ -4646,6 +4646,8 @@
|
|||||||
$_SESSION['datestamp']=$datestamp;
|
$_SESSION['datestamp']=$datestamp;
|
||||||
if ($this->surveyOptions['active'] && !isset($_SESSION['srid']))
|
if ($this->surveyOptions['active'] && !isset($_SESSION['srid']))
|
||||||
{
|
{
|
||||||
|
$srid = $connect->GetOne("SELECT id FROM ".$this->surveyOptions['tablename']." WHERE token='".$this->surveyOptions['token']."'");
|
||||||
|
if (is_null($srid)) {
|
||||||
// Create initial insert row for this record
|
// Create initial insert row for this record
|
||||||
$sdata = array(
|
$sdata = array(
|
||||||
"datestamp"=>$datestamp,
|
"datestamp"=>$datestamp,
|
||||||
@@ -4684,6 +4686,9 @@
|
|||||||
echo $message;
|
echo $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$_SESSION['srid'] = $srid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($updatedValues) > 0 || $finished)
|
if (count($updatedValues) > 0 || $finished)
|
||||||
|
|||||||
@@ -130,6 +130,9 @@
|
|||||||
//INSERT BLANK RECORD INTO "survey_x" if one doesn't already exist
|
//INSERT BLANK RECORD INTO "survey_x" if one doesn't already exist
|
||||||
if (!isset($_SESSION['srid']))
|
if (!isset($_SESSION['srid']))
|
||||||
{
|
{
|
||||||
|
$result = $connect->GetOne("SELECT id FROM ".$thissurvey['tablename']." WHERE token='{$_POST['token']}'");
|
||||||
|
if (is_null($result)) {
|
||||||
|
|
||||||
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust);
|
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust);
|
||||||
$sdata = array("datestamp"=>$today,
|
$sdata = array("datestamp"=>$today,
|
||||||
"ipaddr"=>getIPAddress(),
|
"ipaddr"=>getIPAddress(),
|
||||||
@@ -146,6 +149,9 @@
|
|||||||
{
|
{
|
||||||
safe_die("Unable to insert record into survey table.<br /><br />".$connect->ErrorMsg());
|
safe_die("Unable to insert record into survey table.<br /><br />".$connect->ErrorMsg());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$_SESSION['srid'] = $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//CREATE ENTRY INTO "saved_control"
|
//CREATE ENTRY INTO "saved_control"
|
||||||
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust);
|
$today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust);
|
||||||
|
|||||||
Reference in New Issue
Block a user