Skip to content

Commit

Permalink
Fixed unreported issue: duplicate conditions can be added in the cond…
Browse files Browse the repository at this point in the history
…ition editor GUI

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@8927 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Thibault Le Meur committed Jul 12, 2010
1 parent a14d02e commit 3a75000
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions admin/conditionshandling.php
Expand Up @@ -151,9 +151,23 @@
{
foreach ($p_canswers as $ca)
{
$query = "INSERT INTO {$dbprefix}conditions (qid, scenario, cqid, cfieldname, method, value) VALUES "
. "('{$qid}', '{$p_scenario}', '{$p_cqid}', '{$conditionCfieldname}', '{$p_method}', '$ca')";
$result = $connect->Execute($query) or safe_die ("Couldn't insert new condition<br />$query<br />".$connect->ErrorMsg());
//First lets make sure there isn't already an exact replica of this condition
$query = "SELECT * FROM {$dbprefix}conditions\n"
."WHERE qid='$qid'\n"
."AND scenario='".$p_scenario."'\n"
."AND cqid='".$p_cqid."'\n"
."AND cfieldname='".$conditionCfieldname."'\n"
."AND method='".$p_method."'\n"
."AND value='".$ca."'";
$result = $connect->Execute($query) or safe_die("Couldn't check for existing condition<br />$query<br />".$connect->ErrorMsg());
$count_caseinsensitivedupes = $result->RecordCount();

if ($count_caseinsensitivedupes == 0)
{
$query = "INSERT INTO {$dbprefix}conditions (qid, scenario, cqid, cfieldname, method, value) VALUES "
. "('{$qid}', '{$p_scenario}', '{$p_cqid}', '{$conditionCfieldname}', '{$p_method}', '$ca')";
$result = $connect->Execute($query) or safe_die ("Couldn't insert new condition<br />$query<br />".$connect->ErrorMsg());
}
}
}

Expand Down Expand Up @@ -317,7 +331,7 @@
{
list($newsid, $newgid, $newqid)=explode("X", $copyc);
foreach ($proformaconditions as $pfc)
{
{ //TIBO
//First lets make sure there isn't already an exact replica of this condition
$query = "SELECT * FROM {$dbprefix}conditions\n"
."WHERE qid='$newqid'\n"
Expand Down

0 comments on commit 3a75000

Please sign in to comment.