--- /Users/ptroxler/Downloads/2011-08-10/limesurvey/qanda.php +++ qanda.php @@ -10,7 +10,7 @@ * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. * - * $Id: qanda.php 10625 2011-08-02 15:57:30Z c_schmitz $ + * $Id: qanda.php 10028 2011-05-01 15:47:16Z texens $ */ // Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB @@ -87,13 +87,24 @@ ."{$dbprefix}conditions.cfieldname"; $cresult = db_execute_assoc($cquery) or safe_die ("OOPS
$cquery
".$connect->ErrorMsg()); //Checked - $cquerytoken = "SELECT c.qid, c.scenario, c.cqid, c.cfieldname, c.value, '' as type, 0 as sid, 0 as gid, c.method, q.gid as srcgid " - ."FROM {$dbprefix}conditions c, {$dbprefix}questions q " - ."WHERE c.qid=q.qid " - ."AND c.qid=$ia[0] " - ."AND c.cfieldname LIKE '{%' " - ."ORDER BY c.scenario, c.cqid, c.cfieldname"; - + $cquerytoken = "SELECT {$dbprefix}conditions.qid, " + ."{$dbprefix}conditions.scenario, " + ."{$dbprefix}conditions.cqid, " + ."{$dbprefix}conditions.cfieldname, " + ."{$dbprefix}conditions.value, " + ."'' as type, " + ."0 as sid, " + ."0 as gid, " + ."{$dbprefix}conditions.method," + ."questionssrc.gid as srcgid " + ."FROM {$dbprefix}conditions, {$dbprefix}questions as questionssrc " + ."WHERE {$dbprefix}conditions.qid=questionssrc.qid " + ."AND {$dbprefix}conditions.qid=$ia[0] " + ."AND {$dbprefix}conditions.cfieldname LIKE '{%' " + ."ORDER BY {$dbprefix}conditions.scenario, " + ."{$dbprefix}conditions.cqid, " + ."{$dbprefix}conditions.cfieldname"; + $cresulttoken = db_execute_assoc($cquerytoken) or safe_die ("OOPS
$cquerytoken
".$connect->ErrorMsg()); //Checked while ($tempcrow = $cresulttoken->FetchRow()) @@ -133,7 +144,7 @@ $cfieldnamelist[$condkey] = $condarr[2]; } array_multisort($scenariolist,SORT_ASC,$cqidlist,SORT_ASC,$cfieldnamelist,SORT_ASC,$conditions); - + return $conditions; } else @@ -376,13 +387,9 @@ $mandatorys=array(); $mandatoryfns=array(); - $ansquery = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=0 - ORDER BY question_order, title"; + $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=0 ORDER BY question_order, title"; $ansresult = db_execute_assoc($ansquery); - $ans2query = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=1 - ORDER BY question_order, title"; + $ans2query = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=1 ORDER BY question_order, title"; $ans2result = db_execute_assoc($ans2query); while ($ans2row=$ans2result->FetchRow()) @@ -411,7 +418,7 @@ $mandatoryfns[]=$ia[1]; } } - } + } elseif (trim($qidattributes['array_filter_exclude'])!='') { //This particular one may not be mandatory if it's hidden @@ -469,7 +476,7 @@ $ans1result = db_execute_assoc($ans1query); //Checked $ans1count = $ans1result->RowCount(); - // Get Answer Scale 2 + // Get Answer Scale 2 $ans2query="SELECT qid " ."FROM {$dbprefix}answers " ."WHERE qid={$ia[0]} " @@ -481,7 +488,7 @@ while ($subrow = $subresult->FetchRow()) { - // first answer set + // first answer set if ($ans1count > 0) { $mandatorys[]=$ia[1].$subrow['title']."#0"; @@ -575,7 +582,7 @@ ,'input_error_class' => ''// provides a class. ,'essentials' => '' ); - + switch ($ia[4]) { case 'X': //BOILERPLATE QUESTION @@ -708,7 +715,7 @@ if ($qidattributes['min_num_of_files'] != 0) { if (trim($qidattributes['min_num_of_files']) != 0) - { + { $qtitle .= "
\n" .sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files']).""; $question_text['help'] .= ' '.sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files']); @@ -791,10 +798,10 @@ $qtitle .= validation_message($ia); $question_text['valid_message'] = validation_message($ia); - + $qtitle .= $ia[4] == "|" ? file_validation_message($ia) : ""; $question_text['file_valid_message'] = $ia[4] == "|" ? file_validation_message($ia) : ""; - + if(!empty($question_text['man_message']) || !empty($question_text['valid_message']) || !empty($question_text['file_valid_message'])) { $question_text['input_error_class'] = ' input-error';// provides a class to style question wrapper differently if there is some kind of user input error; @@ -1157,7 +1164,7 @@ } answer.blur(); answer.onfocus=function() {answer.blur();}; - } + } }; //--> "; @@ -1210,7 +1217,7 @@ subcookiejar.bake('limesurvey_timers', timeleftobject, 7)\n"; if($disable_next > 0) { $output .= " - if(document.getElementById('movenextbtn') !== null && timeleft > $disable_next) { + if(document.getElementById('movenextbtn') !== null && timeleft > $disable_next) { document.getElementById('movenextbtn').disabled=true; } else if (document.getElementById('movenextbtn') !== null && $disable_next > 1 && timeleft <= $disable_next) { document.getElementById('movenextbtn').disabled=false; @@ -1218,7 +1225,7 @@ } if($disable_prev > 0) { $output .= " - if(document.getElementById('moveprevbtn') !== null && timeleft > $disable_prev) { + if(document.getElementById('moveprevbtn') !== null && timeleft > $disable_prev) { document.getElementById('moveprevbtn').disabled=true; } else if (document.getElementById('moveprevbtn') !== null && $disable_prev > 1 && timeleft <= $disable_prev) { document.getElementById('moveprevbtn').disabled=false; @@ -1281,11 +1288,11 @@ } warning2hide--; } - var secs = timeleft % 60; + var secs = timeleft % 60; if (secs < 10) secs = '0'+secs; var T1 = (timeleft - secs) / 60; var mins = T1 % 60; if (mins < 10) mins = '0'+mins; - var hours = (T1 - mins) / 60; + var hours = (T1 - mins) / 60; if (hours < 10) hours = '0'+hours; var d2hours=''; var d2mins=''; @@ -1385,7 +1392,7 @@ $filter_select = TRUE; } } - + if (isset($qidattributes['array_filter_exclude']) && ( @@ -1400,7 +1407,7 @@ ) { $selected = getArrayFilterExcludesForQuestion($ia[0]); - if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; + if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; if (!empty($selected) && !in_array($ansrow['title'],$selected)) { $filter_select = TRUE; @@ -1410,7 +1417,7 @@ $filter_select = FALSE; } } - return $filter_select; + return $filter_select; } function return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) { @@ -1554,7 +1561,7 @@ ) { $selected = getArrayFilterExcludesForQuestion($ia[0]); - if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; + if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; if (!empty($selected) && !in_array($ansrow['title'],$selected)) { $htmltbody2 = "\n\n\t<$method id='javatbd$rowname'>\n"; @@ -1625,8 +1632,8 @@ // --------------------------------------------------------------- function do_5pointchoice($ia) { - global $clang, $imageurl; - global $js_header_includes, $css_header_includes; + global $clang; + global $js_header_includes, $css_header_includes; if ($ia[8] == 'Y') { @@ -1684,12 +1691,12 @@ $('#answer$ia[1]'+value).attr('checked','checked'); } } - + }); "; } - + if($qidattributes['slider_rating']==2){ if(!IsSet($_SESSION[$ia[1]]) OR $_SESSION[$ia[1]]==''){ $value=1; @@ -1699,12 +1706,12 @@ $answer.="
1
2
3
4
5

-
+
-
+
"; - + } return array($answer, $inputnames); } @@ -1753,6 +1760,7 @@ { global $clang, $js_header_includes, $css_header_includes, $thissurvey; $qidattributes=getQuestionAttributes($ia[0],$ia[4]); + $js_header_includes[] = '/scripts/jquery/jquery-ui.js'; $js_header_includes[] = '/scripts/jquery/lime-calendar.js'; @@ -1910,7 +1918,7 @@ { if ($clang->langcode !== 'en') { - $js_header_includes[] = '/scripts/jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js'; + $js_header_includes[] = '/scripts/jquery/locale/ui.datepicker-'.$clang->langcode.'.js'; } $css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css'; @@ -1949,9 +1957,9 @@ - +

-

+

".sprintf($clang->gT('Format: %s'),$dateformatdetails['dateformat'])."

"; } @@ -2019,7 +2027,7 @@ if (trim($qidattributes['other_replace_text'])!='') { - $othertext=$qidattributes['other_replace_text']; + $othertext=$clang->gT($qidattributes['other_replace_text']); } else { @@ -2059,10 +2067,10 @@ $ansresult = db_execute_assoc($ansquery) or safe_die('Couldn\'t get answers
'.$ansquery.'
'.$connect->ErrorMsg()); //Checked if (!isset($optCategorySeparator)) - { + { while ($ansrow = $ansresult->FetchRow()) { - $opt_select = ''; + $opt_select = ''; if ($_SESSION[$ia[1]] == $ansrow['code']) { $opt_select = SELECTED; @@ -2310,7 +2318,7 @@ if (trim($qidattributes['other_replace_text'])!='') { - $othertext=$qidattributes['other_replace_text']; + $othertext=$clang->gT($qidattributes['other_replace_text']); } else { @@ -2644,7 +2652,7 @@ { $check_ans = ''; } - $answer .= '\n"; + $answer .= '\n"; } $answer .= '

@@ -2857,7 +2865,7 @@ $answer .= "\t\n" . "\t\n" . "\t\n"; - + $answer .= $ranklist . "\t
".$clang->gT("Your Ranking").":
\n" . "\t\n" @@ -2920,10 +2928,10 @@ // Find out if any questions have attributes which reference this questions // based on value of attribute. This could be array_filter and array_filter_exclude - + $attribute_ref=false; $inputnames=array(); - + $qaquery = "SELECT qid,attribute FROM ".db_table_name('question_attributes')." WHERE value LIKE '".strtolower($ia[2])."' and (attribute='array_filter' or attribute='array_filter_exclude')"; $qaresult = db_execute_assoc($qaquery); //Checked while($qarow = $qaresult->FetchRow()) @@ -2932,10 +2940,10 @@ $qresult = db_execute_assoc($qquery); //Checked if ($qresult->RecordCount() > 0) { - $attribute_ref = true; + $attribute_ref = true; } } - + if ($ia[8] == 'Y' || $attribute_ref === true) { $checkconditionFunction = "checkconditions"; @@ -2949,7 +2957,7 @@ if (trim($qidattributes['other_replace_text'])!='') { - $othertext=$qidattributes['other_replace_text']; + $othertext=$clang->gT($qidattributes['other_replace_text']); } else { @@ -2983,7 +2991,7 @@ $maxanswscript = ''; $exclude_all_others_auto = trim($qidattributes["exclude_all_others_auto"]); - + if ($exclude_all_others_auto=='1'){ $autoArray['list'][]=$ia[1]; $autoArray[$ia[1]]['parent'] = $ia[1]; @@ -3014,7 +3022,7 @@ $maxanswscript = "\t\n"; + $maxanswscript .= "\tif (count > max)\n" + . "{\n" + . "alert('".sprintf($clang->gT("Please choose at most %d answer(s) for question \"%s\"","js"), $maxansw, trim(javascript_escape(str_replace(array("\n", "\r"), "", $ia[3]),true,true)))."');\n" + . "if (me.type == 'checkbox') {me.checked = false;}\n" + . "if (me.type == 'text') {\n" + . "\tme.value = '';\n" + . "\tif (document.getElementById(me.name + 'cbox') ){\n" + . " document.getElementById(me.name + 'cbox').checked = false;\n" + . "\t}\n" + . "}" + . "return max;\n" + . "}\n" + . "\t}\n" + . "\t//-->\n" + . "\t\n"; $answer = $maxanswscript . $answer; } @@ -3362,14 +3391,14 @@ if (count($excludeallothers)>0) { $excludeallotherscript .= " - if (document.getElementById(value).checked) - { - $excludeallotherscripton - } - else - { - $excludeallotherscriptoff - } + if (document.getElementById(value).checked) + { + $excludeallotherscripton + } + else + { + $excludeallotherscriptoff + } } //--> "; @@ -3397,10 +3426,10 @@ $qresult = db_execute_assoc($qquery); //Checked if ($qresult->RecordCount() > 0) { - $attribute_ref = true; + $attribute_ref = true; } } - + if ($ia[8] == 'Y' || $attribute_ref == true) { $checkconditionFunction = "checkconditions"; @@ -3425,7 +3454,7 @@ if (trim($qidattributes['other_replace_text'])!='') { - $othertext=$qidattributes['other_replace_text']; + $othertext=$clang->gT($qidattributes['other_replace_text']); } else { @@ -3467,18 +3496,13 @@ ; } - $qquery = "SELECT other FROM {$dbprefix}questions - WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0"; + $qquery = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0"; $qresult = db_execute_assoc($qquery); //Checked while ($qrow = $qresult->FetchRow()) {$other = $qrow['other'];} if ($qidattributes['random_order']==1) { - $ansquery = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' - ORDER BY ".db_random(); + $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { - $ansquery = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' - ORDER BY question_order"; + $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY question_order"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount()*2; @@ -3501,7 +3525,7 @@ $myfname = $ia[1].$ansrow['title']; $trbc=''; /* Check for array_filter */ - + list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname, "li"); if($label_width < strlen(trim(strip_tags($ansrow['question'])))) @@ -3544,7 +3568,7 @@ ."\n\t\n\n" + $answer_main .= "' onclick='cancelBubbleThis(event);' onkeypress='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t\n\n" . "\t\n"; // --> END NEW FEATURE - SAVE @@ -3613,7 +3637,7 @@ { $maxanswscript .= "\tif (count > max)\n" . "{\n" - . "alert('".sprintf($clang->gT("Please choose at most %d answers for question \"%s\"","js"), $maxansw, trim(javascript_escape($ia[3],true,true)))."');\n" + . "alert('".sprintf($clang->gT("Please choose at most %d answer(s) for question \"%s\"","js"), $maxansw, trim(javascript_escape($ia[3],true,true)))."');\n" . "var commentname='answer'+me.name+'comment';\n" . "if (me.type == 'checkbox') {\n" . "\tme.checked = false;\n" @@ -3704,7 +3728,7 @@ // Fetch question attributes $_SESSION['fieldname'] = $ia[1]; - + // Basic uploader /* $basic = '

' .''; @@ -3765,19 +3789,14 @@ $scriptloc = 'uploader.php'; } - $uploadbutton = "

" .$clang->gT('Upload files'). "



"; + $uploadbutton = "

Upload files



"; - $answer = "\n"; if ($pos) - $answer .= ""; + $answer = ""; else - $answer .= ""; + $answer = ""; // Modal dialog $answer .= $uploadbutton; @@ -3786,25 +3805,15 @@ $answer .= ""; - } - else - { - $answer .= "0 />"; - } - } - else { + $answer .= $_SESSION[$ia[1]."_filecount"]." />"; + else $answer .= "0 />"; - } $answer .= "
"; + //$answer .= '
Trouble uploading files? Try the Simple Uploader
'.$basic.'
'; + $answer .= ''; - + $answer .= '