Skip to content

Commit

Permalink
Dev: some scrutinizer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 14, 2016
1 parent d09e6d4 commit 442b6be
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 46 deletions.
4 changes: 2 additions & 2 deletions application/config/internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
$userConfig = require(dirname(__FILE__) . '/config.php');
}

if (! @date_default_timezone_set(@date_default_timezone_get()))
if (! date_default_timezone_set(@date_default_timezone_get()))
{

@date_default_timezone_set('Europe/London');
date_default_timezone_set('Europe/London');
}


Expand Down
3 changes: 2 additions & 1 deletion application/controllers/admin/conditionsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,8 @@ function index($subaction, $iSurveyID=null, $gid=null, $qid=null)
$subaction == "editthiscondition" || $subaction == "delete")
{
$mytitle = ($subaction == "editthiscondition" && isset($p_cid))?gT("Edit condition"):gT("Add condition");
$showScenario = ( ( $subaction != "editthiscondition" && isset($scenariocount) && ($scenariocount == 1 || $scenariocount==0)) || ( $subaction == "editthiscondition" && isset($scenario) && $scenario == 1) )?true:false;
$scenario = (isset($scenario))?$scenario:'';
$showScenario = ( ( $subaction != "editthiscondition" && isset($scenariocount) && ($scenariocount == 1 || $scenariocount==0)) || ( $subaction == "editthiscondition" && $scenario == 1) )?true:false;

$aDataEditconditions = array(
'subaction'=>$subaction,
Expand Down
26 changes: 21 additions & 5 deletions application/controllers/admin/dataentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,17 +566,14 @@ public function editdata($subaction, $id, $surveyid, $language='')
'access_code' => $password)
);

$saver = array();
foreach($svresult as $svrow)
{
$saver['email'] = $svrow['email'];
$saver['scid'] = $svrow['scid'];
$saver['ip'] = $svrow['ip'];
}

if(!isset($saver) || !array_key_exists('scid', $saver))
{
$saver['scid'] = '';
}
$svresult = SavedControl::model()->findAllByAttributes(array('scid'=>$saver['scid']));
foreach($svresult as $svrow)
{
Expand Down Expand Up @@ -1391,6 +1388,7 @@ public function editdata($subaction, $id, $surveyid, $language='')
*/
public function delete()
{
$surveyid= '';
if (isset($_REQUEST['surveyid']) && !empty($_REQUEST['surveyid']))
{
$surveyid = $_REQUEST['surveyid'];
Expand Down Expand Up @@ -2295,10 +2293,28 @@ public function view($surveyid, $lang=NULL)

$lquery = "SELECT question, title FROM {{questions}} WHERE parent_qid={$deqrow['qid']} and scale_id=1 and language='{$sDataEntryLanguage}' ORDER BY question_order";
$lresult=dbExecuteAssoc($lquery) or die ("Couldn't get labels, Type \":\"<br />$lquery<br />");

$lresult=dbExecuteAssoc($lquery);
if( !$lresult)
{
$eMessage = "Couldn't get labels, Type \":\"<br />$lquery<br />";
Yii::app()->setFlashMessage($eMessage );
$this->getController()->redirect($this->getController()->createUrl("/admin/"));
}


$cdata['lresult'] = $lresult->readAll();

$meaquery = "SELECT question, title FROM {{questions}} WHERE parent_qid={$deqrow['qid']} and scale_id=0 and language='{$sDataEntryLanguage}' ORDER BY question_order";
$mearesult=dbExecuteAssoc($meaquery) or die ("Couldn't get answers, Type \":\"<br />$meaquery<br />");
$mearesult=dbExecuteAssoc($meaquery);

if( !$mearesult)
{
$eMessage = "Couldn't get answers, Type \":\"<br />$meaquery<br />";
Yii::app()->setFlashMessage($eMessage );
$this->getController()->redirect($this->getController()->createUrl("/admin/"));
}

$cdata['mearesult'] = $mearesult->readAll();

break;
Expand Down
2 changes: 0 additions & 2 deletions application/controllers/admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,6 @@ public function dumplabel()

/**
* Export multiple surveys structure. Called via ajax from surveys list massive action
* @param string $sSurveys :json string containing the list of survey to delete
*/
public function exportMultipleStructureSurveys()
{
Expand All @@ -899,7 +898,6 @@ public function exportMultipleStructureSurveys()

/**
* Export multiple surveys archives. Called via ajax from surveys list massive action
* @param string $sSurveys :json string containing the list of survey to delete
*/
public function exportMultipleArchiveSurveys()
{
Expand Down
9 changes: 2 additions & 7 deletions application/controllers/admin/questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,6 @@ public function getSubquestionRow( $surveyid, $gid, $qid, $codes, $language, $fi

// TODO: calcul correct value
$oldCode = false;
$position = $position;
$scale_id = $scale_id ;


// We get the numerical part of each code and we store them in Arrays
Expand Down Expand Up @@ -944,7 +942,7 @@ public function getSubquestionRow( $surveyid, $gid, $qid, $codes, $language, $fi
// Let's get the greatest code
$greatestNumCode = max ($numCodes); // greatest code
$key = array_keys($numCodes, max($numCodes)); // its key (same key in all tables)
$greatesNumCodeWithZeros = $numCodesWithZero[$key[0]]; // its value with prefixed 0 (like : 001)
$greatesNumCodeWithZeros = (isset($numCodesWithZero))?$numCodesWithZero[$key[0]]:''; // its value with prefixed 0 (like : 001)
$stringCodeOfGreatestCode = $stringCodes[$key[0]]; // its original submited string (like: SQ001)

// We get the string part of it: it's the original string code, without the greates code with its 0 :
Expand Down Expand Up @@ -1133,9 +1131,6 @@ public function newquestion($surveyid)
// sidemenu
$aData['sidemenu']['state'] = false;
$aData['sidemenu']['explorer']['state'] = true;
$aData['sidemenu']['explorer']['gid'] = (isset($gid))?$gid:false;
$aData['sidemenu']['explorer']['qid'] = (isset($qid))?$qid:false;

$this->_renderWrappedTemplate('survey/Question', $aViewUrls, $aData);
}

Expand Down Expand Up @@ -1570,7 +1565,7 @@ public function setMultipleQuestionGroup()
{
// Question basic infos
$aQidAndLang = explode(',', $sQidAndLang);
$iQid = $aQidAndLang[0];
$iQid = $aQidAndLang[0];

$oQuestion = Question::model()->findByAttributes(array('qid' => $iQid)); // Question object
$oldGid = $oQuestion->gid; // The current GID of the question
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/surveyadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ public function copy()
{
// Start the HTML
$sExtension = "";

if ($action == 'importsurvey')
{
$aData = array();
Expand All @@ -932,7 +932,7 @@ public function copy()
}
// Start traitment and messagebox
$aData['bFailed'] = false; // Put a var for continue

$sFullFilepath = '';
if ($action == 'importsurvey')
{

Expand Down
1 change: 1 addition & 0 deletions application/core/LSWebUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function isInUserGroup($gid)
return false;

$users = $oUsergroup->users;
$aUids = array();
foreach($users as $user)
{
$aUids[]=$user->uid;
Expand Down
4 changes: 2 additions & 2 deletions application/core/Survey_Common_Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function _showHeaders($aData)
* @global string $surveyid
* @global string $setfont
* @global string $imageurl
* @param int $surveyid
* @global int $surveyid
* @return string $adminmenu
*/
public function _showadminmenu()
Expand Down Expand Up @@ -882,7 +882,7 @@ function _surveybar($aData)
$aForbiddenWordsInUrl[]='editlocalsettings';
$aForbiddenWordsInUrl[]='setsurveysecurity';
$aForbiddenWordsInUrl[]='importsurveyresources';
$aForbiddenWordsInUrl[]='newquestion';
$aForbiddenWordsInUrl[]='newquestion';
$aForbiddenWordsInUrl[]='add';
$aData['surveybar']['closebutton']['url'] = Yii::app()->request->getUrlReferrer( Yii::app()->createUrl($sAlternativeUrl), $aForbiddenWordsInUrl );
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/template_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function gettemplatefilename($template, $templatefile) {
// Something else
else
{
$oEditedTemplate = Template::model()->getTemplateConfiguration($templatename);
$oEditedTemplate = Template::model()->getTemplateConfiguration($template);
return $template.'/'.$oEditedTemplate->viewPath.'/'.$templatefile;
}
break;
Expand Down
1 change: 1 addition & 0 deletions application/helpers/frontend_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function makeLanguageChangerSurvey($sSelectedLanguage)
$route="/survey/index/sid/{$surveyid}";
}
$sTargetURL=Yii::app()->getController()->createUrl($route);
$aListLang = array();
foreach ($aSurveyLangs as $sLangCode => $aSurveyLang)
{
$aListLang[$sLangCode]=html_entity_decode($aSurveyLang['nativedescription'], ENT_COMPAT,'UTF-8');
Expand Down
41 changes: 21 additions & 20 deletions application/helpers/qanda_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ function do_date($ia)
$dateorder = preg_split('/([-\.\/ :])/', $dateformatdetails['phpdate'],-1,PREG_SPLIT_DELIM_CAPTURE );

$sRows = '';
$montharray = array();
foreach($dateorder as $datepart)
{
switch($datepart)
Expand Down Expand Up @@ -1399,7 +1400,7 @@ function do_list_dropdown($ia)
//Time Limit Code
if (trim($aQuestionAttributes['time_limit'])!='')
{
$sselect .= return_timer_script($aQuestionAttributes, $ia);
$sselect = return_timer_script($aQuestionAttributes, $ia);
}
//End Time Limit Code

Expand Down Expand Up @@ -1446,6 +1447,7 @@ function do_list_radio($ia)
$iRowCount = 0;
$isOpen = false; // Is a column opened

$iColumnWidth = '';
if ($iNbCols > 1)
{
// First we calculate the width of each column
Expand Down Expand Up @@ -1677,11 +1679,7 @@ function do_listwithcomment($ia)
$checkconditionFunction = "checkconditions";
$iSurveyId = Yii::app()->getConfig('surveyID'); // survey id
$sSurveyLang = $_SESSION['survey_'.$iSurveyId]['s_lang']; // survey language

if (!isset($maxoptionsize))
{
$maxoptionsize=35;
}
$maxoptionsize = 35;


$aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]); // Question attribute variables
Expand Down Expand Up @@ -1717,6 +1715,7 @@ function do_listwithcomment($ia)
}

// ==> rows
$check_ans = '';
if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
{
if ((!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '') ||($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == ' ' ))
Expand Down Expand Up @@ -1907,7 +1906,8 @@ function do_ranking($ia)
}

$inputnames = array();
$sSelects = '';
$sSelects = '';
$myfname = '';

for ($i=1; $i<=$iMaxLine; $i++)
{
Expand Down Expand Up @@ -1990,7 +1990,7 @@ function do_ranking($ia)
'thisvalue' => $thisvalue,
'answers' => $answers,
'myfname' => $myfname,
'labeltext' => $labeltext,
'labeltext' => (isset($labeltext))?$labeltext:'',
'rankId' => $ia[0],
'rankingName' => $ia[1],
'max_answers' => $max_answers,
Expand Down Expand Up @@ -2117,8 +2117,9 @@ function do_multiplechoice($ia)
if($iNbCols > 1 && $iRowCount == 1 )
{
$sRows .= doRender('/survey/questions/multiplechoice/columns/column_header', array(
'iColumnWidth' => $iColumnWidth,
'first' => $first), true);
'iColumnWidth' => (isset($iColumnWidth))?$iColumnWidth:'',
'first' => (isset($first ))?$first:''),
true);
$isOpen = true; // If a column is not closed, it will be closed at the end of the process
$first = false; // The row containing the column has been opened at the first call.
}
Expand Down Expand Up @@ -2208,7 +2209,7 @@ function do_multiplechoice($ia)
// Display the answer row
$sRows .= doRender('/survey/questions/multiplechoice/rows/answer_row_other', array(
'myfname' => $myfname,
'sDisplayStyle' => $sDisplayStyle,
'sDisplayStyle' => (isset($sDisplayStyle))?$sDisplayStyle:'',
'othertext' => $othertext,
'checkedState' => $checkedState,
'kpclass' => $kpclass,
Expand Down Expand Up @@ -2362,7 +2363,7 @@ function do_multiplechoice_withcomments($ia)

$inputCOmmentValue = htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2],ENT_QUOTES);
$sRows .= doRender('/survey/questions/multiplechoice_with_comments/rows/answer_row', array(
'sDisplayStyle' => $sDisplayStyle,
'sDisplayStyle' => (isset($sDisplayStyle))?$sDisplayStyle:'',
'kpclass' => $kpclass,
'title' => '',
'liclasses' => 'responsive-content question-item answer-item checkbox-text-item',
Expand All @@ -2376,11 +2377,11 @@ function do_multiplechoice_withcomments($ia)
'javainput' => true,
'javaname' => 'java'.$myfname,
'javavalue' => $javavalue,
'checked' => $checked,
'checked' => (isset( $checked))? $checked:'',
'inputCommentId' => 'answer'.$myfname2,
'commentLabelText' => gT('Make a comment on your choice here:'),
'inputCommentName' => $myfname2,
'inputCOmmentValue' => $inputCOmmentValue,
'inputCOmmentValue' => (isset( $inputCOmmentValue))?$inputCOmmentValue :'',
), true);

}
Expand Down Expand Up @@ -3121,7 +3122,7 @@ function do_multiplenumeric($ia)
'slider_max' => $slider_max ,
'slider_maxtext' => $slider_maxtext ,
'slider_default' => $slider_default ,
'slider_handle' => $slider_handle,
'slider_handle' => (isset($slider_handle ))? $slider_handle:'',
'slider_reset' => $slider_reset,
'slider_custom_handle' => $slider_custom_handle,
'slider_user_no_action' => $slider_user_no_action,
Expand Down Expand Up @@ -3488,7 +3489,7 @@ function do_shortfreetext($ia)
'location_mapzoom' => $aQuestionAttributes['location_mapzoom'],
'location_mapheight' => $aQuestionAttributes['location_mapheight'],
'questionHelp' => $questionHelp,
'question_text_help' => $question_text['help'],
'question_text_help' => (isset( $question_text ))? $question_text['help']:'',
'sm_col' => decide_sm_col($prefix, $suffix)
), true);

Expand Down Expand Up @@ -3553,7 +3554,7 @@ function do_shortfreetext($ia)
'location_mapservice'=>$aQuestionAttributes['location_mapservice'],
'location_mapzoom'=>$aQuestionAttributes['location_mapzoom'],
'location_mapheight'=>$aQuestionAttributes['location_mapheight'],
'questionHelp'=>$questionHelp,
'questionHelp'=>(isset($questionHelp))?$questionHelp:'',
'question_text_help'=>$question_text['help'],
'location_value'=> $currentLatLong[0].' '.$currentLatLong[1],
'currentLat'=>$currentLatLong[0],
Expand Down Expand Up @@ -4329,7 +4330,7 @@ function do_array_yesnouncertain($ia)
'extraclass' => $extraclass,
'sColumns' => $sColumns,
'sHeaders' => $sHeaders,
'sRows' => $sRows,
'sRows' => (isset($sRows))?$sRows:'',
'anscount' => $anscount,
), true);

Expand Down Expand Up @@ -5191,7 +5192,7 @@ function do_array_texts($ia)
}
else
{
$answer .= doRender('/survey/questions/arrays/texts/empty_error', array(), true);
$answer = doRender('/survey/questions/arrays/texts/empty_error', array(), true);
$inputnames ='';
}
return array($answer, $inputnames);
Expand Down Expand Up @@ -5226,7 +5227,7 @@ function do_array_multiflexi($ia)
if (trim($aQuestionAttributes['multiflexible_max'])!='' && trim($aQuestionAttributes['multiflexible_min']) =='')
{
$maxvalue = $aQuestionAttributes['multiflexible_max'];
$minvalue = (isset($minvalue['value']) && $minvalue['value'] == 0)?0:1;
$minvalue = 1;
$extraclass .= " maxvalue maxvalue-".trim($aQuestionAttributes['multiflexible_max']);
}

Expand Down
2 changes: 1 addition & 1 deletion application/models/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public static function questionModuleList()
{
//$list_of_files[$file] = $standardtemplaterootdir.DIRECTORY_SEPARATOR.$file;
$oQuestionTypeConfig = simplexml_load_file($sQuestionTypeDir.DIRECTORY_SEPARATOR.$file.'/config.xml');
$aQuestionModules[$file] = $oQuestionTypeConfig->type;
//$aQuestionModules[$file] = $oQuestionTypeConfig->type;
//var_dump($oQuestionTypeConfig->type);
}
}
Expand Down
4 changes: 2 additions & 2 deletions application/models/TemplateConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')
}

$this->sTemplateName = $sTemplateName;
$this->iSurveyId = $iSurveyId;
$this->iSurveyId = (int) $iSurveyId;

if ($sTemplateName=='')
{
Expand Down Expand Up @@ -102,7 +102,7 @@ public function setTemplateConfiguration($sTemplateName='', $iSurveyId='')

// If the template don't have a config file (maybe it has been deleted, or whatever),
// then, we load the default template
$this->hasConfigFile = is_file($this->path.DIRECTORY_SEPARATOR.'config.xml');
$this->hasConfigFile = (string) is_file($this->path.DIRECTORY_SEPARATOR.'config.xml');
$this->isOldTemplate = ( !$this->hasConfigFile && is_file($this->path.DIRECTORY_SEPARATOR.'startpage.pstpl')); // TODO: more complex checks

if (!$this->hasConfigFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@
</label>
<?php if(isset($selectormodeclass) && $selectormodeclass != "none" && $activated != "Y"): ?>
<?php
foreach (getQuestionTypeList($eqrow['type'], 'array') as $key=> $questionType)
$aQuestionTypeList = (array) getQuestionTypeList($eqrow['type'], 'array');
foreach ( $aQuestionTypeList as $key=> $questionType)
{
if (!isset($groups[$questionType['group']]))
{
Expand Down

0 comments on commit 442b6be

Please sign in to comment.