Skip to content

Commit

Permalink
Fixed bug #890: A blank answer code leads to an error message.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2869 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed May 8, 2007
1 parent 856a51d commit ca7f5b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ function get_max_question_order($gid)
{
$langid=substr($sortorderid,0,strrpos($sortorderid,'_'));
$orderid=substr($sortorderid,strrpos($sortorderid,'_')+1,20);
if ($_POST['code_'.$codeids[$count]] != "0" && !in_array($_POST['code_'.$codeids[$count]],$dupanswers))
if ($_POST['code_'.$codeids[$count]] != "0" && trim($_POST['code_'.$codeids[$count]]) != "" && !in_array($_POST['code_'.$codeids[$count]],$dupanswers))
{
$oldcode=false;
$query = "SELECT code from ".db_table_name('answers')." WHERE qid=".$connect->qstr($qid)." and sortorder=".$connect->qstr($orderid)." ";
Expand All @@ -726,13 +726,13 @@ function get_max_question_order($gid)
$result = $connect->Execute($query);
}
} else {
if ($_POST['code_'.$codeids[$count]] == "0") $invalidCode = 1;
if ($_POST['code_'.$codeids[$count]] == "0" || trim($_POST['code_'.$codeids[$count]]) == "") $invalidCode = 1;
if (in_array($_POST['code_'.$codeids[$count]],$dupanswers)) $duplicateCode = 1;
}
$count++;
if ($count>count($codeids)-1) {$count=0;}
}
if ($invalidCode == 1) $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Answers with a code of 0 (zero) are not allowed, and will not be saved","js")."\")\n //-->\n</script>\n";
if ($invalidCode == 1) $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Answers with a code of 0 (zero) or blank code are not allowed, and will not be saved","js")."\")\n //-->\n</script>\n";
if ($duplicateCode == 1) $databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"".$clang->gT("Duplicate codes found, these entries won't be updated","js")."\")\n //-->\n</script>\n";
break;

Expand Down
2 changes: 1 addition & 1 deletion admin/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@
if (($activated != 'Y' && $first) || ($activated == 'Y' && $first && (($qtype=='O') || ($qtype=='L') || ($qtype=='!') )))
{
$vasummary .= "\t<input type='text' name='code_{$row['sortorder']}' value=\"{$row['code']}\" maxlength='5' size='5'"
."onkeypress=\"onkeypress=\" if(event.keyCode==13) {if (event && event.preventDefault) event.preventDefault(); document.getElementById('saveallbtn_$anslang').click(); return false;} return goodchars(event,'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ_')\""
."onkeypress=\" if(event.keyCode==13) {if (event && event.preventDefault) event.preventDefault(); document.getElementById('saveallbtn_$anslang').click(); return false;} return goodchars(event,'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ_')\""
." />";
}
elseif (($activated != 'N' && $first) ) // If survey is activated and its not one of the above question types who allows modfying answers on active survey
Expand Down

0 comments on commit ca7f5b9

Please sign in to comment.