From 105d1150ce6bbeefd2aa7731b2f68f5d1c82a95c Mon Sep 17 00:00:00 2001 From: Shitiz Garg Date: Wed, 23 Nov 2011 22:14:34 +0000 Subject: [PATCH] Commit for GCI Task #7121235, #7121234, #7132249, #7134284, #7132250 Ported quexml export, export to xml lss archive, detailed list of surveys, export to spss and printable version git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11463 b72ed6b6-b9f8-46b5-92b4-906544132732 --- application/config/tcpdf_config_ci.php | 4 +- application/controllers/AdminController.php | 5 +- application/controllers/admin/export.php | 68 ++- .../controllers/admin/printablesurvey.php | 310 +++++----- .../controllers/admin/surveyaction.php | 413 +++++++------ application/core/Survey_Common_Action.php | 12 +- application/helpers/common_helper.php | 3 +- application/helpers/export_helper.php | 324 +++++----- application/libraries/admin/quexmlpdf.php | 571 +++++++++--------- application/views/admin/export/spss_view.php | 2 +- application/views/admin/super/adminmenu.php | 7 +- .../survey/Question/questionbar_view.php | 64 +- .../views/admin/survey/deleteSurvey_view.php | 2 +- .../views/admin/survey/listSurveys_view.php | 12 +- scripts/admin/admin_core.js | 2 +- 15 files changed, 886 insertions(+), 913 deletions(-) diff --git a/application/config/tcpdf_config_ci.php b/application/config/tcpdf_config_ci.php index 6e15e3baa93..939523a1346 100644 --- a/application/config/tcpdf_config_ci.php +++ b/application/config/tcpdf_config_ci.php @@ -74,8 +74,8 @@ * * ADD TRAILING SLASH! ***********************************************************/ - $CI =& get_instance(); - $tcpdf['image_directory'] = $CI->config->item('imagedir').DIRECTORY_SEPARATOR; + + $tcpdf['image_directory'] = Yii::app()->getConfig('imagedir').DIRECTORY_SEPARATOR; /************************************************************ diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index 6ab0a14912d..70f8c1b9d75 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -10,7 +10,7 @@ * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. * - * $Id: LSCI_Controller.php 11188 2011-10-17 14:28:02Z mot3 $ + * $Id: AdminController.php 11413 2011-11-21 22:08:16Z dragooongarg $ */ class AdminController extends LSYii_Controller @@ -112,8 +112,9 @@ public function actions() 'globalsettings' => 'application.controllers.admin.globalsettings', 'quotas' => 'application.controllers.admin.quotas', 'export' => 'application.controllers.admin.export', - 'survey' => 'application.controllers.admin.surveyaction', 'assessments' =>'application.controllers.admin.assessments', + 'survey' => 'application.controllers.admin.surveyaction', + 'printablesurvey' => 'application.controllers.admin.printablesurvey', ); } diff --git a/application/controllers/admin/export.php b/application/controllers/admin/export.php index e5f1d680427..9ebd75fb115 100644 --- a/application/controllers/admin/export.php +++ b/application/controllers/admin/export.php @@ -42,11 +42,17 @@ public function run($sa) $this->route('group', array('surveyid', 'gid')); elseif ($sa == 'exportresults') $this->route('exportresults', array('surveyid')); + elseif ($sa == 'survey') + $this->route('survey', array('action', 'surveyid')); + elseif ($sa == 'showquexmlsurvey') + $this->route('showquexmlsurvey', array('surveyid', 'lang')); + elseif ($sa == 'exportspss') + $this->route('exportspss', array('sid', 'lang')); } - function survey($action,$sSurveyID) + function survey($action,$surveyid) { - $iSurveyID= (int)$sSurveyID; + $iSurveyID= (int) $surveyid; if(bHasSurveyPermission($iSurveyID,'surveycontent','export')) { self::_surveyexport($action, $iSurveyID); return; @@ -102,7 +108,6 @@ function surveyarchives() function _surveyexport($action, $surveyid) { - $surveyid = sanitize_int($surveyid); if($action == "exportstructurexml") { @@ -157,14 +162,14 @@ function _surveyexport($action, $surveyid) function _exportarchive($iSurveyID, $bSendToBrowser=true) { $aSurveyInfo=getSurveyInfo($iSurveyID); - $sTempDir = $this->config->item("tempdir"); + $sTempDir = Yii::app()->getConfig("tempdir"); $aZIPFileName=$sTempDir.DIRECTORY_SEPARATOR.sRandomChars(30); $sLSSFileName=$sTempDir.DIRECTORY_SEPARATOR.sRandomChars(30); $sLSRFileName=$sTempDir.DIRECTORY_SEPARATOR.sRandomChars(30); $sLSTFileName=$sTempDir.DIRECTORY_SEPARATOR.sRandomChars(30); $sLSIFileName=$sTempDir.DIRECTORY_SEPARATOR.sRandomChars(30); - $this->load->library("admin/pclzip/pclzip",array('p_zipname' => $aZIPFileName)); + Yii::import('application.libraries.admin.pclzip.pclzip', true); $zip = new PclZip($aZIPFileName); file_put_contents($sLSSFileName,survey_getXMLData($iSurveyID)); @@ -179,14 +184,14 @@ function _exportarchive($iSurveyID, $bSendToBrowser=true) PCLZIP_ATT_FILE_NEW_FULL_NAME =>'survey_'.$iSurveyID.'_responses.lsr'))); unlink($sLSRFileName); } - if ($this->db->table_exists('tokens_'.$iSurveyID)) + if (Yii::app()->db->schema->getTable('{{tokens_'.$iSurveyID . '}}')) { getXMLDataSingleTable($iSurveyID,'tokens_'.$iSurveyID,'Tokens','tokens',$sLSTFileName); $zip->add(array(array(PCLZIP_ATT_FILE_NAME=>$sLSTFileName, PCLZIP_ATT_FILE_NEW_FULL_NAME =>'survey_'.$iSurveyID.'_tokens.lst'))); unlink($sLSTFileName); } - if ($this->db->table_exists('survey_'.$iSurveyID.'_timings')) + if (Yii::app()->db->schema->getTable('{{survey_'.$iSurveyID.'_timings}}')) { getXMLDataSingleTable($iSurveyID,'survey_'.$iSurveyID.'_timings','Timings','timings',$sLSIFileName); $zip->add(array(array(PCLZIP_ATT_FILE_NAME=>$sLSIFileName, @@ -444,12 +449,12 @@ function exportresults($surveyid) * * Optimization opportunities remain in the VALUE LABELS section, which runs a query / column */ - function exportspss($surveyi, $subaction = null) + function exportspss($sid, $subaction = null) { - $surveyid = (int) $surveyi; - $dbprefix = $this->db->dbprefix; - $clang = $this->limesurvey_lang; - $_POST = $this->input->post(); + global $surveyid; + + $surveyid = (int) $sid; + $clang = $this->getController()->lang; //for scale 1=nominal, 2=ordinal, 3=scale $typeMap = array( '5'=>Array('name'=>'5 Point Choice','size'=>1,'SPSStype'=>'F','Scale'=>3), @@ -488,12 +493,12 @@ function exportspss($surveyi, $subaction = null) $filterstate = incompleteAnsFilterstate(); $spssver = returnglobal('spssver'); if (is_null($spssver)) { - if (!$this->session->userdata('spssversion')) { - $this->session->set_userdata('spssversion', 2); //Set default to 2, version 16 or up + if (!Yii::app()->session['spssversion']) { + Yii::app()->session['spssversion'] = 2; //Set default to 2, version 16 or up } - $spssver = $this->session->userdata('spssversion'); + $spssver = Yii::app()->session['spssversion']; } else { - $this->session->set_userdata('spssversion', $spssver); + Yii::app()->session['spssversion'] = $spssver; } $length_varlabel = '255'; // Set the max text length of Variable Labels @@ -518,8 +523,8 @@ function exportspss($surveyi, $subaction = null) if (!isset($subaction)) { - self::_getAdminHeader(); - self::_browsemenubar($surveyid, $clang->gT('Export results')); + $this->getController()->_getAdminHeader(); + $this->_browsemenubar($surveyid, $clang->gT('Export results')); $selecthide=""; $selectshow=""; @@ -540,15 +545,16 @@ function exportspss($surveyi, $subaction = null) $data['selecthide'] = $selecthide; $data['selectshow'] = $selectshow; $data['spssver'] = $spssver; - $this->load->view("admin/export/spss_view",$data); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $data['surveyid'] = $surveyid; + $this->getController()->render("/admin/export/spss_view",$data); + $this->getController()->_getAdminFooter("http://docs.limesurvey.org", $clang->gT("LimeSurvey online manual")); } else { // Get Base language: $language = GetBaseLanguageFromSurveyID($surveyid); $clang = new limesurvey_lang(array($language)); - $this->load->helper("admin/exportresults"); + Yii::app()->loadHelper("admin/exportresults"); } @@ -578,11 +584,12 @@ function exportspss($surveyi, $subaction = null) //Now get the query string with all fields to export $query = spss_getquery(); - $result=db_execute_assoc($query) or safe_die("Couldn't get results
$query
".$connect->ErrorMsg()); //Checked - $num_fields = count($result->row_array()); + $result=Yii::app()->db->createCommand($query)->query()->readAll(); //Checked + + $num_fields = isset($result[0]) ? count($result[0]) : 0; //Now we check if we need to adjust the size of the field or the type of the field - foreach ($result->result_array() as $row) { + foreach ($result as $row) { $row = array_values($row); $fieldno = 0; while ($fieldno < $num_fields) @@ -1109,7 +1116,7 @@ function vvexport($surveyid, $subaction = null) function showquexmlsurvey($surveyid, $lang = null) { $surveyid = sanitize_int($surveyid); - $tempdir = $this->config->item("tempdir"); + $tempdir = Yii::app()->getConfig("tempdir"); // Set the language of the survey, either from GET parameter of session var if (isset($lang)) @@ -1124,8 +1131,8 @@ function showquexmlsurvey($surveyid, $lang = null) // Setting the selected language for printout $clang = new limesurvey_lang(array($surveyprintlang)); - $this->load->library("admin/queXMLPDF"); - $quexmlpdf = $this->quexmlpdf; //new queXMLPDF(PDF_PAGE_ORIENTATION, 'mm', PDF_PAGE_FORMAT, true, 'UTF-8', false); + Yii::import("application.libraries.admin.queXMLPDF", true); + $quexmlpdf = new queXMLPDF($this->getController()); //new queXMLPDF(PDF_PAGE_ORIENTATION, 'mm', PDF_PAGE_FORMAT, true, 'UTF-8', false); set_time_limit(120); @@ -1138,7 +1145,7 @@ function showquexmlsurvey($surveyid, $lang = null) //NEED TO GET QID from $quexmlpdf $qid = intval($quexmlpdf->getQuestionnaireId()); - $zipdir=self::_tempdir($tempdir); + $zipdir= self::_tempdir($tempdir); $f1 = "$zipdir/quexf_banding_{$qid}_{$surveyprintlang}.xml"; $f2 = "$zipdir/quexmlpdf_{$qid}_{$surveyprintlang}.pdf"; @@ -1150,8 +1157,8 @@ function showquexmlsurvey($surveyid, $lang = null) file_put_contents($f3, $quexml); file_put_contents($f4, $clang->gT('This archive contains a PDF file of the survey, the queXML file of the survey and a queXF banding XML file which can be used with queXF: http://quexf.sourceforge.net/ for processing scanned surveys.')); - $this->load->library("admin/Phpzip"); - $z = $this->phpzip; + Yii::import('application.libraries.admin.phpzip', true); + $z = new Phpzip; $zipfile="$tempdir/quexmlpdf_{$qid}_{$surveyprintlang}.zip"; $z->Zip($zipdir, $zipfile); @@ -1165,6 +1172,7 @@ function showquexmlsurvey($surveyid, $lang = null) header('Content-Transfer-Encoding: binary'); header('Content-Disposition: attachment; filename="quexmlpdf_' . $qid . '_' . $surveyprintlang . '.zip"'); header("Pragma: public"); + // load the file to send: readfile($zipfile); unlink($zipfile); diff --git a/application/controllers/admin/printablesurvey.php b/application/controllers/admin/printablesurvey.php index 658dcb04a2a..6316cd99162 100644 --- a/application/controllers/admin/printablesurvey.php +++ b/application/controllers/admin/printablesurvey.php @@ -22,28 +22,21 @@ * @package LimeSurvey * @subpackage Backend */ -class printablesurvey extends Admin_Controller { - - /** - * Constructor - */ - function __construct() - { - parent::__construct(); - } +class printablesurvey extends CAction +{ /** * Show printable survey */ - function index($surveyid, $lang = null) + function run($surveyid, $lang = null) { $surveyid = sanitize_int($surveyid); - $this->load->helper("database"); + //echo '
'.print_r($_SESSION,true).'
'; // PRESENT SURVEY DATAENTRY SCREEN if(isset($_POST['printableexport'])) { - $this->load->library("admin/pdf"); + Yii::import("application.libraries.admin.pdf"); $pdf = new PDF ($pdforientation,'mm','A4'); $pdf->SetFont($pdfdefaultfont,'',$pdffontsize); $pdf->AddPage(); @@ -55,15 +48,15 @@ function index($surveyid, $lang = null) if ($lang) $surveyprintlang = $lang; } else { - $surveyprintlang=GetbaseLanguageFromSurveyid($surveyid); + $surveyprintlang=GetbaseLanguageFromSurveyid((int) $surveyid); } // Setting the selected language for printout $clang = new limesurvey_lang(array('lang' => $surveyprintlang)); - $desquery = "SELECT * FROM ".$this->db->dbprefix('surveys')." inner join ".$this->db->dbprefix('surveys_languagesettings')." on (surveyls_survey_id=sid) WHERE sid={$surveyid} and surveyls_language=".$this->db->escape($surveyprintlang); //Getting data for this survey + $desquery = "SELECT * FROM {{surveys}} inner join {{surveys_languagesettings}} on (surveyls_survey_id=sid) WHERE sid={$surveyid} and surveyls_language=:lang"; //Getting data for this survey - $desrow = db_execute_assoc($desquery)->row_array(); + $desrow = Yii::app()->db->createCommand($desquery)->query(array('lang' => $surveyprintlang))->read(); if ($desrow==false || count($desrow)==0) { @@ -77,7 +70,7 @@ function index($surveyid, $lang = null) $surveyname = $desrow['surveyls_title']; $surveydesc = $desrow['surveyls_description']; $surveyactive = $desrow['active']; - $surveytable = $this->db->dbprefix("survey_".$desrow['sid']); + $surveytable = "{{survey_".$desrow['sid']."}}"; $surveyexpirydate = $desrow['expires']; $surveystartdate = $desrow['startdate']; $surveyfaxto = $desrow['faxto']; @@ -86,7 +79,7 @@ function index($surveyid, $lang = null) if(isset($_POST['printableexport'])){$pdf->titleintopdf($surveyname,$surveydesc);} - $this->load->helper("surveytranslator"); + Yii::app()->loadHelper('surveytranslator'); $dformat=getDateFormatData($dateformattype); $dformat=$dformat['phpdate']; @@ -102,21 +95,21 @@ function index($surveyid, $lang = null) }; //define('PRINT_TEMPLATE' , '/templates/print/' , true); - if(is_file($this->config->item('usertemplaterootdir').'/'.$template.'/print_survey.pstpl')) + if(is_file(Yii::app()->getConfig('usertemplaterootdir').'/'.$template.'/print_survey.pstpl')) { - define('PRINT_TEMPLATE_DIR' , $this->config->item('usertemplaterootdir').'/'.$template.'/' , true); - define('PRINT_TEMPLATE_URL' , $this->config->item('usertemplaterooturl').'/'.$template.'/' , true); + define('PRINT_TEMPLATE_DIR' , Yii::app()->getConfig('usertemplaterootdir').'/'.$template.'/' , true); + define('PRINT_TEMPLATE_URL' , Yii::app()->getConfig('usertemplaterooturl').'/'.$template.'/' , true); } else { - define('PRINT_TEMPLATE_DIR' , $this->config->item('standardtemplaterootdir').'/default/' , true); - define('PRINT_TEMPLATE_URL' , $this->config->item('standardtemplaterooturl').'/default/' , true); + define('PRINT_TEMPLATE_DIR' , Yii::app()->getConfig('standardtemplaterootdir').'/default/' , true); + define('PRINT_TEMPLATE_URL' , Yii::app()->getConfig('standardtemplaterooturl').'/default/' , true); } $fieldmap=createFieldMap($surveyid); - $degquery = "SELECT * FROM ".$this->db->dbprefix("groups")." WHERE sid='{$surveyid}' AND language='{$surveyprintlang}' ORDER BY ".$this->db->dbprefix("groups").".group_order"; - $degresult = db_execute_assoc($degquery); + $degquery = "SELECT * FROM {{groups}} WHERE sid='{$surveyid}' AND language='{$surveyprintlang}' ORDER BY {{groups}}.group_order"; + $degresult = Yii::app()->db->createCommand($degquery)->query(); if (!isset($surveyfaxto) || !$surveyfaxto and isset($surveyfaxnumber)) { @@ -124,12 +117,12 @@ function index($surveyid, $lang = null) } $pdf_form=''; - if($this->config->item('usepdfexport') == 1 && !in_array($surveyprintlang,$this->config->item('notsupportlanguages'))) + if(Yii::app()->getConfig('usepdfexport') == 1 && !in_array($surveyprintlang,Yii::app()->getConfig('notsupportlanguages'))) { $pdf_form = ' -
+ - +
'; @@ -138,7 +131,7 @@ function index($surveyid, $lang = null) $headelements = getPrintableHeader(); //if $showsgqacode is enabled at config.php show table name for reference - $showsgqacode = $this->config->item("showsgqacode"); + $showsgqacode = Yii::app()->getConfig("showsgqacode"); if(isset($showsgqacode) && $showsgqacode == true) { $surveyname = $surveyname."
[".$clang->gT('Database')." ".$clang->gT('table').": $surveytable]"; @@ -149,7 +142,7 @@ function index($surveyid, $lang = null) } $survey_output = array( - 'SITENAME' => $this->config->item("sitename") + 'SITENAME' => Yii::app()->getConfig("sitename") ,'SURVEYNAME' => $surveyname ,'SURVEYDESCRIPTION' => $surveydesc ,'WELCOME' => $welcome @@ -223,15 +216,15 @@ function index($surveyid, $lang = null) // ========================================================= // START doin the business: $pdfoutput = ''; - foreach ($degresult->result_array() as $degrow) + foreach ($degresult->readAll() as $degrow) { // --------------------------------------------------- // START doing groups - $deqquery = "SELECT * FROM ".$this->db->dbprefix("questions")." WHERE sid=$surveyid AND gid={$degrow['gid']} AND language='{$surveyprintlang}' AND parent_qid=0 AND TYPE<>'I' ORDER BY question_order"; - $deqresult = db_execute_assoc($deqquery); + $deqquery = "SELECT * FROM {{questions}} WHERE sid=$surveyid AND gid={$degrow['gid']} AND language='{$surveyprintlang}' AND parent_qid=0 AND TYPE<>'I' ORDER BY question_order"; + $deqresult = Yii::app()->db->createCommand($deqquery)->query(); $deqrows = array(); //Create an empty array in case FetchRow does not return any rows - foreach ($deqresult->result_array() as $deqrow) {$deqrows[] = $deqrow;} // Get table output into array + foreach ($deqresult->readAll() as $deqrow) {$deqrows[] = $deqrow;} // Get table output into array // Perform a case insensitive natural sort on group name then question title of a multidimensional array usort($deqrows, 'GroupOrderThenQuestionOrder'); @@ -286,13 +279,13 @@ function index($surveyid, $lang = null) $s=0; // TMSW Conditions->Relevance: show relevance instead of this whole section to create $explanation - $scenarioquery="SELECT DISTINCT ".$this->db->dbprefix("conditions").".scenario FROM ".$this->db->dbprefix("conditions")." WHERE ".$this->db->dbprefix("conditions").".qid={$deqrow['qid']} ORDER BY scenario"; - $scenarioresult=db_execute_assoc($scenarioquery); + $scenarioquery="SELECT DISTINCT {{conditions}}.scenario FROM {{conditions}} WHERE {{conditions}}.qid={$deqrow['qid']} ORDER BY scenario"; + $scenarioresult=Yii::app()->db->createCommand($scenarioquery)->query(); //Loop through distinct scenarios, thus grouping them together. - foreach ($scenarioresult->result_array() as $scenariorow) + foreach ($scenarioresult->readAll() as $scenariorow) { - if($s == 0 && $scenarioresult->num_rows() > 1) + if($s == 0 && $scenarioresult->getRowCount() > 1) { $explanation .= '

'.self::_try_debug(__LINE__)." -------- Scenario {$scenariorow['scenario']} --------

\n\n"; } @@ -303,17 +296,17 @@ function index($surveyid, $lang = null) $x=0; $distinctquery="SELECT cqid, method, cfieldname, value - FROM ".$this->db->dbprefix("conditions")." - WHERE ".$this->db->dbprefix("conditions").".qid={$deqrow['qid']} - AND ".$this->db->dbprefix("conditions").".scenario={$scenariorow['scenario']} + FROM {{conditions}} + WHERE {{conditions}}.qid={$deqrow['qid']} + AND {{conditions}}.scenario={$scenariorow['scenario']} group by cqid, method ORDER BY cqid"; - $distinctresult=db_execute_assoc($distinctquery); + $distinctresult=Yii::app()->db->createCommand($distinctquery)->query(); //Loop through each condition for a particular scenario. - foreach ($distinctresult->result_array() as $distinctrow) + foreach ($distinctresult->readAll() as $distinctrow) { - $subquery='select title, question from '.$this->db->dbprefix("questions")." where qid={$distinctrow['cqid']} AND parent_qid=0 AND language='{$surveyprintlang}'"; - $subresult=db_execute_assoc($subquery)->row_array(); + $subquery="select title, question from {{questions}} where qid={$distinctrow['cqid']} AND parent_qid=0 AND language='{$surveyprintlang}'"; + $subresult=Yii::app()->db->createCommand($subquery)->query()->read(); if($x > 0) { @@ -400,15 +393,15 @@ function index($surveyid, $lang = null) $conquery="SELECT cid, cqid, q.title,\n" ."q.question, value, q.type, cfieldname\n" - ."FROM ".$this->db->dbprefix("conditions")." c, ".$this->db->dbprefix("questions")." q\n" + ."FROM {{conditions}} c, {{questions}} q\n" ."WHERE c.cqid=q.qid\n" ."AND c.cqid={$distinctrow['cqid']}\n" ."AND c.qid={$deqrow['qid']} \n" ."AND c.scenario={$scenariorow['scenario']} \n" ."AND language='{$surveyprintlang}'"; - $conresult=db_execute_assoc($conquery) or safe_die("$conquery
".htmlspecialchars($connect->ErrorMsg())); + $conresult=Yii::app()->db->createCommand($conquery)->query(); $conditions=array(); - foreach ($conresult->result_array() as $conrow) + foreach ($conresult->readAll() as $conrow) { $postans=""; @@ -454,11 +447,11 @@ function index($surveyid, $lang = null) $labelIndex=preg_match("/^[^#]+#([01]{1})$/",$conrow['cfieldname']); if ($labelIndex == 0) { // TIBO - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")."\n" + $fquery = "SELECT * FROM {{answers}}\n" . "WHERE qid='{$conrow['cqid']}'\n" . "AND code='{$conrow['value']}' and scale_id=0 AND language='{$surveyprintlang}'"; - $fresult=db_execute_assoc($fquery) or safe_die("$fquery
".htmlspecialchars($connect->ErrorMsg())); - foreach($fresult->result_array() as $frow) + $fresult=Yii::app()->db->createCommand($fquery)->query(); + foreach($fresult->readAll() as $frow) { $postans=$frow['answer']; $conditions[]=$frow['answer']; @@ -466,11 +459,11 @@ function index($surveyid, $lang = null) } elseif ($labelIndex == 1) { - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")."\n" + $fquery = "SELECT * FROM {{answers}}\n" . "WHERE qid='{$conrow['cqid']}'\n" . "AND code='{$conrow['value']}' and scale_id=1 AND language='{$surveyprintlang}'"; - $fresult=db_execute_assoc($fquery) or safe_die("$fquery
".htmlspecialchars($connect->ErrorMsg())); - foreach($fresult->result_array() as $frow) + $fresult=Yii::app()->db->createCommand($fquery)->query(); + foreach($fresult->readAll() as $frow) { $postans=$frow['answer']; $conditions[]=$frow['answer']; @@ -481,9 +474,9 @@ function index($surveyid, $lang = null) case "!": case "O": case "R": - $ansquery="SELECT answer FROM ".$this->db->dbprefix("answers")." WHERE qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$surveyprintlang}'"; - $ansresult=db_execute_assoc($ansquery); - foreach ($ansresult->result_array () as $ansrow) + $ansquery="SELECT answer FROM {{answers}} WHERE qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$surveyprintlang}'"; + $ansresult=Yii::app()->db->createCommand($ansquery)->query(); + foreach ($ansresult->readAll() as $ansrow) { $conditions[]=$ansrow['answer']; } @@ -494,9 +487,9 @@ function index($surveyid, $lang = null) break; case "M": case "P": - $ansquery="SELECT question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='{$conrow['cqid']}' AND title='{$conrow['value']}' AND language='{$surveyprintlang}'"; - $ansresult=db_execute_assoc($ansquery); - foreach ($ansresult->result_array () as $ansrow) + $ansquery="SELECT question FROM {{questions}} WHERE parent_qid='{$conrow['cqid']}' AND title='{$conrow['value']}' AND language='{$surveyprintlang}'"; + $ansresult=Yii::app()->db->createCommand($ansquery)->query(); + foreach ($ansresult->readAll() as $ansrow) { $conditions[]=$ansrow['question']; } @@ -506,11 +499,11 @@ function index($surveyid, $lang = null) case "H": default: $value=substr($conrow['cfieldname'], strpos($conrow['cfieldname'], "X".$conrow['cqid'])+strlen("X".$conrow['cqid']), strlen($conrow['cfieldname'])); - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")."\n" + $fquery = "SELECT * FROM {{answers}}\n" . "WHERE qid='{$conrow['cqid']}'\n" . "AND code='{$conrow['value']}' AND language='{$surveyprintlang}'"; - $fresult=db_execute_assoc($fquery) or safe_die("$fquery
".htmlspecialchars($connect->ErrorMsg())); - foreach ($fresult->result_array () as $frow) + $fresult=Yii::app()->db->createCommand($fquery)->query(); + foreach ($fresult->readAll() as $frow) { $postans=$frow['answer']; $conditions[]=$frow['answer']; @@ -530,10 +523,10 @@ function index($surveyid, $lang = null) case "H": case "K": $thiscquestion=$fieldmap[$conrow['cfieldname']]; - $ansquery="SELECT question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'"; + $ansquery="SELECT question FROM {{questions}} WHERE parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'"; //$ansquery="SELECT question FROM ".$this->db->dbprefix("questions")." WHERE qid='{$conrow['cqid']}' AND language='{$surveyprintlang}'"; - $ansresult=db_execute_assoc($ansquery); - foreach ($ansresult->result_array () as $ansrow) + $ansresult=Yii::app()->db->createCommand($ansquery)->query(); + foreach ($ansresult->readAll() as $ansrow) { $answer_section=" (".$ansrow['question'].")"; } @@ -542,9 +535,9 @@ function index($surveyid, $lang = null) case "1": // dual: (Label 1), (Label 2) $labelIndex=substr($conrow['cfieldname'],-1); $thiscquestion=$fieldmap[$conrow['cfieldname']]; - $ansquery="SELECT question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'"; + $ansquery="SELECT question FROM {{questions}} WHERE parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'"; //$ansquery="SELECT question FROM ".$this->db->dbprefix("questions")." WHERE qid='{$conrow['cqid']}' AND language='{$surveyprintlang}'"; - $ansresult=db_execute_assoc($ansquery); + $ansresult=Yii::app()->db->createCommand($ansquery)->query(); $cqidattributes = getQuestionAttributeValues($conrow['cqid'], $conrow['type']); if ($labelIndex == 0) { @@ -562,7 +555,7 @@ function index($surveyid, $lang = null) $header = '2'; } } - foreach ($ansresult->result_array () as $ansrow) + foreach ($ansresult->readAll() as $ansrow) { $answer_section=" (".$ansrow['question']." ".sprintf($clang->gT("Label %s"),$header).")"; } @@ -570,15 +563,15 @@ function index($surveyid, $lang = null) case ":": case ";": //multi flexi: ( answer [label] ) $thiscquestion=$fieldmap[$conrow['cfieldname']]; - $ansquery="SELECT question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'"; - $ansresult=db_execute_assoc($ansquery); - foreach ($ansresult->result_array () as $ansrow) + $ansquery="SELECT question FROM {{questions}} WHERE parent_qid='{$conrow['cqid']}' AND title='{$thiscquestion['aid']}' AND language='{$surveyprintlang}'"; + $ansresult=Yii::app()->db->createCommand($ansquery)->query(); + foreach ($ansresult->readAll() as $ansrow) { - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")."\n" + $fquery = "SELECT * FROM {{answers}}\n" . "WHERE qid='{$conrow['cqid']}'\n" . "AND code='{$conrow['value']}' AND language='{$surveyprintlang}'"; - $fresult=db_execute_assoc($fquery) or safe_die("$fquery
".htmlspecialchars($connect->ErrorMsg())); - foreach ($fresult->result_array () as $frow) + $fresult=Yii::app()->db->createCommand($fquery)->query(); + foreach ($fresult->readAll() as $frow) { //$conditions[]=$frow['title']; $answer_section=" (".$ansrow['question']."[".$frow['answer']."])"; @@ -646,7 +639,7 @@ function index($surveyid, $lang = null) $question = array( 'QUESTION_NUMBER' => $total_questions // content of the question code field ,'QUESTION_CODE' => $deqrow['title'] - ,'QUESTION_TEXT' => preg_replace('/(?:
|<\/(?:p|h[1-6])>)$/is' , '' , tokenReplace($deqrow['question'])) // content of the question field + ,'QUESTION_TEXT' => preg_replace('/(?:
|<\/(?:p|h[1-6])>)$/is' , '' , $deqrow['question']) // content of the question field ,'QUESTION_SCENARIO' => $explanation // if there are conditions on a question, list the conditions. ,'QUESTION_MANDATORY' => '' // translated 'mandatory' identifier ,'QUESTION_ID' => $deqrow['qid'] // id to be added to wrapping question div @@ -759,9 +752,9 @@ function index($surveyid, $lang = null) $question['QUESTION_TYPE_HELP'] .= self::_array_filter_help($qidattributes, $surveyprintlang, $surveyid); if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"));} - $deaquery = "SELECT * FROM ".$this->db->dbprefix("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; - $dearesult = db_execute_assoc($deaquery); - $deacount=$dearesult->num_rows(); + $deaquery = "SELECT * FROM {{answers}} WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; + $dearesult = Yii::app()->db->createCommand($deaquery)->query(); + $deacount=$dearesult->getRowCount(); if ($deqrow['other'] == "Y") {$deacount++;} $wrapper = setup_columns(0, $deacount); @@ -771,7 +764,7 @@ function index($surveyid, $lang = null) $rowcounter = 0; $colcounter = 1; - foreach ($dearesult->result_array () as $dearow) + foreach ($dearesult->readAll() as $dearow) { if (isset($optCategorySeparator)) { @@ -824,10 +817,10 @@ function index($surveyid, $lang = null) case "O": //LIST WITH COMMENT $question['QUESTION_TYPE_HELP'] = $clang->gT("Please choose *only one* of the following:"); if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"),"U");} - $deaquery = "SELECT * FROM ".$this->db->dbprefix("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer "; - $dearesult = db_execute_assoc($deaquery); + $deaquery = "SELECT * FROM {{answers}} WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer "; + $dearesult = Yii::app()->db->createCommand($deaquery)->query(); $question['ANSWER'] = "\t