From a896df1059340dcbaa34550e048fd723fc93cffe Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Wed, 10 Aug 2011 13:36:56 +0000 Subject: [PATCH] Dev Bugfixes up to rev 10064 git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10666 b72ed6b6-b9f8-46b5-92b4-906544132732 --- application/helpers/common_helper.php | 561 ++++++++++--------- application/views/admin/Survey/surveybar.php | 38 +- 2 files changed, 301 insertions(+), 298 deletions(-) diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php index 704be3410ea..c73887086ec 100644 --- a/application/helpers/common_helper.php +++ b/application/helpers/common_helper.php @@ -13,16 +13,16 @@ * $Id$ * Files Purpose: lots of common functions */ -$CI =& get_instance(); +$CI =& get_instance(); $CI->load->helper('sanitize'); - + /** * This function gives back an array that defines which survey permissions and what part of the CRUD+Import+Export subpermissions is available. * - for example it would not make sense to have a 'create' permissions for survey locale settings as they exist with every survey * so the editor for survey permission should not show a checkbox here, therfore the create element of that permission is set to 'false' * If you want to generally add a new permission just add it here. -* +* */ function aGetBaseSurveyPermissions() @@ -30,29 +30,29 @@ function aGetBaseSurveyPermissions() //global $clang; $CI =& get_instance(); $clang = $CI->limesurvey_lang; - - $aPermissions=array( + + $aPermissions=array( 'assessments'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Assessments"),'description'=>$clang->gT("Permission to create/view/update/delete assessments rules for a survey"),'img'=>'assessments'), // Checked 'quotas'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Quotas"),'description'=>$clang->gT("Permission to create/view/update/delete quota rules for a survey"),'img'=>'quota'), // Checked - 'responses'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Responses"),'description'=>$clang->gT("Permission to create(data entry)/view/update/delete/import/export responses"),'img'=>'browse'), - 'statistics'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Statistics"),'description'=>$clang->gT("Permission to view statistics"),'img'=>'statistics'), //Checked - 'survey'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey deletion"),'description'=>$clang->gT("Permission to delete a survey"),'img'=>'delete'), //Checked - 'surveyactivation'=>array('create'=>false,'read'=>false,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey activation"),'description'=>$clang->gT("Permission to activate/deactivate a survey"),'img'=>'activate_deactivate'), //Checked + 'responses'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Responses"),'description'=>$clang->gT("Permission to create(data entry)/view/update/delete/import/export responses"),'img'=>'browse'), + 'statistics'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Statistics"),'description'=>$clang->gT("Permission to view statistics"),'img'=>'statistics'), //Checked + 'survey'=>array('create'=>false,'read'=>true,'update'=>false,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey deletion"),'description'=>$clang->gT("Permission to delete a survey"),'img'=>'delete'), //Checked + 'surveyactivation'=>array('create'=>false,'read'=>false,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey activation"),'description'=>$clang->gT("Permission to activate/deactivate a survey"),'img'=>'activate_deactivate'), //Checked 'surveycontent'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Survey content"),'description'=>$clang->gT("Permission to create/view/update/delete/import/export the questions, groups, answers & conditions of a survey"),'img'=>'add'), - 'surveylocale'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey locale settings"),'description'=>$clang->gT("Permission to view/update the survey locale settings"),'img'=>'edit'), - 'surveysecurity'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey security"),'description'=>$clang->gT("Permission to modify survey security settings"),'img'=>'survey_security'), - 'surveysettings'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey settings"),'description'=>$clang->gT("Permission to view/update the survey settings including token table creation"),'img'=>'survey_settings'), - 'tokens'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Tokens"),'description'=>$clang->gT("Permission to create/update/delete/import/export token entries"),'img'=>'tokens'), + 'surveylocale'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey locale settings"),'description'=>$clang->gT("Permission to view/update the survey locale settings"),'img'=>'edit'), + 'surveysecurity'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey security"),'description'=>$clang->gT("Permission to modify survey security settings"),'img'=>'survey_security'), + 'surveysettings'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Survey settings"),'description'=>$clang->gT("Permission to view/update the survey settings including token table creation"),'img'=>'survey_settings'), + 'tokens'=>array('create'=>true,'read'=>true,'update'=>true,'delete'=>true,'import'=>true,'export'=>true,'title'=>$clang->gT("Tokens"),'description'=>$clang->gT("Permission to create/update/delete/import/export token entries"),'img'=>'tokens'), 'translations'=>array('create'=>false,'read'=>true,'update'=>true,'delete'=>false,'import'=>false,'export'=>false,'title'=>$clang->gT("Quick translation"),'description'=>$clang->gT("Permission to view & update the translations using the quick-translation feature"),'img'=>'translate') ); - uasort($aPermissions,"aComparePermission"); - return $aPermissions; + uasort($aPermissions,"aComparePermission"); + return $aPermissions; } /** * Simple function to sort the permissions by title -* +* * @param mixed $aPermissionA Permission A to compare * @param mixed $aPermissionB Permission B to compare */ @@ -65,7 +65,7 @@ function aComparePermission($aPermissionA,$aPermissionB) return -1; } } - + /** * getqtypelist() Returns list of question types available in LimeSurvey. Edit this if you are adding a new * question type @@ -91,13 +91,13 @@ function getqtypelist($SelectedCode = "T", $ReturnType = "selector") $CI =& get_instance(); $publicurl = $CI->config->item('publicurl'); $clang = $CI->limesurvey_lang; - + if (!isset($clang)) { $lang = array('en'); $CI->load->library('Limesurvey_lang',$lang); - + $clang = $CI->limesurvey_lang; } $group['Arrays'] = $clang->gT('Arrays'); @@ -284,7 +284,7 @@ function getqtypelist($SelectedCode = "T", $ReturnType = "selector") $newqType[$qtype['group']][$qkey] = $qtype; } - + $qtypeselecter = ""; foreach($newqType as $group=>$members) { @@ -297,7 +297,7 @@ function getqtypelist($SelectedCode = "T", $ReturnType = "selector") } return $qtypeselecter; - + }; $qtypeselecter = ""; foreach($qtypes as $TypeCode=>$TypeProperties) @@ -350,16 +350,16 @@ function getsurveylist($returnarray=false,$returnwithouturl=false, $surveyid=fal //global $surveyid, $clang, $timeadjust,$CI; static $cached = null; $CI = &get_instance(); - + $CI->load->config('lsconfig'); //$surveyid = $CI->config->item("surveyid"); $timeadjust = $CI->config->item("timeadjust"); $clang = $CI->limesurvey_lang; - + if(is_null($cached)) { $CI->load->model('surveys_languagesettings_model'); $surveyidresult = $CI->surveys_languagesettings_model->getAllSurveys(!bHasGlobalPermission('USER_RIGHT_SUPERADMIN')); - + if (!$surveyidresult) {return "Database Error";} $surveynames = $surveyidresult->result_array(); $cached=$surveynames; @@ -483,15 +483,15 @@ function getsurveylist($returnarray=false,$returnwithouturl=false, $surveyid=fal function bHasSurveyPermission($iSID, $sPermission, $sCRUD, $iUID=null) { $CI =&get_instance(); - + if (!in_array($sCRUD,array('create','read','update','delete','import','export'))) return false; $sCRUD=$sCRUD.'_p'; $iSID = (int)$iSID; $aSurveyPermissionCache = $CI->config->item("aSurveyPermissionCache"); - + if (is_null($iUID)) { - if ($CI->session->userdata('loginID')) $iUID = $CI->session->userdata('loginID'); + if ($CI->session->userdata('loginID')) $iUID = $CI->session->userdata('loginID'); else return false; if ($CI->session->userdata('USER_RIGHT_SUPERADMIN')==1) return true; //Superadmin has access to all } @@ -500,7 +500,7 @@ function bHasSurveyPermission($iSID, $sPermission, $sCRUD, $iUID=null) { $CI->load->model("survey_permissions_model"); $query = $CI->survey_permissions_model->getSomeRecords(array($sCRUD),array("sid"=>$iSID,"uid"=>$iUID,"permission"=>$sPermission)); - //$sSQL = "SELECT {$sCRUD} FROM " . db_table_name('survey_permissions') . " + //$sSQL = "SELECT {$sCRUD} FROM " . db_table_name('survey_permissions') . " // WHERE sid={$iSID} AND uid = {$iUID} // and permission=".db_quoteall($sPermission); //Getting rights for this survey $bPermission = $query->row_array(); //$connect->GetOne($sSQL); @@ -514,7 +514,7 @@ function bHasSurveyPermission($iSID, $sPermission, $sCRUD, $iUID=null) /** * Returns true if a user has global permission for a certain action. Available permissions are - * + * * USER_RIGHT_CREATE_SURVEY * USER_RIGHT_CONFIGURATOR * USER_RIGHT_CREATE_USER @@ -533,8 +533,8 @@ function bHasGlobalPermission($sPermission) $CI=& get_instance(); //$aSurveyPermissionCache = $CI->config->item("aSurveyPermissionCache"); - - if ($CI->session->userdata('loginID')) $iUID = $CI->session->userdata('loginID'); + + if ($CI->session->userdata('loginID')) $iUID = $CI->session->userdata('loginID'); else return false; if ($CI->session->userdata('USER_RIGHT_SUPERADMIN')==1) return true; //Superadmin has access to all if ($CI->session->userdata($sPermission)==1) @@ -580,7 +580,7 @@ function gettemplatelist() closedir($handle); } ksort($list_of_files); - + return $list_of_files; } @@ -646,27 +646,27 @@ function getGidPrevious($surveyid, $gid) //global $CI, $clang; $CI =& get_instance(); $clang = $CI->limesurvey_lang; - + if (!$surveyid) {$surveyid=returnglobal('sid');} $s_lang = GetBaseLanguageFromSurveyID($surveyid); $CI->load->model('groups_model'); //$gquery = "SELECT gid FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order"; $qresult = $CI->groups_model->getGroupID($surveyid,$s_lang); //checked $qrows = $qresult->result_array(); - + $i = 0; $iPrev = -1; - + if ($qresult->num_rows() > 0) { - + foreach ($qrows as $qrow) { if ($gid == $qrow['gid']) {$iPrev = $i - 1;} $i += 1; } } - + if ($iPrev >= 0) {$GidPrev = $qrows[$iPrev]['gid'];} else {$GidPrev = "";} return $GidPrev; @@ -690,7 +690,7 @@ function getQidPrevious($surveyid, $gid, $qid) $s_lang = GetBaseLanguageFromSurveyID($surveyid); $CI->load->model('questions_model'); //$qquery = "SELECT * FROM ".$CI->db->dbprefix."questions WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order"; - $qquery = "SELECT qid FROM ".$CI->db->dbprefix."questions WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order"; + $qquery = "SELECT qid FROM ".$CI->db->dbprefix."questions WHERE sid=$surveyid AND gid=$gid AND language='{$s_lang}' and parent_qid=0 order by question_order"; //$qresult = db_execute_assoc($qquery); $qresult = $CI->questions_model->getQuestionID($surveyid,$gid,$s_lang); //checked) $qrows = $qresult->result_array(); @@ -706,23 +706,23 @@ function getQidPrevious($surveyid, $gid, $qid) //$qresult = db_execute_assoc($qquery) ; $qresult = $CI->questions_model->getQuestionID($surveyid,$gid,$s_lang); //checked) $qrows = $qresult->result_array(); - - + + $i = 0; $iPrev = -1; if ($qresult->num_rows() > 0) { - + foreach ($qrows as $qrow) { - + if ($qid == $qrow['qid']) {$iPrev = $i - 1;} $i += 1; } } if ($iPrev >= 0) {$QidPrev = $qrows[$iPrev]['qid'];} else {$QidPrev = "";} - + return $QidPrev; } @@ -859,7 +859,7 @@ function getQuestionSum($surveyid, $groupid) 'gid' => $groupid, 'sid' => $surveyid, 'language' => $s_lang - + ); $sumresult3 = $CI->questions_model->getAllRecords($condn); //Checked $questionscount = $sumresult3->num_rows(); @@ -875,14 +875,14 @@ function getQuestionSum($surveyid, $groupid) */ function getMaxgrouporder($surveyid) { - global $CI ; //$surveyid, + global $CI ; //$surveyid, $s_lang = GetBaseLanguageFromSurveyID($surveyid); $CI->load->model('groups_model'); //$max_sql = "SELECT max( group_order ) AS max FROM ".db_table_name('groups')." WHERE sid =$surveyid AND language='{$s_lang}'" ; $query = $CI->groups_model->getMaximumGroupOrder($surveyid,$s_lang); $query = $query->row_array(); $current_max = $query['max']; - + if($current_max!="") { return ++$current_max ; @@ -903,7 +903,7 @@ function getGroupOrder($surveyid,$gid) global $CI; $CI->load->model('groups_model'); $s_lang = GetBaseLanguageFromSurveyID($surveyid); - + //$grporder_sql = "SELECT group_order FROM ".db_table_name('groups')." WHERE sid =$surveyid AND language='{$s_lang}' AND gid=$gid" ; $grporder_result =$CI->groups_model->getOrderOfGroup($surveyid,$gid,$s_lang); //Checked $grporder_row = $grporder_result->row_array() ; @@ -1301,7 +1301,7 @@ function getgrouplist($gid,$surveyid) $groupselecter .= "config->item('scriptname')."?sid=$surveyid&gid=".$gv['gid']."'>".htmlspecialchars($gv['group_name'])."\n"; - } + } if ($groupselecter) { if (!isset($gvexist)) {$groupselecter = "\n".$groupselecter;} @@ -1350,20 +1350,20 @@ function getgrouplist3($gid,$surveyid) $s_lang = GetBaseLanguageFromSurveyID($surveyid); $CI->load->model('groups_model'); - + //$gidquery = "SELECT gid, group_name FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' ORDER BY group_order"; $gidresult = $CI->groups_model->getGroupAndID($surveyid,$s_lang); // or safe_die("Plain old did not work!"); //Checked - + foreach ($gidresult->result_array() as $gv) { $groupselecter .= "".htmlspecialchars($gv['group_name'])."\n"; } - - + + return $groupselecter; } @@ -1379,12 +1379,12 @@ function getgroupname($gid) $s_lang = GetBaseLanguageFromSurveyID($surveyid); //$gidquery = "SELECT group_name FROM ".db_table_name('groups')." WHERE sid=$surveyid AND language='{$s_lang}' and gid=$gid"; $CI->load->model('groups_model'); - + $gidresult = $CI->groups_model->getGroupName($surveyid,$gid,$s_lang) or safe_die("Group name could not be fetched (getgroupname)."); //Checked $gv = $gidresult->row_array(); - + $groupname = htmlspecialchars($gv['group_name']); - + return $groupname; } @@ -1399,11 +1399,11 @@ function getgrouplistlang($gid, $language,$surveyid) //global $surveyid; $CI =& get_instance(); $clang = $CI->limesurvey_lang; - + $CI->load->model('groups_model'); $groupselecter=""; if (!$surveyid) {$surveyid=returnglobal('sid');} - + //$gidquery = "SELECT gid, group_name FROM ".$CI->db->prefix('groups')." WHERE sid=$surveyid AND language='".$language."' ORDER BY group_order"; $gidresult = $CI->groups_model->getGroupAndID($surveyid,$language) or safe_die("Couldn't get group list in common_helper.php
"); //Checked) foreach ($gidresult->result_array() as $gv) @@ -1521,13 +1521,13 @@ function getSurveyInfo($surveyid, $languagecode='') $surveyid=sanitize_int($surveyid); $languagecode=sanitize_languagecode($languagecode); $thissurvey=false; - + // if no language code is set then get the base language one if (!isset($languagecode) || $languagecode=='') { $languagecode=GetBaseLanguageFromSurveyID($surveyid);; } - + //$query="SELECT * FROM ".db_table_name('surveys').",".db_table_name('surveys_languagesettings')." WHERE sid=$surveyid and surveyls_survey_id=$surveyid and surveyls_language='$languagecode'"; $CI->load->model('surveys_languagesettings_model'); @@ -1561,7 +1561,7 @@ function getSurveyInfo($surveyid, $languagecode='') $thissurvey['passthrulabel']=$CI->session->userdata('passthrulabel') ? $CI->session->userdata('passthrulabel') : ""; $thissurvey['passthruvalue']=$CI->session->userdata('passthruvalue') ? $CI->session->userdata('passthruvalue') : ""; } - + //not sure this should be here... ToDo: Find a better place if (function_exists('makelanguagechanger')) $languagechanger = makelanguagechanger(); return $thissurvey; @@ -1569,7 +1569,7 @@ function getSurveyInfo($surveyid, $languagecode='') /** * Returns the default email template texts as array -* +* * @param mixed $oLanguage Required language translationb object * @param string $mode Escape mode for the translation function * @return array @@ -1609,7 +1609,7 @@ function aTemplateDefaultTexts($oLanguage, $mode='html'){ } .printouttable .printanswersgroup td{ - text-align: center; + text-align: center; font-weight:bold; padding-top:1em; } @@ -1695,7 +1695,7 @@ function fixsortorderAnswers($qid) //Function rewrites the sortorder for a group global $CI, $surveyid; $qid=sanitize_int($qid); $baselang = GetBaseLanguageFromSurveyID($surveyid); - + $CI->load->model('answers_model'); $CI->answers_model->updateSortOrder($qid,$baselang); //$cdresult = db_execute_num("SELECT qid, code, sortorder FROM ".db_table_name('answers')." WHERE qid={$qid} and language='{$baselang}' ORDER BY sortorder"); //Checked @@ -1720,7 +1720,7 @@ function fixsortorderQuestions($groupid, $surveyid) //Function rewrites the sort $gid = sanitize_int($groupid); $surveyid = sanitize_int($surveyid); $baselang = GetBaseLanguageFromSurveyID($surveyid); - + $CI->load->model('questions_model'); $CI->questions_model->updateQuestionOrder($gid,$baselang); //$cdresult = db_execute_assoc("SELECT qid FROM ".db_table_name('questions')." WHERE gid='{$gid}' and language='{$baselang}' ORDER BY question_order, title ASC"); //Checked @@ -1742,10 +1742,10 @@ function shiftorderQuestions($sid,$gid,$shiftvalue) //Function shifts the sortor $shiftvalue=sanitize_int($shiftvalue); $baselang = GetBaseLanguageFromSurveyID($surveyid); - + $CI->load->model('questions_model'); $CI->questions_model->updateQuestionOrder($gid,$baselang,$shiftvalue); - + //$cdresult = db_execute_assoc("SELECT qid FROM ".db_table_name('questions')." WHERE gid='{$gid}' and language='{$baselang}' ORDER BY question_order, title ASC"); //Checked //$position=$shiftvalue; //while ($cdrow=$cdresult->FetchRow()) @@ -1780,7 +1780,7 @@ function fixmovedquestionConditions($qid,$oldgid,$newgid) //Function rewrites th $newgid=sanitize_int($newgid); $CI->load->model('conditions_model'); $CI->conditions_model->updateCFieldName($surveyid,$qid,$oldgid,$newgid); - + } @@ -1963,10 +1963,10 @@ function getextendedanswer($surveyid, $action, $fieldcode, $value, $format='') case "I": case "R": $CI->load->model('answers_model'); - + //$query = "SELECT code, answer FROM ".db_table_name('answers')." WHERE qid={$fields['qid']} AND code='".$connect->escape($value)."' AND scale_id=0 AND language='".$s_lang."'"; $result = $CI->answers_model->getAnswerCode($fields['qid'],$value,$s_lang) or safe_die ("Couldn't get answer type L - getextendedanswer() in common_helper.php
$query
"); //Checked - + foreach($result->result_array() as $row) { $this_answer=$row['answer']; @@ -2022,7 +2022,7 @@ function getextendedanswer($surveyid, $action, $fieldcode, $value, $format='') $fieldtoselect = array('answer'); $condition = "qid = {$fields['qid']} AND code=".$CI->db->escape($value)." AND language='".$s_lang."'"; $CI->load->model('answers_model'); - + $result = $CI->answers_model->getSomeRecords($fieldtoselect,$condition) or safe_die ("Couldn't get answer type F/H - getextendedanswer() in common_helper.php"); //Checked foreach($result->result_array() as $row) { @@ -2509,7 +2509,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi { $usedinconditions = "N"; } - + // Field identifier // GXQXSXA // G=Group Q=Question S=Subquestion A=Answer Option @@ -2521,7 +2521,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi if ($qtypes[$arow['type']]['subquestions']==0 && $arow['type'] != "R" && $arow['type'] != "|") { $fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}"; - if (isset($fieldmap[$fieldname])) $aDuplicateQIDs[$arow['qid']]=array('fieldname'=>$fieldname,'question'=>$arow['question'],'gid'=>$arow['gid']); + if (isset($fieldmap[$fieldname])) $aDuplicateQIDs[$arow['qid']]=array('fieldname'=>$fieldname,'question'=>$arow['question'],'gid'=>$arow['gid']); $fieldmap[$fieldname]=array("fieldname"=>$fieldname, 'type'=>"{$arow['type']}", 'sid'=>$surveyid, "gid"=>$arow['gid'], "qid"=>$arow['qid'], "aid"=>""); if ($style == "full") { @@ -2532,34 +2532,37 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi $fieldmap[$fieldname]['hasconditions']=$conditions; $fieldmap[$fieldname]['usedinconditions']=$usedinconditions; $fieldtoselect = array('defaultvalue'); - - if ($arow['same_default']) - { - $conditiontoselect = array( - 'qid' => $arow['qid'], - 'scale_id' => 0, - 'language' => GetBaseLanguageFromSurveyID($surveyid) - ); //"WHERE qid={$arow['qid']} AND scale_id=0 AND language='".GetBaseLanguageFromSurveyID($surveyid)."'"; - $data = $CI->defaultvalues_model->getSomeRecords($fieldtoselect,$conditiontoselect); - $data = $data->row_array(); - $fieldmap[$fieldname]['defaultvalue']=$data['defaultvalue'];//$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE qid={$arow['qid']} AND scale_id=0 AND language='".GetBaseLanguageFromSurveyID($surveyid)."'"); - } - else + + if ($qtypes[$arow['type']]['hasdefaultvalues']) { - //$conditiontoselect = "WHERE qid={$arow['qid']} AND scale_id=0 AND language='{$clang->langcode}'"; - $conditiontoselect = array( - 'qid' => $arow['qid'], - 'scale_id' => 0, - 'language' => $clang->langcode - ); - $data = $CI->defaultvalues_model->getSomeRecords($fieldtoselect,$conditiontoselect); - - $row = $data->row_array(); - if ($data->num_rows() >0) - $fieldmap[$fieldname]['defaultvalue']=$row['defaultvalue'];//$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE qid={$arow['qid']} AND scale_id=0 AND language='{$clang->langcode}'"); + if ($arow['same_default']) + { + $conditiontoselect = array( + 'qid' => $arow['qid'], + 'scale_id' => 0, + 'language' => GetBaseLanguageFromSurveyID($surveyid) + ); //"WHERE qid={$arow['qid']} AND scale_id=0 AND language='".GetBaseLanguageFromSurveyID($surveyid)."'"; + $data = $CI->defaultvalues_model->getSomeRecords($fieldtoselect,$conditiontoselect); + $data = $data->row_array(); + $fieldmap[$fieldname]['defaultvalue']=$data['defaultvalue'];//$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE qid={$arow['qid']} AND scale_id=0 AND language='".GetBaseLanguageFromSurveyID($surveyid)."'"); + } else - $fieldmap[$fieldname]['defaultvalue']=''; - + { + //$conditiontoselect = "WHERE qid={$arow['qid']} AND scale_id=0 AND language='{$clang->langcode}'"; + $conditiontoselect = array( + 'qid' => $arow['qid'], + 'scale_id' => 0, + 'language' => $clang->langcode + ); + $data = $CI->defaultvalues_model->getSomeRecords($fieldtoselect,$conditiontoselect); + + $row = $data->row_array(); + if ($data->num_rows() >0) + $fieldmap[$fieldname]['defaultvalue']=$row['defaultvalue'];//$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE qid={$arow['qid']} AND scale_id=0 AND language='{$clang->langcode}'"); + else + $fieldmap[$fieldname]['defaultvalue']=''; + + } } } switch($arow['type']) @@ -2570,7 +2573,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi { $fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}other"; if (isset($fieldmap[$fieldname])) $aDuplicateQIDs[$arow['qid']]=array('fieldname'=>$fieldname,'question'=>$arow['question'],'gid'=>$arow['gid']); - + $fieldmap[$fieldname]=array("fieldname"=>$fieldname, 'type'=>$arow['type'], 'sid'=>$surveyid, @@ -2594,7 +2597,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi 'qid' => $arow['qid'], 'scale_id' => 0, 'language' => GetBaseLanguageFromSurveyID($surveyid) - ); + ); $data = $CI->defaultvalues_model->getSomeRecords($fieldtoselect,$conditiontoselect); $data = $data->row_array(); $fieldmap[$fieldname]['defaultvalue']=$data['defaultvalue'];//$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE qid={$arow['qid']} AND scale_id=0 AND language='".GetBaseLanguageFromSurveyID($surveyid)."'"); @@ -2606,7 +2609,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi 'qid' => $arow['qid'], 'scale_id' => 0, 'language' => $clang->langcode - ); + ); $data = $CI->defaultvalues_model->getSomeRecords($fieldtoselect,$conditiontoselect); $data = $data->row_array(); $fieldmap[$fieldname]['defaultvalue']=$data['defaultvalue'];//$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE qid={$arow['qid']} AND scale_id=0 AND language='{$clang->langcode}'"); @@ -2617,7 +2620,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi case "O": //DROPDOWN LIST WITH COMMENT $fieldname="{$arow['sid']}X{$arow['gid']}X{$arow['qid']}comment"; if (isset($fieldmap[$fieldname])) $aDuplicateQIDs[$arow['qid']]=array('fieldname'=>$fieldname,'question'=>$arow['question'],'gid'=>$arow['gid']); - + $fieldmap[$fieldname]=array("fieldname"=>$fieldname, 'type'=>$arow['type'], 'sid'=>$surveyid, @@ -2829,7 +2832,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi $data = $data->row_array(); if(isset($data['defaultvalue'])) $fieldmap[$fieldname]['defaultvalue']=$data['defaultvalue']; - + //$fieldmap[$fieldname]['defaultvalue']=$connect->GetOne("SELECT defaultvalue FROM ".db_table_name('defaultvalues')." WHERE sqid={$abrow['qid']} and qid={$arow['qid']} AND scale_id=0 AND language='{$clang->langcode}'"); } } @@ -2937,7 +2940,7 @@ function createTimingsFieldMap($surveyid, $style='full', $force_refresh=false, $ $fieldmap[$fieldname]=array("fieldname"=>$fieldname, 'type'=>"page_time", 'sid'=>$surveyid, "gid"=>$field['gid'], "group_name"=>$field['group_name'], "qid"=>'', 'aid'=>'', 'title'=>'groupTime'.$field['gid'], 'question'=>$clang->gT('Group time').": ".$field['group_name']); } - // field for time spent on answering a question + // field for time spent on answering a question $fieldname="{$field['sid']}X{$field['gid']}X{$field['qid']}time"; if (!isset($fieldmap[$fieldname])) { @@ -3017,15 +3020,15 @@ function templatereplace($line, $replacements=array(),$redata) 'surveyformat', 'completed', 'register_errormsg', 'notanswered', 'privacy', 'surveyid', 'publicurl', 'templatedir', 'token', 'assessments', 's_lang', 'errormsg', 'clang', 'saved_id', 'usertemplaterootdir', 'totalBoilerplatequestions', 'relativeurl', 'languagechanger', 'printoutput', 'captchapath', 'loadname'); - + foreach($allowedvars as $var) { if(isset($redata[$var])) $$var = $redata[$var]; } - + $showXquestions = $CI->config->item("showXquestions"); $showgroupinfo = $CI->config->item("showgroupinfo"); - + /*$thissurvey = $redata['thissurvey'] ; $percentcomplete = $redata['percentcomplete'] ; $groupname = $redata['groupname'] ; @@ -3045,30 +3048,30 @@ function templatereplace($line, $replacements=array(),$redata) $templateurl = $redata['templateurl'] ; if (isset($redata['surveylist'])) $surveylist = $redata['surveylist'] ; - + if (isset($redata['question'])) { $question = $redata['question'] ; } if (isset($redata['answer'])) $answer = $redata['answer'] ; - + $templatename = $redata['templatename'] ; $screenname = $redata['screenname'] ; $editfile = $redata['editfile'] ;*/ - - + + if (file_exists($line)) { $line = file_get_contents($line); } - + $clang = $CI->limesurvey_lang; $CI->load->helper('surveytranslator'); $questiondetails = array('sid' => 0, 'gid' => 0, 'qid' => 0, 'aid' =>0); if(isset($question) && $question['sgq']) $questiondetails=getsidgidqidaidtype($question['sgq']); //Gets an array containing SID, GID, QID, AID and Question Type) - + // lets sanitize the survey template if(isset($thissurvey['templatedir'])) { @@ -3085,7 +3088,7 @@ function templatereplace($line, $replacements=array(),$redata) // create absolute template URL and template dir vars //$templateurl=sGetTemplateURL($templatename).'/'; //$templatedir=sgetTemplatePath($templatename); - + if (stripos ($line,"")) { $line=str_ireplace("", @@ -3122,7 +3125,7 @@ function templatereplace($line, $replacements=array(),$redata) { $surveycontact=""; } - + // If there are non-bracketed replacements to be made do so above this line. // Only continue in this routine if there are bracketed items to replace {} if (strpos($line, "{") === false) { @@ -3134,10 +3137,10 @@ function templatereplace($line, $replacements=array(),$redata) if (strpos($line, '{'.$replacementkey.'}') !== false) $line=str_replace('{'.$replacementkey.'}', $replacementvalue, $line); } */ - + //$data = array_merge($data,$replacements); $data = $replacements; - + /** if (strpos($line, "{SURVEYLISTHEADING}") !== false) $line=str_replace("{SURVEYLISTHEADING}", $surveylist['listheading'], $line); @@ -3159,11 +3162,11 @@ function templatereplace($line, $replacements=array(),$redata) if (strpos($line, "{LANGUAGECHANGER}") !== false) $line=str_replace("{LANGUAGECHANGER}", $languagechanger, $line); if (strpos($line, "{PERCENTCOMPLETE}") !== false) $line=str_replace("{PERCENTCOMPLETE}", $percentcomplete, $line); */ - + if(!isset($percentcomplete)) $percentcomplete = "PERCENTCOMPLETE"; if(!isset($thissurvey['description'])) $thissurvey['description'] = "SURVEYDESCRIPTION"; if(!isset($thissurvey['welcome'])) $thissurvey['welcome'] = "WELCOME"; - + $temparr = array( "SURVEYLISTHEADING" => (isset($surveylist))?$surveylist['listheading']:'', "SURVEYLIST" => (isset($surveylist))?$surveylist['list']:'', @@ -3180,10 +3183,10 @@ function templatereplace($line, $replacements=array(),$redata) "WELCOME" => $thissurvey['welcome'], "LANGUAGECHANGER" => $languagechanger, "PERCENTCOMPLETE" => $percentcomplete - + ); $data = array_merge($data,$temparr); - + if(isset($groupname) && ($showgroupinfo == 'both' || $showgroupinfo == 'name' || @@ -3243,8 +3246,8 @@ function templatereplace($line, $replacements=array(),$redata) "QUESTION_FILE_VALID_MESSAGE" => $question['file_valid_message'] ); $data = array_merge($data,$temparr); - - + + } } else @@ -3252,25 +3255,25 @@ function templatereplace($line, $replacements=array(),$redata) //if (strpos($line, "{QUESTION}") !== false) $line=str_replace("{QUESTION}", $question, $line); $data = array_merge($data,array("QUESTION" => '')); }; - + /** if (strpos($line, '{QUESTION_ESSENTIALS}') !== false) $line=str_replace('{QUESTION_ESSENTIALS}', $question['essentials'], $line); if (strpos($line, '{QUESTION_CLASS}') !== false) $line=str_replace('{QUESTION_CLASS}', $question['class'], $line); if (strpos($line, '{QUESTION_MAN_CLASS}') !== false) $line=str_replace('{QUESTION_MAN_CLASS}', $question['man_class'], $line); if (strpos($line, "{QUESTION_INPUT_ERROR_CLASS}") !== false) $line=str_replace("{QUESTION_INPUT_ERROR_CLASS}", $question['input_error_class'], $line); */ - + if (isset($question)) { $temparr = array( 'QUESTION_ESSENTIALS' => $question['essentials'], - 'QUESTION_CLASS' => $question['class'], + 'QUESTION_CLASS' => $question['class'], 'QUESTION_MAN_CLASS' => $question['man_class'], 'QUESTION_INPUT_ERROR_CLASS' => $question['input_error_class'] ); $data = array_merge($data,$temparr); } - + if(isset($question) && ( $showqnumcode == 'both' || $showqnumcode == 'number' || @@ -3308,7 +3311,7 @@ function templatereplace($line, $replacements=array(),$redata) //if (strpos($line, "{ANSWER}") !== false) $line=str_replace("{ANSWER}", $answer, $line); if (isset($answer)) $data = array_merge($data,array("ANSWER" => $answer)); - + if(!isset($totalquestions)) $totalquestions = 0; $totalquestionsAsked = $totalquestions - $totalBoilerplatequestions; if( @@ -3340,8 +3343,8 @@ function templatereplace($line, $replacements=array(),$redata) }; //if (strpos($line, "{NUMBEROFQUESTIONS}") !== false) $line=str_replace("{NUMBEROFQUESTIONS}", $totalquestionsAsked, $line); $data = array_merge($data,array("NUMBEROFQUESTIONS" => $totalquestionsAsked)); - - + + if (strpos($line, "{TOKEN}") !== false) { if (isset($token)) { //$line=str_replace("{TOKEN}", $token, $line); @@ -3374,16 +3377,16 @@ function templatereplace($line, $replacements=array(),$redata) //if (strpos($line, "{NAVIGATOR}") !== false) $line=str_replace("{NAVIGATOR}", $navigator, $line); if(!isset($navigator)) $navigator = "NAVIGATOR"; $data = array_merge($data,array("NAVIGATOR" => $navigator)); - + if (strpos($line, "{SUBMITBUTTON}") !== false) { $submitbutton=""; //$line=str_replace("{SUBMITBUTTON}", $submitbutton, $line); $data = array_merge($data,array("SUBMITBUTTON" => $submitbutton)); } //if (strpos($line, "{COMPLETED}") !== false) $line=str_replace("{COMPLETED}", $completed, $line); - if(!isset($completed)) $completed = "COMPLETED"; + if(!isset($completed)) $completed = "COMPLETED"; $data = array_merge($data,array("COMPLETED" => $completed)); - + if (strpos($line, "{URL}") !== false) { if ($thissurvey['surveyls_url']!=""){ if (trim($thissurvey['surveyls_urldescription'])!=''){ @@ -3396,17 +3399,17 @@ function templatereplace($line, $replacements=array(),$redata) else $linkreplace=''; //$line=str_replace("{URL}", $linkreplace, $line); $data = array_merge($data,array("URL" => $linkreplace)); - + //$line=str_replace("{SAVEDID}",$saved_id, $line); // to activate the SAVEDID in the END URL $data = array_merge($data,array("SAVEDID" => $saved_id)); - + if (isset($clienttoken)) {$token=$clienttoken;} else {$token='';} - //$line=str_replace("{TOKEN}",urlencode($token), $line); + //$line=str_replace("{TOKEN}",urlencode($token), $line); $data = array_merge($data,array("TOKEN" => urlencode($token))); // to activate the TOKEN in the END URL //$line=str_replace("{SID}", $surveyid, $line); // to activate the SID in the RND URL $data = array_merge($data,array("SID" => $surveyid)); - + } if (strpos($line, "{PRIVACY}") !== false) { @@ -3501,7 +3504,7 @@ function templatereplace($line, $replacements=array(),$redata) { $templatecss.="\n"; } - //$line=str_replace("{TEMPLATECSS}", $templatecss, $line); + //$line=str_replace("{TEMPLATECSS}", $templatecss, $line); $data = array_merge($data,array("TEMPLATECSS" => $templatecss)); } @@ -3544,7 +3547,7 @@ function templatereplace($line, $replacements=array(),$redata) $line=insertansReplace($line); /** if (strpos($line, "{SID}") !== false) $line=str_replace("{SID}", $questiondetails['sid'], $line); - + if (strpos($line, "{GID}") !== false) $line=str_replace("{GID}", $questiondetails['gid'], $line); if (strpos($line, "{QID}") !== false) $line=str_replace("{QID}", $questiondetails['qid'], $line); if (strpos($line, "{AID}") !== false) $line=str_replace("{AID}", $questiondetails['aid'], $line); @@ -3556,15 +3559,15 @@ function templatereplace($line, $replacements=array(),$redata) "SID" => $questiondetails['sid'], "GID" => $questiondetails['gid'], "QID" => $questiondetails['qid'], - "AID" => (isset($questiondetails['aid']) ? $questiondetails['aid'] : ''), + "AID" => (isset($questiondetails['aid']) ? $questiondetails['aid'] : ''), "SGQ" => (isset($question))?$question['sgq']:'', "SUBMITCOMPLETE" => "".$clang->gT("Thank you!")."

".$clang->gT("You have completed answering the questions in this survey.")."


".$clang->gT("Click on 'Submit' now to complete the process and save your answers.") - - + + ); - + $data = array_merge($data,$temparr); - + if (strpos($line, "{SUBMITREVIEW}") !== false) { if (isset($thissurvey['allowprev']) && $thissurvey['allowprev'] == "N") { $strreview = ""; @@ -3610,13 +3613,13 @@ function templatereplace($line, $replacements=array(),$redata) "SAVEERROR" => $errormsg, "SAVEHEADING" => $clang->gT("Save Your Unfinished Survey"), "SAVEMESSAGE" => $clang->gT("Enter a name and password for this survey and click save below.")."
\n".$clang->gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.")."

\n".$clang->gT("If you give an email address, an email containing the details will be sent to you.")."

\n".$clang->gT("After having clicked the save button you can either close this browser window or continue filling out the survey.") - + ); - + $data = array_merge($data,$temparr); - - - if (strpos($line, "{SAVEALERT}") !== false) + + + if (strpos($line, "{SAVEALERT}") !== false) { if (isset($thissurvey['anonymized']) && $thissurvey['anonymized'] =='Y') { @@ -3629,7 +3632,7 @@ function templatereplace($line, $replacements=array(),$redata) //$line=str_replace("{SAVEALERT}", $savealert, $line); $data = array_merge($data,array("SAVEALERT" => $savealert)); } - + if (strpos($line, "{RETURNTOSURVEY}") !== false) { $savereturn = "", $line); */ - + $temparr = array( "LOADERROR" => $errormsg, "LOADHEADING" => $clang->gT("Load A Previously Saved Survey"), - "LOADMESSAGE" => $clang->gT("You can load a survey that you have previously saved from this screen.")."
".$clang->gT("Type in the 'name' you used to save the survey, and the password.")."
" + "LOADMESSAGE" => $clang->gT("You can load a survey that you have previously saved from this screen.")."
".$clang->gT("Type in the 'name' you used to save the survey, and the password.")."
" ); $data = array_merge($data,$temparr); - - + + if (strpos($line, "{LOADFORM}") !== false) { //LOAD SURVEY DETAILS $loadform = "\n"; - } + } $registerform .= "\n" ."
".$clang->gT("Saved name").":\n"; @@ -3777,7 +3780,7 @@ function templatereplace($line, $replacements=array(),$redata) $registerform .= " value='".htmlentities(returnglobal('register_attribute2'),ENT_QUOTES,'UTF-8')."'"; } $registerform .= " />
" ."
\n" @@ -3791,7 +3794,7 @@ function templatereplace($line, $replacements=array(),$redata) //$line=str_replace("{ASSESSMENT_CURRENT_TOTAL}", $assessmentdata['total'], $line); $data = array_merge($data,array("ASSESSMENT_CURRENT_TOTAL" => $assessmentdata['total'])); } - + /** if (strpos($line, "{ASSESSMENTS}") !== false) $line=str_replace("{ASSESSMENTS}", $assessments, $line); if (strpos($line, "{ASSESSMENT_HEADING}") !== false) $line=str_replace("{ASSESSMENT_HEADING}", $clang->gT("Your Assessment"), $line); @@ -3799,19 +3802,19 @@ function templatereplace($line, $replacements=array(),$redata) if(!isset($assessments)) $assessments = "ASSESSMENTS"; $temparr = array( "ASSESSMENTS" => $assessments, - "ASSESSMENT_HEADING" => $clang->gT("Your Assessment") + "ASSESSMENT_HEADING" => $clang->gT("Your Assessment") ); $data = array_merge($data,$temparr); - - + + $CI->load->library('parser'); //var_dump($line); //echo "


"; //var_dump($data); - + return $CI->parser->parse_string($line,$data,TRUE); - - + + } @@ -3896,7 +3899,7 @@ function tokenReplace($line) /** * set the rights of a user and his children - * + * * @param int $uid the user id * @param mixed $rights rights array */ @@ -3930,17 +3933,17 @@ function PassthruReplace($line, $thissurvey) { $line=str_replace("{PASSTHRULABEL}", $thissurvey['passthrulabel'], $line); $line=str_replace("{PASSTHRUVALUE}", $thissurvey['passthruvalue'], $line); - + // Replacement for variable passthru argument like {PASSTHRU:myarg} while (strpos($line,"{PASSTHRU:") !== false) { $p1 = strpos($line,"{PASSTHRU:"); // startposition $p2 = $p1 + 10; // position of the first arg char $p3 = strpos($line,"}",10); // position of the last arg char - + $cmd=substr($line,$p1,$p3-$p1+1); // extract the complete passthru like "{PASSTHRU:myarg}" $arg=substr($line,$p2,$p3-$p2); // extract the arg to passthru (like "myarg") - + // lookup for the fitting arg $qstring = $_SESSION['ls_initialquerystr']; // get initial query_string @@ -3954,17 +3957,17 @@ function PassthruReplace($line, $thissurvey) $match = 1; break; } - + } - + if ($match == 0) { $line=str_replace($cmd, $arg . "=", $line); // clears "{PASSTHRU:myarg} to "myarg=" if there was no myarg in calling url } } - + return $line; -} +} /** * This function returns a count of the number of saved responses to a survey @@ -3973,14 +3976,14 @@ function PassthruReplace($line, $thissurvey) */ function getSavedCount($surveyid) { - + global $CI; - + $surveyid=(int)$surveyid; - + $CI->load->model('saved_control_model'); - - + + //$query = "SELECT COUNT(*) FROM ".db_table_name('saved_control')." WHERE sid=$surveyid"; $count=$CI->saved_control_model->getCountOfAll($surveyid); return $count; @@ -4003,7 +4006,7 @@ function GetBaseLanguageFromSurveyID($surveyid) $CI->load->model('surveys_model'); $query = $CI->surveys_model->getSomeRecords($fields,$condition);//("SELECT language FROM ".db_table_name('surveys')." WHERE sid=$surveyid";) $surveylanguage = $query->row_array(); //Checked) - + $surveylanguage = $surveylanguage['language']; if (is_null($surveylanguage)) { @@ -4062,7 +4065,7 @@ function SetSurveyLanguage($surveyid, $language) $fields = array('language', 'additional_languages'); $condition = "sid = $surveyid"; $CI->load->model('surveys_model'); - + //$query = "SELECT language, additional_languages FROM ".db_table_name('surveys')." WHERE sid=$surveyid"; $result = $CI->surveys_model->getSomeRecords($fields,$condition); //Checked foreach ($result->result_array() as $row) {//while ($result && ($row=$result->FetchRow())) {) @@ -4103,7 +4106,7 @@ function buildLabelSetCheckSumArray() global $CI; // BUILD CHECKSUMS FOR ALL EXISTING LABEL SETS $CI->load->model('labelsets'); - + /**$query = "SELECT lid FROM ".db_table_name('labelsets')." ORDER BY lid"; */ @@ -4113,7 +4116,7 @@ function buildLabelSetCheckSumArray() { $thisset=""; $CI->load->models('labels'); - + /**$query2 = "SELECT code, title, sortorder, language, assessment_value FROM ".db_table_name('labels')." WHERE lid={$row['lid']} @@ -5284,7 +5287,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, $CI->config->load('email'); //$CI->config->item(''); - + if (!is_array($customheaders) && $customheaders == '') { $customheaders=array(); @@ -5312,10 +5315,10 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, //{ // $mail->SetLanguage('en',$rootdir.'/classes/phpmailer/language/'); //} - + //Auto loaded //$mail->CharSet = $emailcharset; - + //if (isset($emailsmtpssl) && trim($emailsmtpssl)!=='' && $emailsmtpssl!==0) { // if ($emailsmtpssl===1) {$mail->SMTPSecure = "ssl";} // else {$mail->SMTPSecure = $emailsmtpssl;} @@ -5376,7 +5379,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, //Unsupported by CI mail class: //$mail->Sender = $senderemail; // Sets Return-Path for error notifications $toemails = explode(";", $to); - + $toarray = array(); foreach ($toemails as $singletoemail) { @@ -5394,7 +5397,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, } } $CI->email->to($toarray); - + //Unsupported /*if (is_array($customheaders)) { @@ -5404,7 +5407,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, } $mail->AddCustomHeader("X-Surveymailer: $sitename Emailer (LimeSurvey.sourceforge.net)"); */ - + if (get_magic_quotes_gpc() != "0") {$body = stripcslashes($body);} if ($ishtml) { /*$mail->IsHTML(true); @@ -5747,7 +5750,7 @@ function getGroupsByQuestion($surveyid) { $surveyid=sanitize_int($surveyid); //$query="SELECT qid, gid FROM ".db_table_name('questions')." WHERE sid='$surveyid'"; //$result = db_execute_assoc($query); - + $CI->load->model('Questions_model'); $result=$CI->Questions_model->getSomeRecords("qid, gid",array("sid"=>$surveyid)); @@ -5821,7 +5824,7 @@ function getArrayFilterExcludesForQuestion($qid) { static $cascadesCache = array(); static $cache = array(); - + $CI = & get_instance(); $dbprefix = $CI->db->dbprefix; @@ -5900,13 +5903,13 @@ function killSession() //added by Dennis { global $CI; $CI->session->sess_destroy(); - + // making dummy session variable check to destroy session completely! if($CI->session->userdata('loginID')) $CI->session->unset_userdata('loginID'); - + //This is necessary for frontend: - + // Delete the Session Cookie $CookieInfo = session_get_cookie_params(); if ( (empty($CookieInfo['domain'])) && (empty($CookieInfo['secure'])) ) { @@ -5924,7 +5927,7 @@ function killSession() //added by Dennis } $_SESSION = array(); // redundant with previous lines session_unset(); - @session_destroy(); + @session_destroy(); } function CSVEscape($str) @@ -5961,7 +5964,7 @@ function languageDropdown($surveyid,$selected) $baselang = GetBaseLanguageFromSurveyID($surveyid); array_unshift($slangs,$baselang); $html = " - + - - + +
/previous_20.png' title='' alt='gT("Previous question group"); ?>' - name='questiongroupprevious' gT("Previous question group"); ?>/> + name='questiongroupprevious' /> - + /previous_disabled_20.png' title='' alt='gT("No previous question group"); ?>' name='noquestiongroupprevious' /> - - + + /next_20.png' title='' alt='gT("Next question group"); ?>' name='questiongroupnext' /> - + /next_disabled_20.png' title='' alt='gT("No next question group"); ?>' name='noquestiongroupnext' /> - + - /add_disabled.png' title='' alt='gT("Disabled"); ?> - gT("This survey is currently active."); ?>' + /add_disabled.png' title='' alt='gT("Disabled"); ?> - gT("This survey is currently active."); ?>' name='AddNewGroup' /> - + ', '_top')" title="gTview("Add new group to survey"); ?>"> /add.png' alt='gT("Add new group to survey"); ?>' name='AddNewGroup' /> @@ -250,15 +250,15 @@ alt='gT("Hide details of this Survey"); ?>' name='MinimiseSurveyWindow' onclick='document.getElementById("surveydetails").style.display="none";' /> - /plus.gif' title='gT("Show details of this survey"); ?>' - alt='gT("Show details of this survey"); ?>' name='MaximiseSurveyWindow' + /plus.gif' title='gT("Show details of this survey"); ?>' + alt='gT("Show details of this survey"); ?>' name='MaximiseSurveyWindow' onclick='document.getElementById("surveydetails").style.display="";' /> - - /close.gif' title='gT("Close this survey"); ?>' - alt='gT("Close this survey"); ?>' name='CloseSurveyWindow' + + /close.gif' title='gT("Close this survey"); ?>' + alt='gT("Close this survey"); ?>' name='CloseSurveyWindow' onclick="window.open('', '_top')" />