Skip to content

Commit

Permalink
Dev: code inspection application/helpers - undefined variables & meth…
Browse files Browse the repository at this point in the history
…ods (#722)

Dev:  code inspection application/helpers - method not found
Dev:  code inspection application/helpers - undefined variables
Dev:  code inspection application/helpers - undefined variables
Dev:  code inspection application/helpers - undefined variables
Dev:  code inspection application/helpers - undefined variables
Dev:  code inspection application/helpers - undefined variables
Dev:  code inspection application/helpers - undefined variables
  • Loading branch information
TonisOrmisson authored and LouisGac committed Jun 23, 2017
1 parent 5dc9445 commit 77b8d6a
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 36 deletions.
2 changes: 1 addition & 1 deletion application/core/Survey_Common_Action.php
Expand Up @@ -1251,7 +1251,7 @@ public function _surveysummary($aData)

//return (array('column'=>array($columns_used,$hard_limit) , 'size' => array($length, $size_limit) ));
// $aData['tableusage'] = getDBTableUsage($iSurveyID);
// ToDo: Table usage is calculated on every menu display which is too slow with bug surveys.
// ToDo: Table usage is calculated on every menu display which is too slow with big surveys.
// Needs to be moved to a database field and only updated if there are question/subquestions added/removed (it's currently also not functional due to the port)
//

Expand Down
19 changes: 12 additions & 7 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -91,7 +91,7 @@ public function run($surveyid,$args)
$this->makeLanguageChanger(); // language changer can be used on any entry screen, so it must be set first

extract($args);
$this->param = $param;
//$this->param = $param;

///////////////////////////////////////////////////////////
// 1: We check if token and/or captcha form shouls be shown
Expand Down Expand Up @@ -1648,7 +1648,7 @@ private function setSurveySettings( $surveyid, $args )
extract($args);

$this->LEMsessid = 'survey_' . $this->iSurveyid;
$this->aSurveyInfo = (!$thissurvey)?getSurveyInfo($this->iSurveyid):$thissurvey;
$this->aSurveyInfo = getSurveyInfo($this->iSurveyid);
$this->aSurveyInfo['surveyUrl'] = App()->createUrl("/survey/index",array("sid"=>$this->iSurveyid));

// TODO: check this:
Expand All @@ -1673,6 +1673,7 @@ private function setPreview()
}

if ($this->sSurveyMode == 'group' && $this->previewgrp){
// FIXME $param not defined
$_gid = sanitize_int($param['gid']);

LimeExpressionManager::StartSurvey($this->aSurveyInfo['sid'], 'group', $this->aSurveyOptions, false, $this->LEMdebugLevel);
Expand All @@ -1697,11 +1698,15 @@ private function setPreview()
$groupdescription = $this->groupdescription = $this->aStepInfo['gtext'];

}elseif($this->sSurveyMode == 'question' && $this->previewquestion){
$_qid = sanitize_int($param['qid']);
LimeExpressionManager::StartSurvey($this->iSurveyid, 'question', $this->aSurveyOptions, false, $this->LEMdebugLevel);
$qSec = LimeExpressionManager::GetQuestionSeq($_qid);
$this->aMoveResult= LimeExpressionManager::JumpTo($qSec+1,true,false,true);
$this->aStepInfo = LimeExpressionManager::GetStepIndexInfo($this->aMoveResult['seq']);
/**
FIXME $param not defined
*/
$_qid = sanitize_int($param['qid']);

LimeExpressionManager::StartSurvey($this->iSurveyid, 'question', $this->aSurveyOptions, false, $this->LEMdebugLevel);
$qSec = LimeExpressionManager::GetQuestionSeq($_qid);
$this->aMoveResult= LimeExpressionManager::JumpTo($qSec+1,true,false,true);
$this->aStepInfo = LimeExpressionManager::GetStepIndexInfo($this->aMoveResult['seq']);
}
}

Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/activate_helper.php
Expand Up @@ -426,7 +426,7 @@ function activateSurvey($iSurveyID, $simulate = false)
}

if ($simulate){
return array('dbengine'=>$CI->db->databasetabletype, 'dbtype'=>Yii::app()->db->driverName, 'fields'=>$arrSim);
return array('dbengine'=>Yii::app()->db->getDriverName(), 'dbtype'=>Yii::app()->db->driverName, 'fields'=>$arrSim);
}

// If last question is of type MCABCEFHP^QKJR let's get rid of the ending coma in createsurvey
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/export/SurveyDao.php
Expand Up @@ -37,7 +37,7 @@ public function loadSurveyById($id, $lang = null)
if (empty($intId))
{
//The id given to us is not an integer, croak.
safeDie("An invalid survey ID was encountered: $sid");
safeDie("An invalid survey ID was encountered");
}

//Load groups
Expand Down
1 change: 1 addition & 0 deletions application/helpers/admin/export/Writer.php
Expand Up @@ -9,6 +9,7 @@
abstract class Writer implements IWriter
{
protected $sLanguageCode;
/** @var Translator $translator */
protected $translator;
public $filename;
public $webfilename;
Expand Down
16 changes: 12 additions & 4 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -792,6 +792,9 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strlen($rt)), 3);

//select details for this question
/**
FIXME $iQuestionIDlength not defined!!
*/
$nresult = Question::model()->find('language=:language AND parent_qid=0 AND qid=:qid', array(':language'=>$language, ':qid'=>substr($qqid, 0, $iQuestionIDlength)));
$qtitle=$nresult->title;
$qtype=$nresult->type;
Expand Down Expand Up @@ -1596,6 +1599,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
* @param string $outputType
* @param integer $usegraph
* @param boolean $browse
* @return array
*/
protected function displaySimpleResults($outputs, $results, $rt, $outputType, $surveyid, $sql, $usegraph, $browse, $sLanguage)
{
Expand All @@ -1604,6 +1608,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
$statisticsoutput="";
$sDatabaseType = Yii::app()->db->getDriverName();
$astatdata=array();
$sColumnName = null;

//loop though the array which contains all answer data
$ColumnName_RM=array();
Expand Down Expand Up @@ -2259,15 +2264,16 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
$cachefilename = '';
if($outputType == 'xls' || $outputType == 'pdf')
{
/**
*
//FIXME $MyCache is undefined
$cachefilename = createChart($qqid, $qsid, $bShowPieChart, $lbl, $gdata, $grawdata, $MyCache, $sLanguage, $outputs['qtype']);
*
*/
}

}
}
else
{

}


if(isset($aattr["statistics_graphtype"]))
Expand Down Expand Up @@ -2386,6 +2392,8 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
$tempdir = Yii::app()->getConfig("tempdir");
$astatdata = array();

$sColumnName = null;

if ($usegraph==1 && $outputType != 'html')
{
//for creating graphs we need some more scripts which are included here
Expand Down
38 changes: 17 additions & 21 deletions application/helpers/common_helper.php
Expand Up @@ -2974,7 +2974,8 @@ function getArrayFilterExcludesCascadesForGroup($surveyid, $gid="", $output="qid

/**
* getArrayFiltersForQuestion($qid) finds out if a question has an array_filter attribute and what codes where selected on target question
* @return returns an array of codes that were selected else returns false
* @return array an array of codes that were selected else returns false
* @deprecated not used
*/
function getArrayFiltersForQuestion($qid)
{
Expand All @@ -2991,6 +2992,7 @@ function getArrayFiltersForQuestion($qid)
{
if ($fields[2] == $val)
{
/** Broken code below ...
// we found the target question, now we need to know what the answers where, we know its a multi!
$fields[0]=sanitize_int($fields[0]);
//$query = "SELECT title FROM ".db_table_name('questions')." where parent_qid='{$fields[0]}' AND language='".Yii::app()->session[$surveyid]['s_lang']."' order by question_order";
Expand All @@ -3003,6 +3005,8 @@ function getArrayFiltersForQuestion($qid)
|| Yii::app()->session[$fields[1]] == $code['title']) array_push($selected,$code['title']);
}
*/

//Now we also need to find out if (a) the question had "other" enabled, and (b) if that was selected
//$query = "SELECT other FROM ".db_table_name('questions')." where qid='{$fields[0]}'";
$qresult=Question::model()->findAllByAttributes(array("qid"=>$fields[0]));
Expand All @@ -3024,15 +3028,16 @@ function getArrayFiltersForQuestion($qid)

/**
* getGroupsByQuestion($surveyid)
* @return returns a keyed array of groups to questions ie: array([1]=>[2]) question qid 1, is in group gid 2.
* @return array a keyed array of groups to questions ie: array([1]=>[2]) question qid 1, is in group gid 2.
* @deprecated not used
*/
function getGroupsByQuestion($surveyid) {
$output=array();

$surveyid=sanitize_int($surveyid);
$result=Question::model()->findAllByAttributes(array("sid"=>$surveyid));

foreach ($qresult->readAll() as $val)
foreach ($result->readAll() as $val)
{
$output[$val['qid']]=$val['gid'];
}
Expand Down Expand Up @@ -4251,30 +4256,21 @@ function isNumericInt($mStr)
*/
function short_implode($sDelimeter, $sHyphen, $aArray)
{
if (sizeof($aArray) < Yii::app()->getConfig('minlengthshortimplode'))
{
if (sizeof($aArray) < Yii::app()->getConfig('minlengthshortimplode')) {
sort($aArray);
return implode($sDelimeter, $aArray);
}
else
{
} else {
sort($aArray);
$iIndexA = 0;
$iIndexB = 1;
while ($iIndexA < sizeof($aArray))
{
if ($iIndexA == 0)
{
$sResult = null;
while ($iIndexA < sizeof($aArray)) {
if ($iIndexA == 0) {
$sResult = $aArray[$iIndexA];
}
else
{
if (strlen($sResult) > Yii::app()->getConfig('maxstringlengthshortimplode') - strlen($sDelimeter) - 3)
{
} else {
if (strlen($sResult) > Yii::app()->getConfig('maxstringlengthshortimplode') - strlen($sDelimeter) - 3) {
return $sResult.$sDelimeter.'...';
}
else
{
} else {
$sResult = $sResult.$sDelimeter.$aArray[$iIndexA];
}
}
Expand Down Expand Up @@ -5640,7 +5636,7 @@ function getDBTableUsage($surveyid){
$length = $length + 8;
break;
case 'L':
$legth++;
$length++;
break;
case 'I':
case 'I4':
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/expressions/em_core_helper.php
Expand Up @@ -499,7 +499,7 @@ public function RDP_Evaluate($expr, $onlyparse=false)
}
else
{
$this-RDP_AddError(self::gT("Unbalanced equation - values left on stack"),NULL);
$this->RDP_AddError(self::gT("Unbalanced equation - values left on stack"),NULL);
return false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions application/helpers/qanda_helper.php
Expand Up @@ -712,9 +712,13 @@ function return_display_style($ia, $aQuestionAttributes, $thissurvey, $rowname)
* @param integer $surveyid : the survey id
* @param string $subquestionName : the target name
* @param array $aQuestionAttributes : the attribute of the question (for array_filter_style actually)
* @deprecated not used & broken
*/
function getExpressionManagerClass($surveyid,$subquestionName,$aQuestionAttributes=null)
{
/**
FIXME $rowname not defined!!
*/
if (isset($_SESSION["survey_{$surveyid}"]['relevanceStatus'][$rowname]) && !$_SESSION["survey_{$surveyid}"]['relevanceStatus'][$rowname])
{

Expand Down
1 change: 1 addition & 0 deletions application/helpers/remotecontrol/remotecontrol_handle.php
Expand Up @@ -1318,6 +1318,7 @@ public function delete_question($sSessionKey, $iQuestionID)
*/
public function import_question($sSessionKey, $iSurveyID,$iGroupID, $sImportData, $sImportDataType, $sMandatory='N', $sNewQuestionTitle=NULL, $sNewqQuestion=NULL, $sNewQuestionHelp=NULL)
{
$bOldEntityLoaderState = null;
if ($this->_checkSessionKey($sSessionKey))
{
$oSurvey = Survey::model()->findByPk($iSurveyID);
Expand Down
1 change: 1 addition & 0 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -1347,6 +1347,7 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
$plugin->name = 'Authwebserver';
$plugin->active = 1;
$plugin->save();
/** @var Authwebserver $plugin */
$plugin = App()->getPluginManager()->loadPlugin('Authwebserver', $plugin->id);
$aPluginSettings = $plugin->getPluginSettings(true);
$aDefaultSettings = array();
Expand Down
5 changes: 5 additions & 0 deletions application/helpers/userstatistics_helper.php
Expand Up @@ -788,6 +788,9 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strlen($rt)), 3);

//select details for this question
/**
FIXME $iQuestionIDlength not defined!!
*/
$nresult = Question::model()->find('language=:language AND parent_qid=0 AND qid=:qid', array(':language'=>$language, ':qid'=>substr($qqid, 0, $iQuestionIDlength)));
$qtitle=$nresult->title;
$qtype=$nresult->type;
Expand Down Expand Up @@ -1594,6 +1597,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
* @param mixed $sql
* @param integer $usegraph
* @param boolean $browse
* @return array
*/
protected function displayResults($outputs, $results, $rt, $outputType, $surveyid, $sql, $usegraph, $browse, $sLanguage) {

Expand All @@ -1604,6 +1608,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
$tempdir = Yii::app()->getConfig("tempdir");
$tempurl = Yii::app()->getConfig("tempurl");
$astatdata=array();
$sColumnName = null;
if ($usegraph==1)
{
//for creating graphs we need some more scripts which are included here
Expand Down

0 comments on commit 77b8d6a

Please sign in to comment.