From 7fe909c77a22f7bc3f4451680e7a99296a92689c Mon Sep 17 00:00:00 2001 From: Pieter Jan Speelmans Date: Sun, 27 Nov 2011 13:18:08 +0000 Subject: [PATCH] Updated feature: Port the functionality 'Statistics' to the Yii PHP framework - GCI2011 by Shitiz Garg git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@11514 b72ed6b6-b9f8-46b5-92b4-906544132732 --- application/controllers/AdminController.php | 4 +- application/controllers/admin/statistics.php | 1051 +++++++++-------- application/core/LSYii_Application.php | 14 + .../helpers/admin/statistics_helper.php | 375 +++--- application/helpers/common_helper.php | 224 ++-- .../helpers/expressions/em_manager_helper.php | 29 +- .../survey/subview/tabPresentation_view.php | 29 +- 7 files changed, 899 insertions(+), 827 deletions(-) diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php index 5099eac0adc..07651450555 100644 --- a/application/controllers/AdminController.php +++ b/application/controllers/AdminController.php @@ -119,7 +119,9 @@ public function actions() 'tokens' => 'application.controllers.admin.tokens', 'surveypermission' => 'application.controllers.admin.surveypermission', 'questiongroup' => 'application.controllers.admin.questiongroup', - 'dumpdb' => 'application.controllers.admin.dumpdb', + 'question' => 'application.controllers.admin.question', + 'database' => 'application.controllers.admin.database', + 'statistics' => 'application.controllers.admin.statistics', ); } diff --git a/application/controllers/admin/statistics.php b/application/controllers/admin/statistics.php index 6a8e1dbfa33..9fec0f6330e 100644 --- a/application/controllers/admin/statistics.php +++ b/application/controllers/admin/statistics.php @@ -9,9 +9,9 @@ * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See COPYRIGHT.php for copyright notices and details. - * + * * $Id: statistics.php 11221 2011-10-19 20:47:40Z tmswhite $ - * + * */ /** @@ -22,41 +22,23 @@ * @package LimeSurvey * @subpackage Backend */ -class statistics extends Survey_Common_Controller { - +class statistics extends Survey_Common_Action { + /** * Constructor */ - function __construct() - { - parent::__construct(); - } - - public function _remap($method, $params = array()) - { - array_unshift($params, $method); - if ($method == "graph") - { - return call_user_func_array(array($this, "graph"), $params); - } - else - { - return call_user_func_array(array($this, "action"), $params); - } - } - - function action($surveyid, $subaction = null) + public function run($surveyid, $subaction = null) { $surveyid = sanitize_int($surveyid); //TODO: Convert question types to views - $clang = $this->limesurvey_lang; - $this->load->helper("database"); - $this->load->helper("surveytranslator"); - $this->load->helper("admin/statistics"); - $this->load->model('Surveys_dynamic_model'); - $dbprefix = $this->db->dbprefix; - $_POST = $this->input->post(); - $imageurl = $this->config->item("umageurl"); + + $clang = $this->controller->lang; + + Yii::app()->loadHelper("surveytranslator"); + + $imageurl = Yii::app()->getConfig("imageurl"); + + /* * We need this later: * 1 - Array Dual Scale @@ -87,48 +69,48 @@ function action($surveyid, $subaction = null) * : - Array (Flexible Labels) multiple drop down * ; - Array (Flexible Labels) multiple texts * | - File Upload - - + + Debugging help: echo ''; */ - + //split up results to extend statistics -> NOT WORKING YET! DO NOT ENABLE THIS! $showcombinedresults = 0; - + /* * this variable is used in the function shortencode() which cuts off a question/answer title * after $maxchars and shows the rest as tooltip */ $maxchars = 50; - - - + + + //don't call this script directly! //if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');} - + //some includes, the progressbar is used to show a progressbar while generating the graphs //include_once("login_check.php"); //require_once('classes/core/class.progressbar.php'); - + //we collect all the output within this variable $statisticsoutput =''; - + //output for chosing questions to cross query $cr_statisticsoutput = ''; - + // This gets all the 'to be shown questions' from the POST and puts these into an array $summary=returnglobal('summary'); $statlang=returnglobal('statlang'); - + //if $summary isn't an array we create one if (isset($summary) && !is_array($summary)) { $summary = explode("+", $summary); } - + //no survey ID? -> come and get one if (!isset($surveyid)) {$surveyid=returnglobal('sid');} - + //still no survey ID -> error if (!$surveyid) { @@ -136,11 +118,34 @@ function action($surveyid, $subaction = null) $statisticsoutput .= "
You have not selected a survey!
"; exit; } - + // Set language for questions and answers to base language of this survey $language = GetBaseLanguageFromSurveyID($surveyid); - - + + $chartfontfile = Yii::app()->getConfig("chartfontfile"); + //pick the best font file if font setting is 'auto' + if ($chartfontfile=='auto') + { + $chartfontfile='vera.ttf'; + if ( $language=='ar') + { + $chartfontfile='KacstOffice.ttf'; + } + elseif ($language=='fa' ) + { + $chartfontfile='KacstFarsi.ttf'; + } + elseif ($language=='el' ) + { + $chartfontfile='DejaVuLGCSans.ttf'; + } + elseif ($language=='zh-Hant-HK' || $language=='zh-Hant-TW' || $language=='zh-Hans') + { + $chartfontfile='fireflysung.ttf'; + } + + } + //$statisticsoutput .= " //"; - + //hide/show the filter //filtersettings by default aren't shown when showing the results //$statisticsoutput .= ''; - self::_js_admin_includes(base_url()."scripts/admin/statistics.js"); - self::_getAdminHeader(); - - //headline with all icons for available statistic options - //Get the menubar - self::_browsemenubar($surveyid, $clang->gT("Quick statistics")); - - + $this->controller->_js_admin_includes(Yii::app()->baseUrl."/scripts/admin/statistics.js"); + + if (empty($_POST['outputtype']) || $_POST['outputtype'] == 'html') + { + $this->controller->_getAdminHeader(); + + //headline with all icons for available statistic options + //Get the menubar + $this->_browsemenubar($surveyid, $clang->gT("Quick statistics")); + } + //we need a form which can pass the selected data later - $statisticsoutput = "
\n"; - + $statisticsoutput = "\n"; + //Select public language file - $query = "SELECT datestamp FROM {$dbprefix}surveys WHERE sid=$surveyid"; - $result = db_execute_assoc($query) or safe_die("Error selecting language:
".$query."
".$connect->ErrorMsg()); - + $query = "SELECT datestamp FROM {{surveys}} WHERE sid=$surveyid"; + $result = Yii::app()->db->createCommand($query)->query(); + /* * check if there is a datestamp available for this survey * yes -> $datestamp="Y" * no -> $datestamp="N" */ - $row=$result->row_array(); $datestamp=$row['datestamp']; - - - + $row=$result->read(); $datestamp=$row['datestamp']; + + + // 1: Get list of questions from survey - + /* * We want to have the following data * a) "questions" -> all table namens, e.g. @@ -212,21 +220,22 @@ function action($surveyid, $subaction = null) * b) "groups" -> group_name + group_order * */ $query = "SELECT questions.*, groups.group_name, groups.group_order\n" - ." FROM ".$this->db->dbprefix("questions") ." as questions, ".$this->db->dbprefix("groups")." as groups\n" + ." FROM {{questions}} as questions, {{groups}} as groups\n" ." WHERE groups.gid=questions.gid\n" ." AND groups.language='".$language."'\n" ." AND questions.language='".$language."'\n" ." AND questions.parent_qid=0\n" ." AND questions.sid=$surveyid"; - $result = db_execute_assoc($query) or safe_die("Couldn't do it!
$query
".$connect->ErrorMsg()); - + $result = Yii::app()->db->createCommand($query)->query(); + //store all the data in $rows - $rows = $result->result_array(); - + $rows = $result->readAll(); + //SORT IN NATURAL ORDER! usort($rows, 'GroupOrderThenQuestionOrder'); - + //put the question information into the filter array + $filters = array(); foreach ($rows as $row) { //store some column names in $filters array @@ -237,13 +246,13 @@ function action($surveyid, $subaction = null) $row['group_name'], FlattenText($row['question'])); } - + //var_dump($filters); // SHOW ID FIELD - + $statisticsoutput .= "
".$clang->gT("General filters")."
"; - - + + $grapherror=''; if (!function_exists("gd_info")) { $grapherror.='
'.$clang->gT('You do not have the GD Library installed. Showing charts requires the GD library to function properly.'); @@ -257,8 +266,8 @@ function action($surveyid, $subaction = null) { unset($_POST['usegraph']); } - - + + //pre-selection of filter forms if (incompleteAnsFilterstate() == "filter") { @@ -284,12 +293,12 @@ function action($surveyid, $subaction = null) ."\n" ."\n" ."\n" - + ."
  • session->userdata('adminlang') == $survlang) + if (Yii::app()->session['adminlang'] == $survlang) { $language_options .= "selected=\"selected\" " ; } $language_options .= ">".getLanguageNameFromCode($survlang,true)."\n"; } - + $statisticsoutput .="
  • " . "
  • \n"; - + $statisticsoutput.="\n\n"; - + $statisticsoutput .= "
    ".$clang->gT("Response ID")."
    • " ."\n" ."
    \n"; $statisticsoutput .= ""; $statisticsoutput .= ""; - - + + //if the survey contains timestamps you can filter by timestamp, too if (isset($datestamp) && $datestamp == "Y") { - - + + $statisticsoutput .= "

    " ."\n" - ."\n" + ."controller->createUrl("admin/statistics/surveyid/$surveyid")."', '_top')\" />\n" ."

    "; - + //second row below options -> filter settings headline $statisticsoutput.="
    " ."" .$clang->gT("Response filters") ."
    \n"; - + $filterchoice_state=returnglobal('filterchoice_state'); $statisticsoutput.="\n"; - + $statisticsoutput .="" - + //use current groupname and groupid as heading ."$flt[4] (".$clang->gT("Question group")." $flt[1])\n\t\t" ."\n"; } - + //complete output $statisticsoutput .= "\n\t\t\t\t\n"; - - - - - - + + + + + + //add last lines to filter forms $statisticsoutput .= "\t\t\t
    \n" ."
    \n"; - + //counter which is used to adapt layout depending on counter # $counter=0; } - + //we don't want more than 4 questions in a row //and we need a new row after each multiple/array question if (isset($counter) && $counter == 4 || @@ -453,7 +462,7 @@ function action($surveyid, $subaction = null) { $statisticsoutput .= "\t\t\t\t\n\t\t\t\t"; $counter=0; } - + /* * remember: $flt is structured like this * ['qid'], @@ -465,13 +474,13 @@ function action($surveyid, $subaction = null) ['lid'], ['lid1']); */ - + //SGQ identifier $myfield = "{$surveyid}X{$flt[1]}X{$flt[0]}"; - + //full question title $niceqtext = FlattenText($flt[5]); - + /* * Check question type: This question types will be used (all others are separated in the if clause) * 5 - 5 Point Choice @@ -489,20 +498,20 @@ function action($surveyid, $subaction = null) if ($flt[2]=='M' || $flt[2]=='P' || $flt[2]=='N' || $flt[2]=='L' || $flt[2]=='5' || $flt[2]=='G' || $flt[2]=='I' || $flt[2]=='O' || $flt[2]=='Y' || $flt[2]=='!') //Have to make an exception for these types! { - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\t\n"; - + //get answers - $query = "SELECT title as code, question as answer FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language = '{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); - + $query = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid='$flt[0]' AND language = '{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); + //counter is used for layout $counter2=0; - + //go through all the (multiple) answers - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { - $row = array_values($row); + $row = array_values($row); /* * filter form for numerical input * - checkbox @@ -569,66 +578,66 @@ function action($surveyid, $subaction = null) $myfield2="K{$myfield}".$row[0]."G"; $myfield3="K{$myfield}".$row[0]."L"; if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} - + //start new TD $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; - + //get subqestions - $query = "SELECT title as code, question as answer FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); $counter2=0; - + //loop through all answers - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row = array_values($row); //collecting data for output, for details see above (question type "N") - + //we have one input field for each answer $myfield2 = "Q".$myfield."$row[0]"; if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} - + $statisticsoutput .= "\t\t\t\t\n"; $counter2++; @@ -644,106 +653,106 @@ function action($surveyid, $subaction = null) $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter=0; break; - - - + + + /* * all "free text" types (T, U, S) get the same prefix ("T") */ case "T": // Long free text case "U": // Huge free text - + $myfield2="T$myfield"; $statisticsoutput .= "\t\t\t\t\n"; break; - - - + + + case "S": // Short free text - + $myfield2="T$myfield"; $statisticsoutput .= "\t\t\t\t\n"; break; - - - + + + case "N": // Numerical - + //textfields for greater and less than X $myfield2="{$myfield}G"; $myfield3="{$myfield}L"; $statisticsoutput .= "\t\t\t\t\t".$clang->gT("Number greater than").":
    \n" ."\t\t\t\t\t
    \n" ."\t\t\t\t\t".$clang->gT("Number less than").":
    \n" ."\t\t\t\t\t
    \n"; - + //put field names into array - + break; - - + + case "|": // File Upload - + // Number of files uploaded for greater and less than X $myfield2 = "{$myfield}G"; $myfield3 = "{$myfield}L"; $statisticsoutput .= "\t\t\t\t\t".$clang->gT("Number of files greater than").":
    \n" ."\t\t\t\t\t
    \n" ."\t\t\t\t\t".$clang->gT("Number of files less than").":
    \n" ."\t\t\t\t\t
    \n"; - + //put field names into array - + break; - - + + /* * DON'T show any statistics for date questions * because there aren't any statistics implemented yet! @@ -754,7 +763,7 @@ function action($surveyid, $subaction = null) * feature request #2620 */ case "D": // Date - + /* * - input name * - date equals @@ -766,196 +775,196 @@ function action($surveyid, $subaction = null) $myfield4=$myfield2."less"; $myfield5=$myfield2."more"; $statisticsoutput .= "\t\t\t\t\n"; break; - - - + + + case "Y": // Yes\No $statisticsoutput .= "\t\t\t\t\t\n" ."\t\t\t\t\t\n"; break; - - - + + + case "I": // Language $survlangs = GetAdditionalLanguagesFromSurveyID($surveyid); $survlangs[] = GetBaseLanguageFromSurveyID($surveyid); foreach ($survlangs as $availlang) { $statisticsoutput .= "\t\t\t\t\t\n\t\t\t\t\n"; - + //get answers - $query = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); $counter2=0; - + //check all the results - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row = array_values($row); $myfield2 = $myfield.$row[0]; $statisticsoutput .= "\n"; - + if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} - + $statisticsoutput .= "\t\t\t\t\n"; $counter2++; } - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter=0; break; - - - + + + case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; - + //get answers - $query = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); $counter2=0; - + //loop answers - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row=array_values($row); $myfield2 = $myfield . "$row[0]"; $statisticsoutput .= "\n"; - + if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} - + $statisticsoutput .= "\t\t\t\t\n"; $counter2++; - + //add to array } - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter=0; break; - - - + + + //similiar to the above one case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; - $query = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); $counter2=0; - - foreach($result->result_array() as $row) + + foreach($result->readAll() as $row) { $row=array_values($row); $myfield2 = $myfield . "$row[0]"; $statisticsoutput .= "\n"; - + if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0;} - + $statisticsoutput .= "\t\t\t\t\n"; $counter2++; } - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter=0; break; - + case ";": //ARRAY (Multi Flex) (Text) $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; - $query = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' AND scale_id=0 ORDER BY question_order"; - $result = db_execute_assoc($query) or die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' AND scale_id=0 ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); $counter2=0; - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row = array_values($row); - $fquery = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' AND scale_id=1 ORDER BY question_order"; - $fresult = db_execute_assoc($fquery); - foreach($fresult->result_array() as $frow) + $fquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' AND scale_id=1 ORDER BY question_order"; + $fresult = Yii::app()->db->createCommand($fquery)->query(); + foreach($fresult->readAll() as $frow) { $myfield2 = "T".$myfield . $row[0] . "_" . $frow['title']; $statisticsoutput .= "\n"; - + if ($counter2 == 4) { $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0; } - + $statisticsoutput .= "\t\t\t\t\n"; $counter2++; - + //add fields to main array } - + //$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; - + //get some answers - $query = "SELECT code, answer FROM ".$this->db->dbprefix("answers")." WHERE qid='$flt[0]' AND language='{$language}' ORDER BY sortorder, answer"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); - + $query = "SELECT code, answer FROM {{answers}} WHERE qid='$flt[0]' AND language='{$language}' ORDER BY sortorder, answer"; + $result = Yii::app()->db->createCommand($query)->query(); + //get number of answers - $count = $result->num_rows(); - + $count = $result->getRowCount(); + //lets put the answer code and text into the answers array - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $answers[]=array($row['code'], $row['answer']); } - + $counter2=0; - + //loop through all answers. if there are 3 items to rate there will be 3 statistics for ($i=1; $i<=$count; $i++) { //adjust layout depending on counter if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter=0;} - + //myfield is the SGQ identifier //myfield2 is just used as comment in HTML like "R40X34X1721-1" $myfield2 = "R" . $myfield . $i . "-" . strlen($i); $myfield3 = $myfield . $i; $statisticsoutput .= "\n" ."\t\t\t\t"; break; - + case "1": // MULTI SCALE $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; - + //special dual scale counter $counter2=0; - + //get answers - $query = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); - + $query = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); + //loop through answers - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row=array_values($row); - + //----------------- LABEL 1 --------------------- //myfield2 = answer code. $myfield2 = $myfield . "$row[0]#0"; - + //3 lines of debugging output $statisticsoutput .= "\n"; - + //some layout adaptions -> new line after 4 entries if ($counter2 == 4) { $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0; } - + //output checkbox and question/label text $statisticsoutput .= "\t\t\t\t\n"; $counter2++; - - - - + + + + //----------------- LABEL 2 --------------------- - + //myfield2 = answer code $myfield2 = $myfield . "$row[0]#1"; - + //3 lines of debugging output $statisticsoutput .= "\n"; - + //some layout adaptions -> new line after 4 entries if ($counter2 == 4) { $statisticsoutput .= "\t\t\t\t\n\t\t\t\t\n"; $counter2=0; } - + //output checkbox and question/label text $statisticsoutput .= "\t\t\t\t\n"; $counter2++; - + } //end WHILE -> loop through all answers - + $statisticsoutput .= "\t\t\t\t\n"; break; - - + + /* * This question types use the default settings: * L - List (Radio) @@ -1572,74 +1581,74 @@ function action($surveyid, $subaction = null) ! - List (Dropdown) */ default: - + //get answers - $query = "SELECT code, answer FROM ".$this->db->dbprefix("answers")." WHERE qid='$flt[0]' AND language='{$language}' ORDER BY sortorder, answer"; - $result = db_execute_assoc($query) or safe_die("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); - + $query = "SELECT code, answer FROM {{answers}} WHERE qid='$flt[0]' AND language='{$language}' ORDER BY sortorder, answer"; + $result = Yii::app()->db->createCommand($query)->query(); + //loop through answers - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row=array_values($row); $statisticsoutput .= "\t\t\t\t\t\t\n\t\t\t
    "; - + //Multiple choice: if ($flt[2] == "M") {$myfield = "M$myfield";} if ($flt[2] == "P") {$myfield = "P$myfield";} - + // File Upload will need special filters in future, hence the special treatment if ($flt[2] == "|") {$myfield = "|$myfield";} - + //numerical input will get special treatment (arihtmetic mean, standard derivation, ...) if ($flt[2] == "N") {$myfield = "N$myfield";} $statisticsoutput .= "
    \n"; - + //numerical question type -> add some HTML to the output //if ($flt[2] == "N") {$statisticsoutput .= "";} //removed to correct font error if ($flt[2] != "N" && $flt[2] != "|") {$statisticsoutput .= "\t\t\t\t
    "; - + //checkbox $statisticsoutput .= " do we want to pre-check the checkbox? if (isset($summary) && (array_search("K{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}", $summary) !== FALSE)) {$statisticsoutput .= " checked='checked'";} $statisticsoutput .= " /> "; - + //show speaker $statisticsoutput .= self::_showSpeaker($flt[3]." - ".FlattenText($row[1],true))."
    \n"; - + //input fields $statisticsoutput .= "\t\t\t\t\t".$clang->gT("Number greater than").":
    \n" ."\t\t\t\t\t
    \n" ."\t\t\t\t\t".$clang->gT("Number less than").":
    \n" ."\t\t\t\t\t
    \n"; - + //we added 1 form -> increase counter $counter2++; - + } break; - - - + + + case "Q": // Multiple Short Text - + //new section $statisticsoutput .= "\t\t\t\t
    "; $statisticsoutput .= "\n" @@ -636,7 +645,7 @@ function action($surveyid, $subaction = null) ."\t\t\t\t\t" ."\t\t\t\t
    \n"; $statisticsoutput .= "\t\t\t\t\t\n" ."\t\t\t\t\t".$clang->gT("Responses containing").":
    \n" ."\t\t\t\t\t\n" ."\t\t\t\t
    "; $statisticsoutput .= "\n" ."\t\t\t\t\t".$clang->gT("Responses containing").":
    \n" ."\t\t\t\t\t"; $statisticsoutput .= "\t\t\t\t
    "; - + $statisticsoutput .= "\n" - + ."\t\t\t\t\t".$clang->gT("Date (YYYY-MM-DD) equals").":
    \n" ."\t\t\t\t\t
    \n" ."\t\t\t\t\t  ".$clang->gT("Date is")." >=
    \n" ."\t\t\t\t\t
    " .$clang->gT("AND/OR Date is")." <=
    \n"; break; - - - + + + case "5": // 5 point choice - + //we need a list of 5 entries for ($i=1; $i<=5; $i++) { $statisticsoutput .= "\t\t\t\t\t\n"; $statisticsoutput .= "\t\t\t\t\t\n\t\t\t\t\n"; $statisticsoutput .= "\t\t\t\t
    " ."\n" ."\t\t\t\t
    "; //heading $statisticsoutput .= "\n" ."\t\t\t\t\n\t\t\t\t
    " ."
    \n" ."\t\t\t\t\n\t\t\t\t
    " ."
    \n" ."\t\t\t\t\n\t\t\t\t
    " ."
    \n"; - + /* * when hoovering the speaker symbol we show the whole question * @@ -1244,104 +1253,104 @@ function action($surveyid, $subaction = null) * - sortorder * - language */ - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")." WHERE qid={$flt[0]} AND language='{$language}' ORDER BY sortorder, code"; - $fresult = db_execute_assoc($fquery); - + $fquery = "SELECT * FROM {{answers}} WHERE qid={$flt[0]} AND language='{$language}' ORDER BY sortorder, code"; + $fresult = Yii::app()->db->createCommand($fquery)->query(); + //for debugging only: //$statisticsoutput .= $fquery; - + //creating form $statisticsoutput .= "\t\t\t\t\n\t\t\t\t
    \n"; $counter=0; break; - - - + + + case "R": //RANKING - + $statisticsoutput .= "\t\t\t\t
    " ."
    \n" ."\t\t\t\t
    "; $statisticsoutput .= "db->dbprefix("question_attributes")." WHERE qid={$flt[0]} AND attribute='dualscale_headerA'"; - $dshresult = db_execute_assoc($dshquery) or safe_die ("Couldn't get dualscale header!
    $dshquery
    ".$connect->ErrorMsg()); - + $dshquery = "SELECT value FROM {{question_attributes}} WHERE qid={$flt[0]} AND attribute='dualscale_headerA'"; + $dshresult = Yii::app()->db->createCommand($dshquery)->query(); + //get header - foreach($dshresult->result_array() as $dshrow) + foreach($dshresult->readAll() as $dshrow) { $dshrow=array_values($dshrow); $dualscaleheadera = $dshrow[0]; } - + if(isset($dualscaleheadera) && $dualscaleheadera != "") { $labeltitle = $dualscaleheadera; @@ -1416,11 +1425,11 @@ function action($surveyid, $subaction = null) { $labeltitle=''; } - + $statisticsoutput .= " /> " .self::_showSpeaker($niceqtext." [".str_replace("'", "`", $row[1])."] - ".$clang->gT("Label").": ".$labeltitle) ."
    \n"; - + /* get labels * table "labels" contains * - lid @@ -1429,72 +1438,72 @@ function action($surveyid, $subaction = null) * - sortorder * - language */ - - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")." WHERE qid={$flt[0]} AND language='{$language}' and scale_id=0 ORDER BY sortorder, code"; - $fresult = db_execute_assoc($fquery); - + + $fquery = "SELECT * FROM {{answers}} WHERE qid={$flt[0]} AND language='{$language}' and scale_id=0 ORDER BY sortorder, code"; + $fresult = Yii::app()->db->createCommand($fquery)->query(); + //this is for debugging only //$statisticsoutput .= $fquery; - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t
    "; $statisticsoutput .= "db->dbprefix("question_attributes")." WHERE qid={$flt[0]} AND attribute='dualscale_headerB'"; - $dshresult2 = db_execute_assoc($dshquery2) or safe_die ("Couldn't get dualscale header!
    $dshquery2
    ".$connect->ErrorMsg()); - + $dshquery2 = "SELECT value FROM {{question_attributes}} WHERE qid={$flt[0]} AND attribute='dualscale_headerB'"; + $dshresult2 = Yii::app()->db->createCommand($dshquery2)->query(); + //get header - foreach($dshresult2->result_array() as $dshrow2) + foreach($dshresult2->readAll() as $dshrow2) { $dshrow2=array_values($dshrow2); $dualscaleheaderb = $dshrow2[0]; } - + if(isset($dualscaleheaderb) && $dualscaleheaderb != "") { $labeltitle2 = $dualscaleheaderb; @@ -1502,68 +1511,68 @@ function action($surveyid, $subaction = null) else { //get label text - + $labeltitle2 = ''; } - + $statisticsoutput .= " /> " .self::_showSpeaker($niceqtext." [".str_replace("'", "`", $row[1])."] - ".$clang->gT("Label").": ".$labeltitle2) ."
    \n"; - - $fquery = "SELECT * FROM ".$this->db->dbprefix("answers")." WHERE qid={$flt[0]} AND language='{$language}' and scale_id=1 ORDER BY sortorder, code"; - $fresult = db_execute_assoc($fquery); - + + $fquery = "SELECT * FROM {{answers}} WHERE qid={$flt[0]} AND language='{$language}' and scale_id=1 ORDER BY sortorder, code"; + $fresult = Yii::app()->db->createCommand($fquery)->query(); + //this is for debugging only //$statisticsoutput .= $fquery; - + $statisticsoutput .= "\t\t\t\t\n\t\t\t\t
    \n"; - - + + $counter=0; break; - + case "P": //P - Multiple choice with comments case "M": //M - Multiple choice - + //get answers - $query = "SELECT title, question FROM ".$this->db->dbprefix("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; - $result = db_execute_assoc($query) or safe_die("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); - + $query = "SELECT title, question FROM {{questions}} WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order"; + $result = Yii::app()->db->createCommand($query)->query(); + //loop through answers - foreach($result->result_array() as $row) + foreach($result->readAll() as $row) { $row=array_values($row); $statisticsoutput .= "\t\t\t\t\t\t
    \n" ."\t\t\n"; - - + + //add line to separate the the filters from the other options $statisticsoutput .= ""; - + $statisticsoutput .= ""; - - - - + + + + //very last lines of output $statisticsoutput .= "\t\t

    \n" ."\t\t\t\n" - ."\t\t\t\n" + ."\t\t\tcontroller->createUrl("admin/statistics/surveyid/$surveyid")."', '_top')\" />\n" ."\t\t\n" ."\t\t\n" ."\t\t

    \n" ."\t

    \n"; - + // ----------------------------------- END FILTER FORM --------------------------------------- - - + + Yii::app()->loadHelper('admin/statistics'); //Show Summary results if (isset($summary) && $summary) { @@ -1653,7 +1662,7 @@ function action($surveyid, $subaction = null) } $outputType = $_POST['outputtype']; switch($outputType){ - + case 'html': $statisticsoutput .= generate_statistics($surveyid,$summary,$summary,$usegraph,$outputType,'DD',$statlang); break; @@ -1666,40 +1675,40 @@ function action($surveyid, $subaction = null) exit; break; default: - + break; - + } - - + + //print_r($summary); exit; - + } //end if -> show summary results - + $data['output'] = $statisticsoutput; - $this->load->view("admin/export/statistics_view",$data); - self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); + $this->controller->render("/admin/export/statistics_view",$data); + $this->controller->_getAdminFooter("http://docs.limesurvey.org", $clang->gT("LimeSurvey online manual")); } function _showSpeaker($hinttext) { global $clang, $imageurl, $maxchars; - $clang = $this->limesurvey_lang; - $imageurl = $this->config->item("imageurl"); + $clang = $this->controller->lang; + $imageurl = Yii::app()->getConfig("imageurl"); if(!isset($maxchars)) { $maxchars = 100; } $htmlhinttext=str_replace("'",''',$hinttext); //the string is already HTML except for single quotes so we just replace these only $jshinttext=javascript_escape($hinttext,true,true); - + if(strlen($hinttext) > ($maxchars)) { $shortstring = FlattenText($hinttext); - + $shortstring = htmlspecialchars(mb_strcut(html_entity_decode($shortstring,ENT_QUOTES,'UTF-8'), 0, $maxchars, 'UTF-8')); - + //output with hoover effect $reshtml= "gT("Question","js").": $jshinttext')\">" @@ -1713,15 +1722,15 @@ function _showSpeaker($hinttext) } return $reshtml; } - - + + function graph() { $this->load->model('Surveys_dynamic_model'); $this->load->model('Question_attributes_model'); - $this->load->helper('admin/statistics_helper'); + $this->load->helper('admin/statistics_helper'); $this->load->helper("surveytranslator"); - + // Initialise PCHART require_once(APPPATH.'/third_party/pchart/pchart/pChart.class'); require_once(APPPATH.'/third_party/pchart/pchart/pData.class'); @@ -1731,17 +1740,17 @@ function graph() $MyCache = new pCache($tempdir.'/'); $data['success'] = 1; - + if (isset($_POST['cmd']) || !isset($_POST['id'])) { list($qsid, $qgid, $qqid) = explode("X", substr($_POST['id'], 1), 3); $qtype = substr($_POST['id'], 0, 1); $aattr = getQuestionAttributeValues($qqid, substr($_POST['id'], 0, 1)); $field = substr($_POST['id'], 1); - + switch ($_POST['cmd']) { case 'showmap': - if (isset($aattr['location_mapservice'])) { - + if (isset($aattr['location_mapservice'])) { + $data['mapdata'] = array ( "coord" => getQuestionMapData($field, $qsid), "zoom" => $aattr['location_mapzoom'], @@ -1749,7 +1758,7 @@ function graph() "height" => $aattr['location_mapheight'] ); $this->Question_attributes_model->setAttribute($qqid, 'statistics_showmap', 1); - } else { + } else { $data['success'] = 0; } break; @@ -1757,12 +1766,12 @@ function graph() if (isset($aattr['location_mapservice'])) { $data['success'] = 1; $this->Question_attributes_model->setAttribute($qqid, 'statistics_showmap', 0); - } else { + } else { $data['success'] = 0; } break; case 'showgraph': - if (isset($aattr['location_mapservice'])) { + if (isset($aattr['location_mapservice'])) { $data['mapdata'] = array ( "coord" => getQuestionMapData($field, $qsid), "zoom" => $aattr['location_mapzoom'], @@ -1770,13 +1779,13 @@ function graph() "height" => $aattr['location_mapheight'] ); } - + $bChartType = $qtype != "M" && $qtype != "P" && $aattr["statistics_graphtype"] == "1"; - + $adata = $_SESSION['stats'][$_POST['id']]; $data['chartdata'] = createChart($qqid, $qsid, $bChartType, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache); - - + + $this->Question_attributes_model->setAttribute($qqid, 'statistics_showgraph', 1); break; case 'hidegraph': @@ -1786,33 +1795,33 @@ function graph() if ($qtype == "M" || $qtype == "P") { $data['success'] = 0; break; - } - + } + $this->Question_attributes_model->setAttribute($qqid, 'statistics_graphtype', 0); - + $adata = $_SESSION['stats'][$_POST['id']]; $data['chartdata'] = createChart($qqid, $qsid, 0, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache); - + break; case 'showpie': - + if ($qtype == "M" || $qtype == "P") { $data['success'] = 0; break; - } - + } + $this->Question_attributes_model->setAttribute($qqid, 'statistics_graphtype', 1); - + $adata = $_SESSION['stats'][$_POST['id']]; $data['chartdata'] = createChart($qqid, $qsid, 1, $adata['lbl'], $adata['gdata'], $adata['grawdata'], $MyCache); - - + + break; default: $data['success'] = 0; - break; + break; } - } else { + } else { $data['success'] = 0; } $this->load->view("admin/export/statistics_graph_view", $data); diff --git a/application/core/LSYii_Application.php b/application/core/LSYii_Application.php index 7b2f2b8c9c5..aafec6b3107 100644 --- a/application/core/LSYii_Application.php +++ b/application/core/LSYii_Application.php @@ -71,6 +71,20 @@ public function setConfig($name, $value) $this->config[$name] = $value; } + /** + * Loads a config from a file + * + * @access public + * @param string $file + * @return void + */ + public function loadConfig($file) + { + $config = require_once(APPPATH . '/config/' . $file . '.php'); + foreach ($config as $k => $v) + $this->setConfig($k, $v); + } + /** * Returns a config variable from the registry * diff --git a/application/helpers/admin/statistics_helper.php b/application/helpers/admin/statistics_helper.php index 541622e980f..bac4735cead 100644 --- a/application/helpers/admin/statistics_helper.php +++ b/application/helpers/admin/statistics_helper.php @@ -72,20 +72,19 @@ * @param mixed $gdata * @param mixed $grawdata * @param mixed $cache -* @return Name +* @return Name */ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) -{ - $CI = &get_instance(); - $rootdir = $CI->config->item("rootdir"); - $homedir = $CI->config->item("homedir"); - $homeurl = $CI->config->item("homeurl"); - $admintheme = $CI->config->item("admintheme"); - $scriptname = $CI->config->item("scriptname"); - $chartfontfile = $CI->config->item("chartfontfile"); - $chartfontsize = $CI->config->item("chartfontsize"); +{ + $rootdir = Yii::app()->getConfig("rootdir"); + $homedir = Yii::app()->getConfig("homedir"); + $homeurl = Yii::app()->getConfig("homeurl"); + $admintheme = Yii::app()->getConfig("admintheme"); + $scriptname = Yii::app()->getConfig("scriptname"); + $chartfontfile = Yii::app()->getConfig("chartfontfile"); + $chartfontsize = Yii::app()->getConfig("chartfontsize"); $language = GetBaseLanguageFromSurveyID($sid); - + if ($chartfontfile=='auto') { $chartfontfile='vera.ttf'; @@ -108,9 +107,9 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) } $cachefilename = ""; - + if (array_sum($gdata ) > 0) - { + { $graph = ""; $p1 = ""; @@ -122,9 +121,9 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) $i++; } } - + $totallines=$i; - + if ($totallines>15) { $gheight=320+(6.7*($totallines-15)); @@ -170,13 +169,13 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) { $graph = new pChart(1,1); - $graph->setFontProperties($rootdir."/fonts/".$chartfontfile, $chartfontsize); + $graph->setFontProperties($rootdir.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.$chartfontfile, $chartfontsize); $legendsize=$graph->getLegendBoxSize($DataSet->GetDataDescription()); if ($legendsize[1]<320) $gheight=420; else $gheight=$legendsize[1]+100; $graph = new pChart(690+$legendsize[0],$gheight); - $graph->loadColorPalette($homedir.'/styles/'.$admintheme.'/limesurvey.pal'); - $graph->setFontProperties($rootdir."/fonts/".$chartfontfile,$chartfontsize); + $graph->loadColorPalette($rootdir.DIRECTORY_SEPARATOR.'styles'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.$admintheme.DIRECTORY_SEPARATOR.'limesurvey.pal'); + $graph->setFontProperties($rootdir.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.$chartfontfile,$chartfontsize); $graph->setGraphArea(50,30,500,$gheight-60); $graph->drawFilledRoundedRectangle(7,7,523+$legendsize[0],$gheight-7,5,254,255,254); $graph->drawRoundedRectangle(5,5,525+$legendsize[0],$gheight-5,5,230,230,230); @@ -184,14 +183,14 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) $graph->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,150,150,150,TRUE,90,0,TRUE,5,false); $graph->drawGrid(4,TRUE,230,230,230,50); // Draw the 0 line - $graph->setFontProperties($rootdir."/fonts/".$chartfontfile,$chartfontsize); + $graph->setFontProperties($rootdir.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.$chartfontfile,$chartfontsize); $graph->drawTreshold(0,143,55,72,TRUE,TRUE); // Draw the bar graph $graph->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),FALSE); //$Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie4","1","Important point!"); // Finish the graph - $graph->setFontProperties($rootdir."/fonts/".$chartfontfile, $chartfontsize); + $graph->setFontProperties($rootdir.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.$chartfontfile, $chartfontsize); $graph->drawLegend(510,30,$DataSet->GetDataDescription(),255,255,255); $cache->WriteToCache("graph".$sid,$DataSet->GetData(),$graph); @@ -220,7 +219,7 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) if ($language=='ar') { $lblout=$lbl; //reset text order to original - $CI->load->library("admin/Arabic"); + Yii::import('application.libraries.admin.Arabic', true); $Arabic = new Arabic('ArGlyphs'); foreach($lblout as $kkey => $kval){ if (preg_match("^[A-Za-z]^", $kval)) { //auto detect if english @@ -274,7 +273,7 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) } } //end else -> pie charts } - + return $cachefilename; } @@ -286,8 +285,8 @@ function createChart($qid, $sid, $type, $lbl, $gdata, $grawdata, $cache) */ function getQuestionMapData($sField, $qsid) { - $CI = &get_instance(); - $aresult = $CI->Surveys_dynamic_model->getSomeRecords(array($sField), $qsid)->result(); + Survey_dynamic::sid($qsid); + $aresult = Survey_dynamic::model()->findAll(); $d = array (); @@ -298,8 +297,8 @@ function getQuestionMapData($sField, $qsid) if (count($alocation) >= 2) { $d[] = "{$alocation[0]} {$alocation[1]}"; } - } - return $d; + } + return $d; } /** @@ -318,24 +317,23 @@ function getQuestionMapData($sField, $qsid) function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $outputType='pdf', $pdfOutput='I',$statlangcode=null, $browse = true) { //$allfields =""; - global $rooturl, $rootdir, $homedir, $homeurl, $scriptname, $admintheme, $pdfdefaultfont, $pdffontsize; - - - - $CI = &get_instance(); - $imagedir = $CI->config->item("imagedir"); - $tempdir = $CI->config->item("tempdir"); - $tempurl = $CI->config->item("tempurl"); - - $clang = $CI->limesurvey_lang; - $dbprefix = $CI->db->dbprefix; + + global $rooturl, $rootdir, $homedir, $homeurl, $scriptname, + $chartfontfile, $chartfontsize, $admintheme, $pdfdefaultfont, $pdffontsize; + + + $imagedir = Yii::app()->getConfig("imagedir"); + $tempdir = Yii::app()->getConfig("tempdir"); + $tempurl = Yii::app()->getConfig("tempurl"); + $clang = Yii::app()->lang; + $fieldmap=createFieldMap($surveyid, "full"); $astatdata = array(); // Used for getting coordinates for google maps $agmapdata = array(); - + //pick the best font file if font setting is 'auto' if (is_null($statlangcode)) { @@ -382,10 +380,10 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if($q2show=='all' ) { $summarySql=" SELECT gid, parent_qid, qid, type " - ." FROM {$dbprefix}questions WHERE parent_qid=0" + ." FROM {{questions}} WHERE parent_qid=0" ." AND sid=$surveyid "; - $summaryRs = db_execute_assoc($summarySql); + $summaryRs = Yii::app()->db->createCommand($summarySql)->query()->readAll(); foreach($summaryRs as $field) { @@ -407,12 +405,12 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($field['type'] == "F" || $field['type'] == "H") { //Get answers. We always use the answer code because the label might be too long elsewise - $query = "SELECT code, answer FROM ".$CI->db->dbprefix("answers")." WHERE qid='".$field['qid']."' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; - $result = db_execute_assoc($query) or safe_die ("Couldn't get answers!
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT code, answer FROM {{answers}} WHERE qid='".$field['qid']."' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; + $result = Yii::app()->db->createCommand($query)->query(); $counter2=0; //check all the answers - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $row=array_values($row); $myField = "$myField{$row[0]}"; @@ -469,9 +467,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, global $l; $l['w_page'] = $statlang->gT("Page",'unescaped'); //require_once('classes/tcpdf/mypdf.php'); - $CI->load->library('admin/pdf'); + Yii::import('application.libraries.admin.pdf', true); // create new PDF document - $pdf = $CI->pdf; + $pdf = new Pdf(); $pdf->SetFont($pdfdefaultfont,'',$pdffontsize); $surveyInfo = getSurveyInfo($surveyid,$language); @@ -514,11 +512,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, /** * Initiate the Spreadsheet_Excel_Writer */ - $CI->load->library('admin/pear/Spreadsheet/Excel/Xlswriter'); + Yii::import('application.libraries.admin.pear.Spreadsheet.Excel.Xlswriter', true); if($pdfOutput=='F') - $workbook = new Spreadsheet_Excel_Writer($tempdir.'/statistic-survey'.$surveyid.'.xls'); + $workbook = new Xlswriter($tempdir.'/statistic-survey'.$surveyid.'.xls'); else - $workbook = new Spreadsheet_Excel_Writer(); + $workbook = new Xlswriter(); $workbook->setVersion(8); // Inform the module that our data will arrive as UTF-8. @@ -527,7 +525,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $workbook->setTempDir($tempdir); } if ($pdfOutput!='F') - $workbook->send('statistic-survey'.$surveyid.'.xls'); + $workbook->send('statistic-survey'.$surveyid.'.xls'); // Creating the first worksheet $sheet =& $workbook->addWorksheet(utf8_decode('results-survey'.$surveyid)); @@ -600,11 +598,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //create a list out of the $pv array list($lsid, $lgid, $lqid) = explode("X", $pv); - $aquery="SELECT title FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid=$lqid AND language='{$language}' and scale_id=0 ORDER BY question_order"; - $aresult=db_execute_assoc($aquery) or safe_die ("Couldn't get subquestions
    $aquery
    ".$connect->ErrorMsg()); + $aquery="SELECT title FROM {{questions}} WHERE parent_qid=$lqid AND language='{$language}' and scale_id=0 ORDER BY question_order"; + $aresult=Yii::app()->db->createCommand($aquery)->query(); // go through every possible answer - foreach ($aresult->result_array() as $arow) + foreach ($aresult->readAll() as $arow) { $arow=array_values($arow); // only add condition if answer has been chosen @@ -745,15 +743,15 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //end foreach -> loop through filter options to create SQL //count number of answers - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid"); + $query = "SELECT count(*) FROM {{survey_$surveyid}}"; //if incompleted answers should be filtert submitdate has to be not null if (incompleteAnsFilterstate() == "inc") {$query .= " WHERE submitdate is null";} elseif (incompleteAnsFilterstate() == "filter") {$query .= " WHERE submitdate is not null";} - $result = db_execute_assoc($query) or safe_die ("Couldn't get total
    $query
    ".$connect->ErrorMsg()); + $result = Yii::app()->db->createCommand($query)->query(); //$total = total number of answers - $row=$result->row_array(); $total=reset($row); + $row=$result->read(); $total=reset($row); //are there any filters that have to be taken care of? if (isset($selects) && $selects) @@ -785,10 +783,10 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //get me some data Scotty - $result=db_execute_assoc($query) or safe_die("Couldn't get results
    $query
    ".$connect->ErrorMsg()); + $result=Yii::app()->db->createCommand($query)->query(); //put all results into $results - $row=$result->row_array(); $results=reset($row); + $row=$result->read(); $results=reset($row); if ($total) { @@ -871,7 +869,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if($outputType=='html' && $browse === true) { //add a buttons to browse results - $statisticsoutput .= "
    \n" + $statisticsoutput .= "\n" ."\t\t

    " ."\t\t\t\n" ."\t\t\t\n" @@ -891,11 +889,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //START Chop up fieldname and find matching questions //GET LIST OF LEGIT QIDs FOR TESTING LATER - $lq = "SELECT DISTINCT qid FROM ".$CI->db->dbprefix("questions")." WHERE sid=$surveyid and parent_qid=0"; - $lr = db_execute_assoc($lq); + $lq = "SELECT DISTINCT qid FROM {{questions}} WHERE sid=$surveyid and parent_qid=0"; + $lr = Yii::app()->db->createCommand($lq)->query(); //loop through the IDs - foreach ($lr->result_array() as $lw) + foreach ($lr->readAll() as $lw) { //this creates an array of question id's' $legitqids[] = $lw['qid']; @@ -915,11 +913,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strlen($rt)), 3); //select details for this question - $nquery = "SELECT title, type, question, parent_qid, other FROM ".$CI->db->dbprefix("questions")." WHERE language='{$language}' AND parent_qid=0 AND qid='$qqid'"; - $nresult = db_execute_assoc($nquery) or safe_die ("Couldn't get question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question, parent_qid, other FROM {{questions}} WHERE language='{$language}' AND parent_qid=0 AND qid='$qqid'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); //loop through question data - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=$nrow[0]; @@ -930,11 +928,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //1. Get list of answers - $query="SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qqid' AND language='{$language}' and scale_id=0 ORDER BY question_order"; - $result=db_execute_assoc($query) or safe_die("Couldn't get list of subquestions for multitype
    $query
    ".$connect->ErrorMsg()); + $query="SELECT title, question FROM {{questions}} WHERE parent_qid='$qqid' AND language='{$language}' and scale_id=0 ORDER BY question_order"; + $result=Yii::app()->db->createCommand($query)->query(); //loop through multiple answers - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $row=array_values($row); $mfield=substr($rt, 1, strlen($rt))."$row[0]"; @@ -975,11 +973,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //get question data - $nquery = "SELECT title, type, question, other, parent_qid FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid=0 AND qid='$qqid' AND language='{$language}'"; - $nresult = db_execute_assoc($nquery) or safe_die("Couldn't get text question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question, other, parent_qid FROM {{questions}} WHERE parent_qid=0 AND qid='$qqid' AND language='{$language}'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); //loop through question data - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=FlattenText($nrow[0]); @@ -1018,14 +1016,14 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $qaid=substr($qqid, $qidlength, strlen($qqid)-$qidlength); //get some question data - $nquery = "SELECT title, type, question, other FROM ".$CI->db->dbprefix("questions")." WHERE qid='".substr($qqid, 0, $qidlength)."' AND parent_qid=0 AND language='{$language}'"; - $nresult = db_execute_assoc($nquery) or safe_die("Couldn't get text question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question, other FROM {{questions}} WHERE qid='".substr($qqid, 0, $qidlength)."' AND parent_qid=0 AND language='{$language}'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); //more substrings $count = substr($qqid, strlen($qqid)-1); //loop through question data - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=FlattenText($nrow[0]).'-'.$count; @@ -1034,11 +1032,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //get answers - $qquery = "SELECT title as code, question as answer FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='".substr($qqid, 0, $qidlength)."' AND title='$qaid' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or safe_die ("Couldn't get answer details (Array 5p Q)
    $qquery
    ".$connect->ErrorMsg()); + $qquery = "SELECT title as code, question as answer FROM {{questions}} WHERE parent_qid='".substr($qqid, 0, $qidlength)."' AND title='$qaid' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); //loop through answer data - foreach ($qresult->result_array() as $qrow) + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); //store each answer here @@ -1068,11 +1066,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strpos($rt, "-")-($lengthofnumeral+1)), 3); //get question data - $nquery = "SELECT title, type, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid=0 AND qid='$qqid' AND language='{$language}'"; - $nresult = db_execute_assoc($nquery) or safe_die ("Couldn't get question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question FROM {{questions}} WHERE parent_qid=0 AND qid='$qqid' AND language='{$language}'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); //loop through question data - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=FlattenText($nrow[0]). " [".substr($rt, strpos($rt, "-")-($lengthofnumeral), $lengthofnumeral)."]"; @@ -1081,11 +1079,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //get answers - $query="SELECT code, answer FROM ".$CI->db->dbprefix("answers")." WHERE qid='$qqid' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; - $result=db_execute_assoc($query) or safe_die("Couldn't get list of answers for multitype
    $query
    ".$connect->ErrorMsg()); + $query="SELECT code, answer FROM {{answers}} WHERE qid='$qqid' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; + $result=Yii::app()->db->createCommand($query)->query(); //loop through answers - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $row=array_values($row); //create an array containing answer code, answer and fieldname(??) @@ -1101,11 +1099,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strlen($rt)), 3); //select details for this question - $nquery = "SELECT title, type, question, parent_qid, other FROM ".$CI->db->dbprefix("questions")." WHERE language='{$language}' AND parent_qid=0 AND qid='$qqid'"; - $nresult = db_execute_assoc($nquery) or safe_die ("Couldn't get question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question, parent_qid, other FROM {{questions}} WHERE language='{$language}' AND parent_qid=0 AND qid='$qqid'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); //loop through question data - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=$nrow[0]; @@ -1129,26 +1127,26 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, // 1) Total number of files uploaded // 2) Number of respondents who uploaded at least one file (with the inverse being the number of respondents who didn t upload any) $fieldname=substr($rt, 1, strlen($rt)); - $query = "SELECT SUM(".db_quote_id($fieldname.'_filecount').") as sum, AVG(".db_quote_id($fieldname.'_filecount').") as avg FROM ".$CI->db->dbprefix("survey_$surveyid"); - $result=db_execute_assoc($query) or safe_die("Couldn't fetch the records
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT SUM(".db_quote_id($fieldname.'_filecount').") as sum, AVG(".db_quote_id($fieldname.'_filecount').") as avg FROM {{survey_$surveyid}}"; + $result=Yii::app()->db->createCommand($query)->query(); $showem = array(); - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $showem[]=array($statlang->gT("Total number of files"), $row['sum']); $showem[]=array($statlang->gT("Average no. of files per respondent"), $row['avg']); } - $query = "SELECT ". $fieldname ." as json FROM ".$CI->db->dbprefix("survey_$surveyid"); - $result=db_execute_assoc($query) or safe_die("Couldn't fetch the records
    $query
    ".$connect->ErrorMsg()); + $query = "SELECT ". $fieldname ." as json FROM {{survey_$surveyid}}"; + $result=Yii::app()->db->createCommand($query)->query(); $responsecount = 0; $filecount = 0; $size = 0; - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $json = $row['json']; @@ -1165,7 +1163,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $showem[] = array($statlang->gT("Average file size"), $size/$filecount . " KB"); $showem[] = array($statlang->gT("Average size per respondent"), $size/$responsecount . " KB"); -/* $query="SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qqid' AND language='{$language}' ORDER BY question_order"; +/* $query="SELECT title, question FROM {{questions}} WHERE parent_qid='$qqid' AND language='{$language}' ORDER BY question_order"; $result=db_execute_num($query) or safe_die("Couldn't get list of subquestions for multitype
    $query
    ".$connect->ErrorMsg()); //loop through multiple answers @@ -1274,22 +1272,22 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //get question details from DB $nquery = "SELECT title, type, question, qid, parent_qid - FROM ".$CI->db->dbprefix("questions")." + FROM {{questions}} WHERE parent_qid=0 AND qid='".substr($qqid, 0, $qidlength)."' AND language='{$language}'"; - $nresult = db_execute_assoc($nquery) or safe_die("Couldn't get text question
    $nquery
    ".$connect->ErrorMsg()); + $nresult = Yii::app()->db->createCommand($nquery)->query(); } //probably question type "N" = numerical input else { //we can use the qqid without any editing - $nquery = "SELECT title, type, question, qid, parent_qid FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid=0 AND qid='$qqid' AND language='{$language}'"; - $nresult = db_execute_assoc($nquery) or safe_die ("Couldn't get question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question, qid, parent_qid FROM {{questions}} WHERE parent_qid=0 AND qid='$qqid' AND language='{$language}'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); } //loop through results - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=FlattenText($nrow[0]); //clean up title @@ -1303,7 +1301,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if(substr($rt, 0, 1) == "K") { //get answer data - $atext=$connect->GetOne("SELECT question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='{$qiqid}' AND scale_id=0 AND title='{$qaid}' AND language='{$language}'"); + $atext=Yii::app()->db->createCommand("SELECT question FROM {{questions}} WHERE parent_qid='{$qiqid}' AND scale_id=0 AND title='{$qaid}' AND language='{$language}'")->queryScalar(); //put single items in brackets at output $qtitle .= " [$atext]"; } @@ -1368,7 +1366,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $fieldname=substr($rt, 1, strlen($rt)); //special treatment for MS SQL databases - $sDatabaseType = $CI->db->platform(); + $sDatabaseType = Yii::app()->db->getDriverName(); if ($sDatabaseType == 'odbc_mssql' || $sDatabaseType == 'odbtp' || $sDatabaseType == 'mssql_n' || $sDatabaseType == 'mssqlnative') { //standard deviation @@ -1399,7 +1397,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($sDatabaseType == 'odbc_mssql' || $sDatabaseType == 'odbtp' || $sDatabaseType == 'mssql_n' || $sDatabaseType == 'mssqlnative') { //no NULL/empty values please - $query .= " FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT NULL"; + $query .= " FROM {{survey_$surveyid}} WHERE ".db_quote_id($fieldname)." IS NOT NULL"; if(!$excludezeros) { //NO ZERO VALUES @@ -1411,7 +1409,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, else { //no NULL/empty values please - $query .= " FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT NULL"; + $query .= " FROM {{survey_$surveyid}} WHERE ".db_quote_id($fieldname)." IS NOT NULL"; if(!$excludezeros) { //NO ZERO VALUES @@ -1427,10 +1425,10 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($sql != "NULL") {$query .= " AND $sql";} //execute query - $result=db_execute_assoc($query) or safe_die("Couldn't do maths testing
    $query
    ".$connect->ErrorMsg()); + $result=Yii::app()->db->createCommand($query)->query(); //get calculated data - foreach ($nresult->result_array() as $row) + foreach ($nresult->readAll() as $row) { //put translation of mean and calculated data into $showem array $showem[]=array($statlang->gT("Sum"), $row['sum']); @@ -1448,7 +1446,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //CALCULATE QUARTILES //get data - $query ="SELECT ".db_quote_id($fieldname)." FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT null"; + $query ="SELECT ".db_quote_id($fieldname)." FROM {{survey_$surveyid}} WHERE ".db_quote_id($fieldname)." IS NOT null"; //NO ZEROES if(!$excludezeros) { @@ -1463,9 +1461,8 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($sql != "NULL") {$query .= " AND $sql";} //execute query - $result=$connect->Execute($query) or safe_die("Disaster during median calculation
    $query
    ".$connect->ErrorMsg()); - - $querystarter="SELECT ".db_quote_id($fieldname)." FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id($fieldname)." IS NOT null"; + $result = Yii::app()->db->createCommand($quer)->query(); + $querystarter="SELECT ".db_quote_id($fieldname)." FROM {{survey_$surveyid}} WHERE ".db_quote_id($fieldname)." IS NOT null"; //No Zeroes if(!$excludezeros) { @@ -1479,7 +1476,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($sql != "NULL") {$querystarter .= " AND $sql";} //we just count the number of records returned - $medcount=$result->RecordCount(); + $medcount=$result->getRowCount(); //put the total number of records at the beginning of this array array_unshift($showem, array($statlang->gT("Count"), $medcount)); @@ -1504,9 +1501,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, { //ODD NUMBER $query = $querystarter . " ORDER BY ".db_quote_id($fieldname)."*1 "; - $result=db_select_limit_assoc($query, 2, $q1c) or safe_die("1st Quartile query failed
    ".$connect->ErrorMsg()); + $result=Yii::app()->db->createCommand($query)->limit(2, $q1c)->query(); - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { if ($total == 0) {$total=$total-$row[$fieldname];} @@ -1525,9 +1522,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, { //EVEN NUMBER $query = $querystarter . " ORDER BY ".db_quote_id($fieldname)."*1 "; - $result=db_select_limit_assoc($query,1, $q1c) or safe_die ("1st Quartile query failed
    ".$connect->ErrorMsg()); + $result=Yii::app()->db->createCommand($query)->limit(1, $q1c)->query(); - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $showem[]=array($statlang->gT("1st quartile (Q1)"), $row[$fieldname]); } @@ -1546,9 +1543,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, { //remainder $query = $querystarter . " ORDER BY ".db_quote_id($fieldname)."*1 "; - $result=db_select_limit_assoc($query,2, $medianc) or safe_die("What a complete mess with the remainder
    $query
    ".$connect->ErrorMsg()); + $result=Yii::app()->db->createCommand($query)->limit(2, $medianc)->query(); - foreach ($result->result_array() as $row) {$total=$total+$row[$fieldname];} + foreach ($result->readAll() as $row) {$total=$total+$row[$fieldname];} $showem[]=array($statlang->gT("2nd quartile (Median)"), $total/2); } @@ -1557,9 +1554,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, { //EVEN NUMBER $query = $querystarter . " ORDER BY ".db_quote_id($fieldname)."*1 "; - $result=db_select_limit_assoc($query,1, $medianc-1) or safe_die("What a complete mess
    $query
    ".$connect->ErrorMsg()); + $result = Yii::app()->db->createCommand($query)->limit(1, $medianc-1)->query(); - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $showem[]=array($statlang->gT("Median value"), $row[$fieldname]); } @@ -1577,9 +1574,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($q3 != $q3b) { $query = $querystarter . " ORDER BY ".db_quote_id($fieldname)."*1 "; - $result = db_select_limit_assoc($query,2,$q3c) or safe_die("3rd Quartile query failed
    ".$connect->ErrorMsg()); + $result = Yii::app()->db->createCommand($query)->limit(2,$q3c)->query(); - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { if ($total == 0) {$total=$total-$row[$fieldname];} @@ -1597,9 +1594,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, else { $query = $querystarter . " ORDER BY ".db_quote_id($fieldname)."*1"; - $result = db_select_limit_assoc($query,1, $q3c) or safe_die("3rd Quartile even query failed
    ".$connect->ErrorMsg()); + $result = Yii::app()->db->createCommand($query)->limit(1, $q3c); - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $showem[]=array($statlang->gT("3rd quartile (Q3)"), $row[$fieldname]); } @@ -1776,11 +1773,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $rqid=$qqid; //get question data - $nquery = "SELECT title, type, question, qid, parent_qid, other FROM ".$CI->db->dbprefix("questions")." WHERE qid='{$rqid}' AND parent_qid=0 and language='{$language}'"; - $nresult = db_execute_assoc($nquery) or safe_die ("Couldn't get question
    $nquery
    ".$connect->ErrorMsg()); + $nquery = "SELECT title, type, question, qid, parent_qid, other FROM {{questions}} WHERE qid='{$rqid}' AND parent_qid=0 and language='{$language}'"; + $nresult = Yii::app()->db->createCommand($nquery)->query(); //loop though question data - foreach ($nresult->result_array() as $nrow) + foreach ($nresult->readAll() as $nrow) { $nrow=array_values($nrow); $qtitle=FlattenText($nrow[0]); @@ -1798,11 +1795,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, case "A": //get data - $qquery = "SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or safe_die ("Couldn't get answer details (Array 5p Q)
    $qquery
    ".$connect->ErrorMsg()); + $qquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); //loop through results - foreach ($qresult->result_array() as $qrow) + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); //5-point array @@ -1825,9 +1822,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //Array of 10 point choices //same as above just with 10 items case "B": - $qquery = "SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or safe_die ("Couldn't get answer details (Array 10p Q)
    $qquery
    ".$connect->ErrorMsg()); - foreach ($qresult->result_array() as $qrow) + $qquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); for ($i=1; $i<=10; $i++) @@ -1845,11 +1842,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //Array of Yes/No/$statlang->gT("Uncertain") case "C": - $qquery = "SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or safe_die ("Couldn't get answer details
    $qquery
    ".$connect->ErrorMsg()); + $qquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); //loop thorugh results - foreach ($qresult->result_array() as $qrow) + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); //add results @@ -1868,9 +1865,9 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //Array of Yes/No/$statlang->gT("Uncertain") //same as above case "E": - $qquery = "SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or safe_die ("Couldn't get answer details
    $qquery
    ".$connect->ErrorMsg()); - foreach ($qresult->result_array() as $qrow) + $qquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); $alist[]=array("I", $statlang->gT("Increase")); @@ -1886,15 +1883,15 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, case ";": //Array (Multi Flexi) (Text) list($qacode, $licode)=explode("_", $qanswer); - $qquery = "SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qacode' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or die ("Couldn't get answer details
    $qquery
    ".$connect->ErrorMsg()); + $qquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qacode' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); - foreach ($qresult->result_array() as $qrow) + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); - $fquery = "SELECT * FROM ".$CI->db->dbprefix("answers")." WHERE qid='{$qiqid}' AND scale_id=0 AND code = '{$licode}' AND language='{$language}'ORDER BY sortorder, code"; + $fquery = "SELECT * FROM {{answers}} WHERE qid='{$qiqid}' AND scale_id=0 AND code = '{$licode}' AND language='{$language}'ORDER BY sortorder, code"; $fresult = db_execute_assoc($fquery); - foreach ($result->result_array() as $frow) + foreach ($result->readAll() as $frow) { $alist[]=array($frow['code'], $frow['answer']); $ltext=$frow['answer']; @@ -1950,20 +1947,20 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, case "F": //Array of Flexible case "H": //Array of Flexible by Column - $qquery = "SELECT title, question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; - $qresult=db_execute_assoc($qquery) or safe_die ("Couldn't get answer details
    $qquery
    ".$connect->ErrorMsg()); + $qquery = "SELECT title, question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; + $qresult=Yii::app()->db->createCommand($qquery)->query(); //loop through answers - foreach ($result->result_array() as $qrow) + foreach ($result->readAll() as $qrow) { $qrow=array_values($qrow); //this question type uses its own labels - $fquery = "SELECT * FROM ".$CI->db->dbprefix("answers")." WHERE qid='{$qiqid}' AND scale_id=0 AND language='{$language}'ORDER BY sortorder, code"; + $fquery = "SELECT * FROM {{answers}} WHERE qid='{$qiqid}' AND scale_id=0 AND language='{$language}'ORDER BY sortorder, code"; $fresult = db_execute_assoc($fquery); //add code and title to results for outputting them later - foreach ($fresult->result_array() as $frow) + foreach ($fresult->readAll() as $frow) { $alist[]=array($frow['code'], FlattenText($frow['answer'])); } @@ -2012,7 +2009,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, case "1": //array (dual scale) - $sSubquestionQuery = "SELECT question FROM ".$CI->db->dbprefix("questions")." WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; + $sSubquestionQuery = "SELECT question FROM {{questions}} WHERE parent_qid='$qiqid' AND title='$qanswer' AND language='{$language}' ORDER BY question_order"; $sSubquestion=FlattenText($connect->GetOne($sSubquestionQuery)); //get question attributes @@ -2022,7 +2019,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if (substr($rt,-1,1) == 0) { //get label 1 - $fquery = "SELECT * FROM ".$CI->db->dbprefix("answers")." WHERE qid='{$qqid}' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, code"; + $fquery = "SELECT * FROM {{answers}} WHERE qid='{$qqid}' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, code"; //header available? if (trim($qidattributes['dualscale_headerA'])!='') { @@ -2044,7 +2041,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, else { //get label 2 - $fquery = "SELECT * FROM ".$CI->db->dbprefix("answers")." WHERE qid='{$qqid}' AND scale_id=1 AND language='{$language}' ORDER BY sortorder, code"; + $fquery = "SELECT * FROM {{answers}} WHERE qid='{$qqid}' AND scale_id=1 AND language='{$language}' ORDER BY sortorder, code"; //header available? if (trim($qidattributes['dualscale_headerB'])!='') { @@ -2063,10 +2060,10 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //get data - $fresult = db_execute_assoc($fquery); + $fresult = Yii::app()->db->createCommand($fquery)->query(); //put label code and label title into array - foreach ($fresult->result_array() as $frow) + foreach ($fresult->readAll() as $frow) { $alist[]=array($frow['code'], FlattenText($frow['answer'])); } @@ -2082,11 +2079,11 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, default: //default handling //get answer code and title - $qquery = "SELECT code, answer FROM ".$CI->db->dbprefix("answers")." WHERE qid='$qqid' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; - $qresult = db_execute_assoc($qquery) or safe_die ("Couldn't get answers list
    $qquery
    ".$connect->ErrorMsg()); + $qquery = "SELECT code, answer FROM {{answers}} WHERE qid='$qqid' AND scale_id=0 AND language='{$language}' ORDER BY sortorder, answer"; + $qresult = Yii::app()->db->createCommand($qquery)->query(); //put answer code and title into array - foreach ($qresult->result_array() as $qrow) + foreach ($qresult->readAll() as $qrow) { $qrow=array_values($qrow); $alist[]=array("$qrow[0]", FlattenText($qrow[1])); @@ -2190,12 +2187,12 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, { // It is better for single choice question types to filter on the number of '-oth-' entries, than to // just count the number of 'other' values - that way with failing Javascript the statistics don't get messed up - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id(substr($al[2],0,strlen($al[2])-5))."='-oth-'"; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ".db_quote_id(substr($al[2],0,strlen($al[2])-5))."='-oth-'"; } else { //get data - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE "; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE "; $query .= ($sDatabaseType == "mysql")? db_quote_id($al[2])." != ''" : "NOT (".db_quote_id($al[2])." LIKE '')"; } } @@ -2211,28 +2208,30 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, elseif ($qtype == "U" || $qtype == "T" || $qtype == "S" || $qtype == "Q" || $qtype == ";") { + $sDatabaseType = Yii::app()->db->getDriverName(); + //free text answers if($al[0]=="Answers") { - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE "; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE "; $query .= ($sDatabaseType == "mysql")? db_quote_id($al[2])." != ''" : "NOT (".db_quote_id($al[2])." LIKE '')"; } //"no answer" handling elseif($al[0]=="NoAnswer") { - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ( "; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ( "; $query .= ($sDatabaseType == "mysql")? db_quote_id($al[2])." = '')" : " (".db_quote_id($al[2])." LIKE ''))"; } } elseif ($qtype == "O") { - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ( "; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ( "; $query .= ($sDatabaseType == "mysql")? db_quote_id($al[2])." <> '')" : " (".db_quote_id($al[2])." NOT LIKE ''))"; // all other question types } else { - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id($al[2])." ="; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ".db_quote_id($al[2])." ="; //ranking question? if (substr($rt, 0, 1) == "R") @@ -2252,14 +2251,14 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($al[0] != "") { //get more data - $sDatabaseType = $CI->db->platform(); + $sDatabaseType = Yii::app()->db->getDriverName(); if ($sDatabaseType == 'odbc_mssql' || $sDatabaseType == 'odbtp' || $sDatabaseType == 'mssql_n' || $sDatabaseType == 'mssqlnative') { // mssql cannot compare text blobs so we have to cast here - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE cast(".db_quote_id($rt)." as varchar)= '$al[0]'"; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE cast(".db_quote_id($rt)." as varchar)= '$al[0]'"; } else - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ".db_quote_id($rt)." = '$al[0]'"; + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ".db_quote_id($rt)." = '$al[0]'"; } else { // This is for the 'NoAnswer' case @@ -2273,15 +2272,15 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($sDatabaseType == 'odbc_mssql' || $sDatabaseType == 'odbtp' || $sDatabaseType == 'mssql_n' || $sDatabaseType == 'mssqlnative') { // mssql cannot compare text blobs so we have to cast here - //$query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE (".db_quote_id($rt)." IS NULL " - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ( " + //$query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE (".db_quote_id($rt)." IS NULL " + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ( " // . "OR cast(".db_quote_id($rt)." as varchar) = '' " . "cast(".db_quote_id($rt)." as varchar) = '' " . "OR cast(".db_quote_id($rt)." as varchar) = ' ' )"; } else - // $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE (".db_quote_id($rt)." IS NULL " - $query = "SELECT count(*) FROM ".$CI->db->dbprefix("survey_$surveyid")." WHERE ( " + // $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE (".db_quote_id($rt)." IS NULL " + $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ( " // . "OR ".db_quote_id($rt)." = '' " . " ".db_quote_id($rt)." = '' " . "OR ".db_quote_id($rt)." = ' ') "; @@ -2297,12 +2296,12 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if ($sql != "NULL") {$query .= " AND $sql";} //get data - $result=db_execute_assoc($query) or safe_die ("Couldn't do count of values
    $query
    ".$connect->ErrorMsg()); + $result=Yii::app()->db->createCommand($query)->query(); // $statisticsoutput .= "\n\n\n"; // this just extracts the data, after we present - foreach ($result->result_array() as $row) + foreach ($result->readAll() as $row) { $row=array_values($row); //increase counter @@ -2361,7 +2360,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //check if aggregated results should be shown - elseif ($CI->config->item('showaggregateddata') == 1) + elseif (Yii::app()->getConfig('showaggregateddata') == 1) { if(!isset($showheadline) || $showheadline != false) { @@ -2452,7 +2451,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //text for answer column is always needed $fname="$al[1] ($al[0])"; - //these question types get special treatment by $CI->config->item('showaggregateddata') + //these question types get special treatment by Yii::app()->getConfig('showaggregateddata') if($qtype == "5" || $qtype == "A") { //put non-edited data in here because $row will be edited later @@ -2596,7 +2595,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, if (($qtype != "M") and ($qtype != "P")) { //is the checkbox "Don't consider NON completed responses (only works when Filter incomplete answers is Disable)" checked? - //if (isset($_POST["noncompleted"]) and ($_POST["noncompleted"] == "on") && (isset($CI->config->item('showaggregateddata')) && $CI->config->item('showaggregateddata') == 0)) + //if (isset($_POST["noncompleted"]) and ($_POST["noncompleted"] == "on") && (isset(Yii::app()->getConfig('showaggregateddata')) && Yii::app()->getConfig('showaggregateddata') == 0)) // TIBO: TODO WE MUST SKIP THE FOLLOWING SECTION FOR TYPE A and 5 when // showaggreagated data is set and set to 1 if (isset($_POST["noncompleted"]) and ($_POST["noncompleted"] == "on") ) @@ -2738,8 +2737,8 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, $statisticsoutput .= sprintf("%01.2f", $gdata[$i]) . "%"; $gdata[$i] = 0; - //check if we have to adjust ouput due to $CI->config->item('showaggregateddata') setting - if($CI->config->item('showaggregateddata') == 1 && ($qtype == "5" || $qtype == "A")) + //check if we have to adjust ouput due to Yii::app()->getConfig('showaggregateddata') setting + if(Yii::app()->getConfig('showaggregateddata') == 1 && ($qtype == "5" || $qtype == "A")) { $statisticsoutput .= "\t\t"; } @@ -2760,7 +2759,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, else { //check if data should be aggregated - if($CI->config->item('showaggregateddata') == 1 && ($qtype == "5" || $qtype == "A")) + if(Yii::app()->getConfig('showaggregateddata') == 1 && ($qtype == "5" || $qtype == "A")) { //mark that we have done soemthing special here $aggregated = true; @@ -3165,7 +3164,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, } //end while //only show additional values when this setting is enabled - if($CI->config->item('showaggregateddata') == 1 ) + if(Yii::app()->getConfig('showaggregateddata') == 1 ) { //it's only useful to calculate standard deviation and arithmetic means for question types //5 = 5 Point Scale @@ -3305,10 +3304,10 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //-------------------------- PCHART OUTPUT ---------------------------- - - list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strlen($rt)), 3); + list($qsid, $qgid, $qqid) = explode("X", $rt, 3); + $qsid = $surveyid; $aattr = getQuestionAttributeValues($qqid, substr($rt, 0, 1)); - + //PCHART has to be enabled and we need some data if ($usegraph == 1) { $bShowGraph = $aattr["statistics_showgraph"] == "1"; @@ -3330,13 +3329,13 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, 'lbl' => $lbl, 'gdata' => $gdata, 'grawdata' => $grawdata - ); + ); if (array_sum($gdata)>0 && $bShowGraph == true) - { - $cachefilename = createChart($qqid, $qsid, $bShowPieChart, $lbl, $gdata, $grawdata, $MyCache); + { + $cachefilename = createChart($qqid, $qsid, $bShowPieChart, $lbl, $gdata, $grawdata, $MyCache); //introduce new counter - if (!isset($ci)) {$ci=0;} + if (!isset($ci)) {$ci=0;} //increase counter, start value -> 1 $ci++; @@ -3384,8 +3383,8 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, //close table/output if($outputType=='html') { if ($usegraph) { - $sImgUrl = $CI->config->item('imageurl'); - + $sImgUrl = Yii::app()->getConfig('imageurl'); + $statisticsoutput .= "

    " ."" ."" @@ -3394,7 +3393,7 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, ."" ."" ."
    "; - + } $statisticsoutput .= "
    \n"; } @@ -3439,18 +3438,19 @@ function generate_statistics($surveyid, $allfields, $q2show='all', $usegraph=0, case 'pdf': $pdf->lastPage(); + if($pdfOutput=='F') { // This is only used by lsrc to send an E-Mail attachment, so it gives back the filename to send and delete afterwards $pdf->Output($tempdir."/".$statlang->gT('Survey').'_'.$surveyid."_".$surveyInfo['surveyls_title'].'.pdf', $pdfOutput); return $tempdir."/".$statlang->gT('Survey').'_'.$surveyid."_".$surveyInfo['surveyls_title'].'.pdf'; } else - return $pdf->Output($statlang->gT('Survey').'_'.$surveyid."_".$surveyInfo['surveyls_title'].'.pdf', $pdfOutput); + return $pdf->Output($statlang->gT('Survey').'_'.$surveyid."_".$surveyInfo['surveyls_title'].'.pdf', $pdfOutput); break; case 'html': $statisticsoutput .= "" - .""; + .""; return $statisticsoutput; break; @@ -3478,3 +3478,4 @@ function square($number) return $squarenumber; } + diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php index 50fa4dedd1d..93508bc6c5f 100644 --- a/application/helpers/common_helper.php +++ b/application/helpers/common_helper.php @@ -854,13 +854,12 @@ function getMaxgrouporder($surveyid) */ function getGroupOrder($surveyid,$gid) { - $CI =& get_instance(); - $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() ; + $grporder_result = Groups::model()->findByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'language' => $s_lang)); //Checked + $grporder_row = $grporder_result->attributes ; $group_order = $grporder_row['group_order']; if($group_order=="") { @@ -875,14 +874,12 @@ function getGroupOrder($surveyid,$gid) */ function getMaxquestionorder($gid,$surveyid) { - $CI =& get_instance(); $gid=sanitize_int($gid); $s_lang = GetBaseLanguageFromSurveyID($surveyid); - $CI->load->model('questions_model'); - //$max_sql = "SELECT max( question_order ) AS max FROM ".db_table_name('questions')." WHERE gid='$gid' AND language='$s_lang'"; + $max_sql = "SELECT max( question_order ) AS max FROM {{questions}} WHERE gid='$gid' AND language='$s_lang'"; - $max_result =$CI->questions_model->getMaximumQuestionOrder($gid,$s_lang); ; //Checked - $maxrow = $max_result->row_array() ; + $max_result = Yii::app()->db->createCommand($max_sql)->query(); //Checked + $maxrow = $max_result->read() ; $current_max = $maxrow['max']; if($current_max=="") { @@ -1283,7 +1280,6 @@ function getgrouplist2($gid,$surveyid) function getgrouplist3($gid,$surveyid) { - $CI =& get_instance(); //$clang = $CI->limesurvey_lang; $gid=sanitize_int($gid); $surveyid=sanitize_int($surveyid); @@ -1292,15 +1288,14 @@ function getgrouplist3($gid,$surveyid) $groupselecter = ""; $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 = Groups::model()->findAllByAttributes(array('sid' => $surveyid, 'language' => $s_lang)); - $gidresult = $CI->groups_model->getGroupAndID($surveyid,$s_lang); // or safe_die("Plain old did not work!"); //Checked - - foreach ($gidresult->result_array() as $gv) + foreach ($gidresult as $gv) { + $gv = $gv->attributes; $groupselecter .= "".htmlspecialchars($gv['group_name'])."\n"; @@ -1710,7 +1705,7 @@ function fixSortOrderGroups($surveyid) //Function rewrites the sortorder for gro function fixmovedquestionConditions($qid,$oldgid,$newgid) //Function rewrites the cfieldname for a question after group change { $CI = &get_instance(); - $surveyid = $CI->config->item('sid'); + $surveyid = Yii::app()->getConfig('sid'); $qid=sanitize_int($qid); $oldgid=sanitize_int($oldgid); $newgid=sanitize_int($newgid); @@ -2244,9 +2239,9 @@ function strip_comments($comment, $email, $replace=''){ function validate_templatedir($templatename) { $CI = &get_instance(); - $usertemplaterootdir = $CI->config->item('usertemplaterootdir'); - $standardtemplaterootdir = $CI->config->item('standardtemplaterootdir'); - $defaulttemplate = $CI->config->item('defaulttemplate'); + $usertemplaterootdir = Yii::app()->getConfig('usertemplaterootdir'); + $standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir'); + $defaulttemplate = Yii::app()->getConfig('defaulttemplate'); if (is_dir("$usertemplaterootdir/{$templatename}/")) { return $templatename; @@ -2890,7 +2885,7 @@ function createTimingsFieldMap($surveyid, $style='full', $force_refresh=false, $ global $globalfieldmap, $aDuplicateQIDs; static $timingsFieldMap; - + $clang = Yii::app()->lang; $surveyid=sanitize_int($surveyid); @@ -3056,7 +3051,7 @@ function SetSurveyLanguage($surveyid, $language) { $CI = &get_instance(); $surveyid=sanitize_int($surveyid); - $defaultlang = $CI->config->item('defaultlang'); + $defaultlang = Yii::app()->getConfig('defaultlang'); if (isset($surveyid) && $surveyid>0) { @@ -3144,7 +3139,7 @@ function getQuestionAttributeValues($qid, $type='') if (isset($cache[$qid])) { return $cache[$qid]; } - $result = Questions::model()->findByAttributes(array('qid' => $qid)) or safe_die("Error finding question attributes"); //Checked + $result = Questions::model()->findByAttributes(array('qid' => $qid)); //Checked $row=$result->attributes; if ($row===false) // Question was deleted while running the survey { @@ -3494,7 +3489,7 @@ function questionAttributes($returnByName=false) 'caption'=>$clang->gT("Display map"), 'default'=>1 ); - + $qattributes["statistics_showgraph"]=array( 'types'=>'15ABCDEFGHIKLMNOPQRSTUWXYZ!:;|*', 'category'=>$clang->gT('Statistics'), @@ -3505,7 +3500,7 @@ function questionAttributes($returnByName=false) 'caption'=>$clang->gT("Display chart"), 'default'=>1 ); - + $qattributes["statistics_graphtype"]=array( "types"=>'15ABCDEFGHIKLNOQRSTUWXYZ!:;|*', 'category'=>$clang->gT('Statistics'), @@ -4322,6 +4317,43 @@ function html_escape($str) { return str_replace(array("\x0A","\x0D"),array(" "," "), htmlspecialchars( $str, ENT_QUOTES )); } +function db_quote_id($id) +{ + // WE DONT HAVE nor USE other thing that alfanumeric characters in the field names + // $quote = $connect->nameQuote; + // return $quote.str_replace($quote,$quote.$quote,$id).$quote; + $id = addslashes($id); + + switch (Yii::app()->db->getDriverName()) + { + case "mysqli" : + case "mysql" : + return "`".$id."`"; + break; + case "mssql_n" : + case "mssql" : + case "mssqlnative" : + case "odbc_mssql" : + return "[".$id."]"; + break; + case "postgre": + return "\"".$id."\""; + break; + default: + return "`".$id."`"; + } +} + +/** + * Escapes a text value for db + * + * @param string $value + * @return string + */ +function db_quoteall($value) +{ + return '\'' . addslashes($value) . '\''; +} // make a string safe to include in a JavaScript String parameter. function javascript_escape($str, $strip_tags=false, $htmldecode=false) { @@ -4358,17 +4390,16 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, global $maildebug, $maildebugbody; - $CI =& get_instance(); - $CI->config->load('email'); - $clang = $CI->limesurvey_lang; - $emailmethod = $CI->config->item('emailmethod'); - $emailsmtphost = $CI->config->item("emailsmtphost"); - $emailsmtpuser = $CI->config->item("emailsmtpuser"); - $emailsmtppassword = $CI->config->item("emailsmtppassword"); - $emailsmtpdebug = $CI->config->item("emailsmtpdebug"); - $emailsmtpssl = $CI->config->item("emailsmtpssl"); - $defaultlang = $CI->config->item("defaultlang"); - $emailcharset = $CI->config->item("charset"); + Yii::app()->loadConfig('email'); + $clang = Yii::app()->lang; + $emailmethod = Yii::app()->getConfig('emailmethod'); + $emailsmtphost = Yii::app()->getConfig("emailsmtphost"); + $emailsmtpuser = Yii::app()->getConfig("emailsmtpuser"); + $emailsmtppassword = Yii::app()->getConfig("emailsmtppassword"); + $emailsmtpdebug = Yii::app()->getConfig("emailsmtpdebug"); + $emailsmtpssl = Yii::app()->getConfig("emailsmtpssl"); + $defaultlang = Yii::app()->getConfig("defaultlang"); + $emailcharset = Yii::app()->getConfig("charset"); if (!is_array($to)){ $to=array($to); @@ -4380,7 +4411,7 @@ function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml=false, { $customheaders=array(); } - if ($CI->config->item('demoMode')) + if (Yii::app()->getConfig('demoMode')) { $maildebug=$clang->gT('Email was not sent because demo-mode is activated.'); $maildebugbody=''; @@ -4839,7 +4870,7 @@ function getArrayFiltersOutGroup($qid) // TODO: Check list_filter values to make sure questions are previous? global $gid; $CI = &get_instance(); - $surveyid = $CI->config->item('sid'); + $surveyid = Yii::app()->getConfig('sid'); $qid=sanitize_int($qid); $attributes = getQuestionAttributeValues($qid); @@ -4867,7 +4898,7 @@ function getArrayFiltersExcludesOutGroup($qid) // TODO: Check list_filter values to make sure questions are previous? global $gid; $CI = &get_instance(); - $surveyid = $CI->config->item('sid'); + $surveyid = Yii::app()->getConfig('sid'); $qid=sanitize_int($qid); $attributes = getQuestionAttributeValues($qid); @@ -4898,7 +4929,7 @@ function getArrayFilterExcludesForQuestion($qid) $dbprefix = $CI->db->dbprefix; // TODO: Check list_filter values to make sure questions are previous? - // $surveyid = $CI->config->item('sid'); + // $surveyid = Yii::app()->getConfig('sid'); $surveyid=returnglobal('sid'); $qid=sanitize_int($qid); @@ -5004,7 +5035,7 @@ function createPassword() function languageDropdown($surveyid,$selected) { $CI = &get_instance(); - $homeurl = $CI->config->item('homeurl'); + $homeurl = Yii::app()->getConfig('homeurl'); $slangs = GetAdditionalLanguagesFromSurveyID($surveyid); $baselang = GetBaseLanguageFromSurveyID($surveyid); array_unshift($slangs,$baselang); @@ -5195,7 +5226,7 @@ function convertCsvreturn2return($string) */ function tableExists($tablename) { - + return Yii::app()->db->schema->getTable($tablename); } @@ -5254,7 +5285,6 @@ function getBounceEmail($surveyid) // returns 'text' or 'html' function getEmailFormat($surveyid) { - $surveyInfo=getSurveyInfo($surveyid); if ($surveyInfo['htmlemail'] == 'Y') { @@ -5387,7 +5417,7 @@ function aReverseTranslateFieldnames($iOldSID,$iNewSID,$aGIDReplacements,$aQIDRe function hasResources($id,$type='survey') { $CI = &get_instance(); - $dirname = $CI->config->item("uploaddir"); + $dirname = Yii::app()->getConfig("uploaddir"); if ($type == 'survey') { @@ -5544,11 +5574,9 @@ function filterforattributes ($fieldname) function GetAttributeFieldNames($surveyid) { if (($table = Yii::app()->db->schema->getTable('{{tokens_'.$surveyid . '}}')) === false) - { return Array(); - } - $tokenfieldnames = $table->getColumnNames(); - return array_filter($tokenfieldnames,'filterforattributes'); + + return array_filter(array_keys($table->columns), 'filterforattributes'); } /** @@ -5755,7 +5783,7 @@ function GetUpdateInfo() /* Data transfer timeout */ $CI->http->data_timeout=0; $CI->http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; - $CI->http->GetRequestArguments("http://update.limesurvey.org?build=".$CI->config->item("buildnumber"),$arguments); + $CI->http->GetRequestArguments("http://update.limesurvey.org?build=".Yii::app()->getConfig("buildnumber"),$arguments); $updateinfo=false; $error=$CI->http->Open($arguments); @@ -5795,7 +5823,7 @@ function updatecheck() { $CI =& get_instance(); $updateinfo=GetUpdateInfo(); - if (isset($updateinfo['Targetversion']['build']) && (int)$updateinfo['Targetversion']['build']>(int)$CI->config->item('buildnumber') && trim($CI->config->item('buildnumber'))!='') + if (isset($updateinfo['Targetversion']['build']) && (int)$updateinfo['Targetversion']['build']>(int)Yii::app()->getConfig('buildnumber') && trim(Yii::app()->getConfig('buildnumber'))!='') { setGlobalSetting('updateavailable',1); setGlobalSetting('updatebuild',$updateinfo['Targetversion']['build']); @@ -5858,26 +5886,26 @@ function sGetTemplatePath($sTemplateName) if (isStandardTemplate($sTemplateName)) { - return $CI->config->item("standardtemplaterootdir").'/'.$sTemplateName; + return Yii::app()->getConfig("standardtemplaterootdir").'/'.$sTemplateName; } else { - if (file_exists($CI->config->item("usertemplaterootdir").'/'.$sTemplateName)) + if (file_exists(Yii::app()->getConfig("usertemplaterootdir").'/'.$sTemplateName)) { - return $CI->config->item("usertemplaterootdir").'/'.$sTemplateName; + return Yii::app()->getConfig("usertemplaterootdir").'/'.$sTemplateName; } - elseif (file_exists($CI->config->item("usertemplaterootdir").'/'.$CI->config->item('defaulttemplate'))) + elseif (file_exists(Yii::app()->getConfig("usertemplaterootdir").'/'.Yii::app()->getConfig('defaulttemplate'))) { - return $CI->config->item("usertemplaterootdir").'/'.$CI->config->item('defaulttemplate'); + return Yii::app()->getConfig("usertemplaterootdir").'/'.Yii::app()->getConfig('defaulttemplate'); } - elseif (file_exists($CI->config->item("standardtemplaterootdir").'/'.$CI->config->item('defaulttemplate'))) + elseif (file_exists(Yii::app()->getConfig("standardtemplaterootdir").'/'.Yii::app()->getConfig('defaulttemplate'))) { - return $CI->config->item("standardtemplaterootdir").'/'.$CI->config->item('defaulttemplate'); + return Yii::app()->getConfig("standardtemplaterootdir").'/'.Yii::app()->getConfig('defaulttemplate'); } else { - return $$CI->config->item("standardtemplaterootdir").'/default'; + return $Yii::app()->getConfig("standardtemplaterootdir").'/default'; } } } @@ -5892,25 +5920,25 @@ function sGetTemplateURL($sTemplateName) $CI = &get_instance(); if (isStandardTemplate($sTemplateName)) { - return $CI->config->item("standardtemplaterooturl").'/'.$sTemplateName; + return Yii::app()->getConfig("standardtemplaterooturl").'/'.$sTemplateName; } else { - if (file_exists($CI->config->item("usertemplaterootdir").'/'.$sTemplateName)) + if (file_exists(Yii::app()->getConfig("usertemplaterootdir").'/'.$sTemplateName)) { - return $CI->config->item("usertemplaterooturl").'/'.$sTemplateName; + return Yii::app()->getConfig("usertemplaterooturl").'/'.$sTemplateName; } - elseif (file_exists($CI->config->item("usertemplaterootdir").'/'.$CI->config->item('defaulttemplate'))) + elseif (file_exists(Yii::app()->getConfig("usertemplaterootdir").'/'.Yii::app()->getConfig('defaulttemplate'))) { - return $CI->config->item("usertemplaterooturl").'/'.$CI->config->item('defaulttemplate'); + return Yii::app()->getConfig("usertemplaterooturl").'/'.Yii::app()->getConfig('defaulttemplate'); } - elseif (file_exists($CI->config->item("standardtemplaterootdir").'/'.$CI->config->item('defaulttemplate'))) + elseif (file_exists(Yii::app()->getConfig("standardtemplaterootdir").'/'.Yii::app()->getConfig('defaulttemplate'))) { - return $CI->config->item("standardtemplaterooturl").'/'.$CI->config->item('defaulttemplate'); + return Yii::app()->getConfig("standardtemplaterooturl").'/'.Yii::app()->getConfig('defaulttemplate'); } else { - return $CI->config->item("standardtemplaterooturl").'/default'; + return Yii::app()->getConfig("standardtemplaterooturl").'/default'; } } } @@ -6466,7 +6494,7 @@ function checkquestionfordisplay($qid, $gid=null) // TMSW Conditions->Relevance: not needed (only check relevance) global $thissurvey; $CI = &get_instance(); - $surveyid = $CI->config->item('sid'); + $surveyid = Yii::app()->getConfig('sid'); if (!is_array($thissurvey)) { @@ -7069,9 +7097,9 @@ function access_denied($action,$sid='') $clang = Yii::app()->lang; if (Yii::app()->session['loginID']) { - $ugid = $CI->config->item('ugid'); + $ugid = Yii::app()->getConfig('ugid'); $accesssummary = "

    ".$clang->gT("Access denied!")."
    \n"; - $scriptname = $CI->config->item('scriptname'); + $scriptname = Yii::app()->getConfig('scriptname'); //$action=returnglobal('action'); if ( $action == "dumpdb" ) { @@ -7663,9 +7691,7 @@ function GetQuestDepsForConditions($sid,$gid="all",$depqid="all",$targqid="all", */ function checkMovequestionConstraintsForConditions($sid,$qid,$newgid="all") { - $CI =& get_instance(); - $CI->load->helper('database'); - $clang = $CI->limesurvey_lang; + $clang = Yii::app()->lang; $resarray=Array(); $resarray['notAbove']=null; // defaults to no constraint $resarray['notBelow']=null; // defaults to no constraint @@ -7688,19 +7714,19 @@ function checkMovequestionConstraintsForConditions($sid,$qid,$newgid="all") $condquery = "SELECT tq.qid as depqid, tq.gid as depgid, tg.group_order as depgorder, " . "tq2.qid as targqid, tq2.gid as targgid, tg2.group_order as targgorder, " . "tc.cid FROM " - . $CI->db->dbprefix."conditions AS tc, " - . $CI->db->dbprefix."questions AS tq, " - . $CI->db->dbprefix."questions AS tq2, " - . $CI->db->dbprefix."groups AS tg, " - . $CI->db->dbprefix."groups AS tg2 " + . "{{conditions}} AS tc, " + . "{{questions}} AS tq, " + . "{{questions}} AS tq2, " + . "{{groups}} AS tg, " + . "{{groups}} AS tg2 " . "WHERE tq.language='{$baselang}' AND tq2.language='{$baselang}' AND tc.qid = tq.qid AND tq.sid=$sid " . "AND tq2.qid=tc.cqid AND tg.gid=tq.gid AND tg2.gid=tq2.gid AND tq.qid=$qid ORDER BY tg2.group_order DESC"; - $condresult=db_execute_assoc($condquery); // or safe_die($connect->ErrorMsg()); //Checked + $condresult=Yii::app()->db->createCommand($condquery)->query(); // or safe_die($connect->ErrorMsg()); //Checked - if ($condresult->num_rows() > 0) { + if ($condresult->getRowCount() > 0) { - foreach ($condresult->result_array() as $condrow ) + foreach ($condresult->readAll() as $condrow ) { // This Question can go up to the minimum GID on the 1st row $depqid=$condrow['depqid']; @@ -7728,19 +7754,19 @@ function checkMovequestionConstraintsForConditions($sid,$qid,$newgid="all") // Secondly look for 'questions dependent on me': questions that have conditions on my answers $condquery = "SELECT tq.qid as depqid, tq.gid as depgid, tg.group_order as depgorder, " . "tq2.qid as targqid, tq2.gid as targgid, tg2.group_order as targgorder, " - . "tc.cid FROM ".$CI->db->dbprefix."conditions AS tc, " - . $CI->db->dbprefix."questions AS tq, " - . $CI->db->dbprefix."questions AS tq2, " - . $CI->db->dbprefix."groups AS tg, " - . $CI->db->dbprefix."groups AS tg2 " + . "tc.cid FROM {{conditions}} AS tc, " + . "{{questions}} AS tq, " + . "{{questions}} AS tq2, " + . "{{groups}} AS tg, " + . "{{groups}} AS tg2 " . "WHERE tq.language='{$baselang}' AND tq2.language='{$baselang}' AND tc.qid = tq.qid AND tq.sid=$sid " . "AND tq2.qid=tc.cqid AND tg.gid=tq.gid AND tg2.gid=tq2.gid AND tq2.qid=$qid ORDER BY tg.group_order"; - $condresult=db_execute_assoc($condquery); // or safe_die($connect->ErrorMsg()); //Checked + $condresult=Yii::app()->db->createCommand($condquery)->query(); // or safe_die($connect->ErrorMsg()); //Checked - if ($condresult->num_rows() > 0) { + if ($condresult->getRowCount() > 0) { - foreach ($condresult->result_array() as $condrow) + foreach ($condresult->readAll() as $condrow) { // This Question can go down to the maximum GID on the 1st row $depqid=$condrow['depqid']; @@ -7899,11 +7925,11 @@ function modify_database($sqlfile='', $sqlstring='') $line = substr($line, 0, $length-1); // strip ; $command .= $line; $command = str_replace('prefix_', $CI->db->dbprefix, $command); // Table prefixes - $command = str_replace('$defaultuser', $CI->config->item('defaultuser'), $command); - $command = str_replace('$defaultpass', $CI->sha256->hashing($CI->config->item('defaultpass')), $command); + $command = str_replace('$defaultuser', Yii::app()->getConfig('defaultuser'), $command); + $command = str_replace('$defaultpass', $CI->sha256->hashing(Yii::app()->getConfig('defaultpass')), $command); $command = str_replace('$siteadminname', $siteadminname, $command); $command = str_replace('$siteadminemail', $siteadminemail, $command); - $command = str_replace('$defaultlang', $CI->config->item('defaultlang'), $command); + $command = str_replace('$defaultlang', Yii::app()->getConfig('defaultlang'), $command); $command = str_replace('$sessionname', 'ls'.sRandomChars(20,'123456789'), $command); $command = str_replace('$databasetabletype', $CI->db->dbdriver, $command); @@ -7964,7 +7990,7 @@ function getHeader($meta = false) global $embedded; $CI =& get_instance(); - $surveyid = $CI->config->item('sid'); + $surveyid = Yii::app()->getConfig('sid'); $CI->load->helper('surveytranslator'); $clang = $CI->limesurvey_lang; @@ -7978,13 +8004,13 @@ function getHeader($meta = false) } else { - $surveylanguage=$CI->config->item('defaultlang'); + $surveylanguage=Yii::app()->getConfig('defaultlang'); } $js_header = ''; $css_header=''; - if($CI->config->item("js_admin_includes")) + if(Yii::app()->getConfig("js_admin_includes")) { - foreach ($CI->config->item("js_admin_includes") as $jsinclude) + foreach (Yii::app()->getConfig("js_admin_includes") as $jsinclude) { if (substr($jsinclude,0,4) == 'http') $js_header .= "\n"; @@ -7992,9 +8018,9 @@ function getHeader($meta = false) $js_header .= "\n"; } } - if($CI->config->item("css_admin_includes")) + if(Yii::app()->getConfig("css_admin_includes")) { - foreach ($CI->config->item("css_admin_includes") as $cssinclude) + foreach (Yii::app()->getConfig("css_admin_includes") as $cssinclude) { $css_header .= "\n"; } @@ -8010,10 +8036,10 @@ function getHeader($meta = false) } $header.= ">\n\t\n" . $css_header - . "\n" - . "\n" - . "config->item('generalscripts')."jquery/css/start/jquery-ui.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />" - . "config->item('generalscripts')."jquery/css/start/lime-progress.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />" + . "\n" + . "\n" + . "getConfig('generalscripts')."jquery/css/start/jquery-ui.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />" + . "getConfig('generalscripts')."jquery/css/start/lime-progress.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />" . $js_header; if ($meta) diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index a78ebc132b6..8a78c14e384 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -141,17 +141,36 @@ public static function RevertUpgradeConditionsToRelevance($surveyId=NULL, $qid=N */ public static function ConvertConditionsToRelevance($surveyId=NULL, $qid=NULL) { - $CI =& get_instance(); - $CI->load->model('conditions_model'); - - $query = $CI->conditions_model->getAllRecordsForSurvey($surveyId,$qid); + if (!is_null($qid)) { + $where = " c.qid = ".$qid." and "; + } + else if (!is_null($surveyid)) { + $where = " c.qid in (select qid from ".$this->db->dbprefix('questions')." where sid = ".$surveyid.") and "; + } + else { + $where = ""; + } + $query = "select distinct c.*" + .", q.sid, q.type" + ." from {{conditions}} as c" + .", {{questions}} as q" + ." where " . $where + ." c.cqid=q.qid" + ." union " + ." select c.*, q.sid, '' as type" + ." from {{conditions}} as c" + .", {{questions}} as q" + ." where ". $where + ." c.cqid = 0 and c.qid = q.qid" + ." order by sid, qid, scenario, cqid, cfieldname, value"; + $query = Yii::app()->db->createCommand($query)->query(); $_qid = -1; $relevanceEqns = array(); $scenarios = array(); $relAndList = array(); $relOrList = array(); - foreach($query->result_array() as $row) + foreach($query->readAll() as $row) { if ($row['qid'] != $_qid) { diff --git a/application/views/admin/survey/subview/tabPresentation_view.php b/application/views/admin/survey/subview/tabPresentation_view.php index 8d82300ef7a..7b0f4f97ad6 100644 --- a/application/views/admin/survey/subview/tabPresentation_view.php +++ b/application/views/admin/survey/subview/tabPresentation_view.php @@ -237,8 +237,8 @@ }; ?>

  • gT('Hide both (Forced by the system administrator)'); ?> " size="70" /> - break; - '' , 'D' => '' , 'N' => '' , 'X' => '' ); if (isset($esrow['showgroupinfo'])) { @@ -285,10 +286,10 @@ }; ?>