Skip to content

Commit

Permalink
Dev Fixed problematic comments
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 23, 2017
1 parent 94e3196 commit 66dcafa
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 56 deletions.
7 changes: 4 additions & 3 deletions application/controllers/admin/conditionsaction.php
Expand Up @@ -144,7 +144,9 @@ public function index($subaction, $iSurveyID = null, $gid = null, $qid = null)
if (!isset($p_cqid))
{
$p_cqid = returnGlobal('cqid');
if ($p_cqid == '') $p_cqid = 0; // we are not using another question as source of condition
if ($p_cqid == '') { // we are not using another question as source of condition
$p_cqid = 0;
}
}

if (!isset($p_cid)) { $p_cid = returnGlobal('cid'); }
Expand Down Expand Up @@ -1369,8 +1371,7 @@ protected function getPostQuestionList($qid, array $qrows)
{
$position = "before";
$postquestionlist = array();
foreach ($qrows as $qrow) //Go through each question until we reach the current one
{
foreach ($qrows as $qrow) { //Go through each question until we reach the current one
if ($qrow["qid"] == $qid)
{
$position = "after";
Expand Down
4 changes: 1 addition & 3 deletions application/controllers/admin/globalsettings.php
Expand Up @@ -242,8 +242,7 @@ private function _saveSettings()
if (!Yii::app()->getConfig('demoMode'))
{
$sTemplate = Yii::app()->getRequest()->getPost("defaulttheme");
if (array_key_exists($sTemplate, getTemplateList()))// Filter template name
{
if (array_key_exists($sTemplate, getTemplateList())) { // Filter template name
setGlobalSetting('defaulttheme', $sTemplate);
}
setGlobalSetting('x_frame_options', Yii::app()->getRequest()->getPost('x_frame_options'));
Expand All @@ -253,7 +252,6 @@ private function _saveSettings()
$sAdmintheme = sanitize_paranoid_string($_POST['admintheme']);
setGlobalSetting('admintheme', $sAdmintheme);

//setGlobalSetting('adminthemeiconsize', trim(file_get_contents(Yii::app()->getConfig("styledir").DIRECTORY_SEPARATOR.sanitize_paranoid_string($_POST['admintheme']).DIRECTORY_SEPARATOR.'iconsize')));
setGlobalSetting('emailmethod', strip_tags($_POST['emailmethod']));
setGlobalSetting('emailsmtphost', strip_tags(returnGlobal('emailsmtphost')));
if (returnGlobal('emailsmtppassword') != 'somepassword') {
Expand Down
3 changes: 1 addition & 2 deletions application/core/LSUserIdentity.php
Expand Up @@ -139,8 +139,7 @@ protected function postLogin()
$not->save();
}

if ((int) App()->request->getPost('width', '1220') < 1220) // Should be 1280 but allow 60 lenience pixels for browser frame and scrollbar
{
if ((int) App()->request->getPost('width', '1220') < 1220) { // Should be 1280 but allow 60 lenience pixels for browser frame and scrollbar
Yii::app()->setFlashMessage(gT("Your browser screen size is too small to use the administration properly. The minimum size required is 1280*1024 px."), 'error');
}

Expand Down
3 changes: 1 addition & 2 deletions application/helpers/admin/activate_helper.php
Expand Up @@ -391,8 +391,7 @@ function activateSurvey($iSurveyID, $simulate = false)
$oQuestionAttribute->value = $nrOfAnswers;
$oQuestionAttribute->save();
}
elseif (intval($oQuestionAttribute->value) < 1) // Fix it if invalid : disallow 0, but need a sub question minimum for EM
{
elseif (intval($oQuestionAttribute->value) < 1) { // Fix it if invalid : disallow 0, but need a sub question minimum for EM
$oQuestionAttribute->value = $nrOfAnswers;
$oQuestionAttribute->save();
}
Expand Down
3 changes: 1 addition & 2 deletions application/helpers/admin/export/SurveyObj.php
Expand Up @@ -208,8 +208,7 @@ public function getFullAnswer($fieldName, $answerCode, Translator $translator, $
{
$fullAnswer = $translator->translate('Yes', $sLanguageCode);
}
elseif ($answerCode == 'N' || $answerCode === '') // Strict check for empty string to find null values
{
elseif ($answerCode == 'N' || $answerCode === '') { // Strict check for empty string to find null values
$fullAnswer = $translator->translate('No', $sLanguageCode);
} else {
$fullAnswer = $translator->translate('N/A', $sLanguageCode);
Expand Down
22 changes: 7 additions & 15 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -122,8 +122,7 @@ function createChart($iQuestionID, $iSurveyID, $type = null, $lbl, $gdata, $graw
$gheight = 320;
}

if (!$type) // Bar chart
{
if (!$type) { // Bar chart
$DataSet = new pData;
$counter = 0;
$maxyvalue = 0;
Expand Down Expand Up @@ -394,8 +393,7 @@ function buildSelects($allfields, $surveyid, $language) {
*/
if ($pv != "sid" && $pv != "display" && $firstletter != "M" && $firstletter != "P" && $firstletter != "T" &&
$firstletter != "Q" && $firstletter != "D" && $firstletter != "N" && $firstletter != "K" && $firstletter != "|" &&
$pv != "summary" && substr($pv, 0, 2) != "id" && substr($pv, 0, 9) != "datestamp") //pull out just the fieldnames
{
$pv != "summary" && substr($pv, 0, 2) != "id" && substr($pv, 0, 9) != "datestamp") { //pull out just the fieldnames
//put together some SQL here
$thisquestion = Yii::app()->db->quoteColumnName($pv)." IN (";

Expand Down Expand Up @@ -682,8 +680,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
}

//S - Short Free Text and T - Long Free Text
elseif ($firstletter == "T" || $firstletter == "S") //Short and long text
{
elseif ($firstletter == "T" || $firstletter == "S") { //Short and long text
//search for key
$fld = substr($rt, 1, strlen($rt));
$fielddata = $fieldmap[$fld];
Expand Down Expand Up @@ -772,8 +769,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,
}
}

else if ($firstletter == "|") // File UPload
{
else if ($firstletter == "|") { // File Upload

//get SGQ data
list($qsid, $qgid, $qqid) = explode("X", substr($rt, 1, strlen($rt)), 3);
Expand Down Expand Up @@ -894,8 +890,7 @@ protected function buildOutputList($rt, $language, $surveyid, $outputType, $sql,

//N = numerical input
//K = multiple numerical input
elseif ($firstletter == "N" || $firstletter == "K") //NUMERICAL TYPE
{
elseif ($firstletter == "N" || $firstletter == "K") { //NUMERICAL TYPE
//Zero handling
if (!isset($excludezeros)) //If this hasn't been set, set it to on as default:
{
Expand Down Expand Up @@ -1677,18 +1672,15 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
if ($sDatabaseType == 'mssql' || $sDatabaseType == 'sqlsrv' || $sDatabaseType == 'dblib')
{
// mssql cannot compare text blobs so we have to cast here
//$query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE (".sanitize_int($rt)." IS NULL "
$query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ( "
// . "OR cast(".sanitize_int($rt)." as varchar) = '' "
. "cast(".Yii::app()->db->quoteColumnName($rt)." as varchar) = '' "
. "OR cast(".Yii::app()->db->quoteColumnName($rt)." as varchar) = ' ' )";
}
else
// $query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE (".sanitize_int($rt)." IS NULL "
else {
$query = "SELECT count(*) FROM {{survey_$surveyid}} WHERE ( "
// . "OR ".sanitize_int($rt)." = '' "
. " ".Yii::app()->db->quoteColumnName($rt)." = '' "
. "OR ".Yii::app()->db->quoteColumnName($rt)." = ' ') ";
}
}
}

Expand Down
34 changes: 12 additions & 22 deletions application/helpers/common_helper.php
Expand Up @@ -1239,8 +1239,7 @@ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $sLanguage)
$survey = Survey::model()->findByPk($iSurveyID);
//Fieldcode used to determine question, $sValue used to match against answer code
//Returns NULL if question type does not suit
if (strpos($sFieldCode, "{$iSurveyID}X") === 0) //Only check if it looks like a real fieldcode
{
if (strpos($sFieldCode, "{$iSurveyID}X") === 0) { //Only check if it looks like a real fieldcode
$fieldmap = createFieldMap($survey, 'short', false, false, $sLanguage);
if (isset($fieldmap[$sFieldCode]))
{
Expand Down Expand Up @@ -1757,8 +1756,7 @@ function createFieldMap($survey, $style = 'short', $force_refresh = false, $ques
$groupSeq = -1;
$_groupOrder = -1;

foreach ($questions as $arow) //With each question, create the appropriate field(s))
{
foreach ($questions as $arow) { //With each question, create the appropriate field(s))
++$questionSeq;

// fix fact taht group_order may have gaps
Expand Down Expand Up @@ -2031,8 +2029,7 @@ function createFieldMap($survey, $style = 'short', $force_refresh = false, $ques
$fieldmap[$fieldname]['groupSeq'] = $groupSeq;
}
}
else // Question types with subquestions and one answer per subquestion (M/A/B/C/E/F/H/P)
{
else { // Question types with subquestions and one answer per subquestion (M/A/B/C/E/F/H/P)
//MULTI ENTRY
$abrows = getSubQuestions($surveyid, $arow['qid'], $sLanguage);
foreach ($abrows as $abrow)
Expand Down Expand Up @@ -2622,8 +2619,8 @@ function flattenText($sTextToFlatten, $bKeepSpan = false, $bDecodeHTMLEntities =
$sNicetext = str_replace(array("\r\n", "\n", "\r"), array(' ', ' ', ' '), $sNicetext);
}
}
elseif (version_compare(substr(PCRE_VERSION, 0, strpos(PCRE_VERSION, ' ')), '7.0') > -1)// unify newlines to \r\n
{
elseif (version_compare(substr(PCRE_VERSION, 0, strpos(PCRE_VERSION, ' ')), '7.0') > -1) {
// unify newlines to \r\n
$sNicetext = preg_replace(array('~\R~u'), array("\r\n"), $sNicetext);
}
if ($bDecodeHTMLEntities == true)
Expand Down Expand Up @@ -2666,15 +2663,12 @@ function getArrayFilterExcludesCascadesForGroup($surveyid, $gid = "", $output =
}
}
$attrmach = array(); // Stores Matches of filters that have their values as questions within current group
foreach ($grows as $qrow) // Cycle through questions to see if any have list_filter attributes
{
foreach ($grows as $qrow) { // Cycle through questions to see if any have list_filter attributes
$qidtotitle[$qrow['qid']] = $qrow['title'];
$qresult = QuestionAttribute::model()->getQuestionAttributes($qrow['qid']);
if (isset($qresult['array_filter_exclude'])) // We Found a array_filter attribute
{
if (isset($qresult['array_filter_exclude'])) { // We Found a array_filter attribute
$val = $qresult['array_filter_exclude']; // Get the Value of the Attribute ( should be a previous question's title in same group )
foreach ($grows as $avalue) // Cycle through all the other questions in this group until we find the source question for this array_filter
{
foreach ($grows as $avalue) { // Cycle through all the other questions in this group until we find the source question for this array_filter
if ($avalue['title'] == $val)
{
/* This question ($avalue) is the question that provides the source information we use
Expand Down Expand Up @@ -5159,12 +5153,10 @@ function ellipsize($sString, $iMaxLength, $fPosition = 1, $sEllipsis = '&hellip;
*/
function getIPAddress()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$sIPAddress = $_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$sIPAddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif (!empty($_SERVER['REMOTE_ADDR']))
Expand Down Expand Up @@ -5320,12 +5312,10 @@ function decodeTokenAttributes($oTokenAttributeData) {
if (substr($oTokenAttributeData, 0, 1) != '{' && substr($oTokenAttributeData, 0, 1) != '[')
{
$sSerialType = getSerialClass($oTokenAttributeData);
if ($sSerialType == 'array') // Safe to decode
{
if ($sSerialType == 'array') { // Safe to decode
$aReturnData = @unserialize($oTokenAttributeData);
}
else // Something else, might be unsafe
{
else { // Something else, might be unsafe
return array();
}
}
Expand Down
5 changes: 1 addition & 4 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -1322,15 +1322,12 @@ public function GetJavaScriptEquivalentOfExpression()
}
// for each variable that does not have a default value, add clause to throw error if any of them are NA
$nonNAvarsUsed = array();
foreach ($this->GetVarsUsed() as $var) {
// this function wants to see the NAOK suffix
{
foreach ($this->GetVarsUsed() as $var) { // this function wants to see the NAOK suffix
if (!preg_match("/^.*\.(NAOK|relevanceStatus)$/", $var))
{
if ($this->GetVarAttribute($var, 'jsName', '') != '')
{
$nonNAvarsUsed[] = $var;
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions application/helpers/userstatistics_helper.php
Expand Up @@ -126,8 +126,7 @@ function createChart($iQuestionID, $iSurveyID, $type = null, $lbl, $gdata, $graw
$gheight = 320;
}

if (!$type) // Bar chart
{
if (!$type) { // Bar chart
$DataSet = new pData;
$counter = 0;
$maxyvalue = 0;
Expand Down
4 changes: 3 additions & 1 deletion application/models/Question.php
Expand Up @@ -805,7 +805,9 @@ public function getOrderedSubQuestions($random = 0, $exclude_all_others = '')
$position = 0;
foreach ($ansresult as $answer) {
if (($answer['title'] == trim($exclude_all_others))) {
if ($position == $answer['question_order'] - 1) break; //already in the right position
if ($position == $answer['question_order'] - 1) { //already in the right position
break;
}
$tmp = array_splice($ansresult, $position, 1);
array_splice($ansresult, $answer['question_order'] - 1, 0, $tmp);
break;
Expand Down

0 comments on commit 66dcafa

Please sign in to comment.