Skip to content

Commit

Permalink
Fix createFieldMap()
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12034 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
GautamGupta committed Jan 13, 2012
1 parent abb6122 commit 7ea466f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions application/helpers/common_helper.php
Expand Up @@ -2175,14 +2175,25 @@ function validate_templatedir($templatename)
* @return array
*/
function createFieldMap($surveyid, $style='short', $force_refresh=false, $questionid=false, $sQuestionLanguage=null) {
// TMSW Conditions->Relevance: Refactor this function so that doesn't query conditions table, and so that only 3 db calls total to build array (questions, answers, attributes)
// TMSW Conditions->Relevance: 'hasconditions' and 'usedinconditions' are no longer needed.

global $globalfieldmap, $aDuplicateQIDs;

$clang = Yii::app()->lang;
$surveyid = sanitize_int($surveyid);
//Get list of questions
if (is_null($sQuestionLanguage))
{
if (isset($_SESSION['s_lang'])) {
$sQuestionLanguage = $_SESSION['s_lang'];
}
else {
$sQuestionLanguage = Survey::model()->findByPk($surveyid)->language;
}
}
$sQuestionLanguage = sanitize_languagecode($sQuestionLanguage);
if ($clang->langcode != $sQuestionLanguage) {
SetSurveyLanguage($surveyid, $sQuestionLanguage);
}
$s_lang = $clang->langcode;
$surveyid=sanitize_int($surveyid);

//checks to see if fieldmap has already been built for this page.
if (isset($globalfieldmap[$surveyid][$style][$s_lang]) && $force_refresh==false) {
return $globalfieldmap[$surveyid][$style][$s_lang];
Expand Down Expand Up @@ -2585,7 +2596,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
{
$fieldmap[$fieldname]['title']=$arow['title'];
$fieldmap[$fieldname]['question']=$arow['question'];
$fieldmap[$fieldname]['max_files']=$abvalue;
$fieldmap[$fieldname]['max_files']=$abvalue;
$fieldmap[$fieldname]['group_name']=$arow['group_name'];
$fieldmap[$fieldname]['mandatory']=$arow['mandatory'];
$fieldmap[$fieldname]['hasconditions']=$conditions;
Expand Down Expand Up @@ -2643,8 +2654,8 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$fieldmap[$fieldname]['preg']=$arow['preg'];
if (isset($defaultValues[$arow['qid'].'~'.$abrow['qid']])) {
$fieldmap[$fieldname]['defaultvalue'] = $defaultValues[$arow['qid'].'~'.$abrow['qid']];
}
}
}
}
if ($arow['type'] == "P")
{
$fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}{$abrow['title']}comment";
Expand Down

0 comments on commit 7ea466f

Please sign in to comment.