Skip to content

Commit

Permalink
Dev Fixed Scrutinizer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Dec 12, 2017
1 parent 0cf80e4 commit 306cc98
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 39 deletions.
25 changes: 12 additions & 13 deletions application/controllers/admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class export extends Survey_Common_Action
{

function __construct($controller, $id)
public function __construct($controller, $id)
{
parent::__construct($controller, $id);

Expand All @@ -52,7 +52,7 @@ public function survey()
public function surveyarchives()
{
if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) {
die('Access denied.');
safeDie('Access denied.');
}

$aSurveyIDs = $this->session->flashdata('sids');
Expand Down Expand Up @@ -314,7 +314,7 @@ public function exportresults()
viewHelper::disableHtmlLogging();
$resultsService->exportSurvey($iSurveyID, $explang, $sExportType, $options, $sFilter);

exit;
Yii::app()->end();
}

/*
Expand Down Expand Up @@ -698,8 +698,7 @@ public function vvexport()

unset($sun);
}

exit;
Yii::app()->end();
}
}

Expand Down Expand Up @@ -732,20 +731,20 @@ public function resources()
}
}
if ($zip->create($zipdirs, PCLZIP_OPT_REMOVE_PATH, $resourcesdir) === 0) {
die("Error : ".$zip->errorInfo(true));
safeDie("Error : ".$zip->errorInfo(true));
} elseif (file_exists($zipfilepath)) {
$this->_addHeaders($zipfilename, 'application/force-download', 0);
readfile($zipfilepath);
unlink($zipfilepath);
exit;
Yii::app()->end();
}
}
}

public function dumplabel()
{
if (!Permission::model()->hasGlobalPermission('labelsets', 'export')) {
die ('No permission.');
safeDie ('No permission.');
}
$lid = sanitize_int(Yii::app()->request->getParam('lid'));
// DUMP THE RELATED DATA FOR A SINGLE QUESTION INTO A SQL FILE FOR IMPORTING LATER ON OR
Expand All @@ -756,7 +755,7 @@ public function dumplabel()
$lids = returnGlobal('lids');

if (!$lid && !$lids) {
die('No LID has been provided. Cannot dump label set.');
safeDie('No LID has been provided. Cannot dump label set.');
}

if ($lid) {
Expand Down Expand Up @@ -787,7 +786,7 @@ public function dumplabel()
buildXMLFromQuery($xml, $lquery, 'labels');
$xml->endElement(); // close columns
$xml->endDocument();
exit;
Yii::app()->end();
}

/**
Expand Down Expand Up @@ -1016,14 +1015,14 @@ private function _surveyexport($action, $iSurveyID)
$this->_addHeaders($fn, "text/xml", "Mon, 26 Jul 1997 05:00:00 GMT");

echo surveyGetXMLData($iSurveyID);
exit;
Yii::app()->end();
} elseif ($action == "exportstructurejson") {
$fn = "limesurvey_survey_{$iSurveyID}.json";
$this->_addHeaders($fn, "application/json", "Mon, 26 Jul 1997 05:00:00 GMT");
$surveyInXmlFormat = surveyGetXMLData($iSurveyID);
// now convert this xml into json format and then return
echo _xmlToJson($surveyInXmlFormat);
exit;
Yii::app()->end();
} elseif ($action == "exportstructurequexml") {
if (isset($surveyprintlang) && !empty($surveyprintlang)) {
$quexmllang = $surveyprintlang;
Expand All @@ -1037,7 +1036,7 @@ private function _surveyexport($action, $iSurveyID)
$this->_addHeaders($fn, "text/xml", "Mon, 26 Jul 1997 05:00:00 GMT");

echo quexml_export($iSurveyID, $quexmllang);
exit;
Yii::app()->end();
}
} elseif ($action == 'exportstructuretsv') {
$this->_exporttsv($iSurveyID);
Expand Down
25 changes: 6 additions & 19 deletions application/controllers/admin/globalsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class GlobalSettings extends Survey_Common_Action
{

function __construct($controller, $id)
public function __construct($controller, $id)
{
parent::__construct($controller, $id);

Expand Down Expand Up @@ -56,17 +56,7 @@ public function showphpinfo()
private function _displaySettings()
{
Yii::app()->loadHelper('surveytranslator');

// Save refurl from where global settings screen is called!
$refurl = Yii::app()->getRequest()->getUrlReferrer(Yii::app()->createUrl('admin'));

// Some URLs are not to be allowed to refered back to.
// These exceptions can be added to the $aReplacements array
$aReplacements = array('admin/update/sa/step4b'=>'admin/sa/index',
'admin/user/sa/adduser'=>'admin/user/sa/index',
'admin/user/sa/setusertemplates'=>'admin/user/sa/index'
);

$data = [];
$data['title'] = "hi";
$data['message'] = "message";
foreach ($this->_checkSettings() as $key => $row) {
Expand Down Expand Up @@ -345,10 +335,10 @@ private function _checkSettings()
if ($activesurveycount == false) {
$activesurveycount = 0;
}
if ($surveycount == false) {
if ($surveycount === false) {
$surveycount = 0;
}

$oldtokenlist = [];
$tablelist = Yii::app()->db->schema->getTableNames();
foreach ($tablelist as $table) {
if (strpos($table, Yii::app()->db->tablePrefix."old_tokens_") !== false) {
Expand All @@ -365,11 +355,8 @@ private function _checkSettings()
} else {
$deactivatedsurveys = 0;
}
if (isset($oldtokenlist) && is_array($oldtokenlist)) {
$deactivatedtokens = count($oldtokenlist);
} else {
$deactivatedtokens = 0;
}
$deactivatedtokens = count($oldtokenlist);

if (isset($tokenlist) && is_array($tokenlist)) {
$activetokens = count($tokenlist);
} else {
Expand Down
8 changes: 2 additions & 6 deletions application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function getSurveyList($bReturnArray = false)
$inactivesurveys .= " class='mysurvey emphasis'";
}
$inactivesurveys .= " value='{$sv['sid']}'>{$surveylstitle}</option>\n";
} elseif ($sv['expires'] != '' && $sv['expires'] < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust)) {
} elseif ($sv['expires'] != '' && $sv['expires'] < dateShift((string)date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust)) {
$expiredsurveys .= "<option ";
if (Yii::app()->user->getId() == $sv['owner_id']) {
$expiredsurveys .= " class='mysurvey emphasis'";
Expand Down Expand Up @@ -247,11 +247,7 @@ function getSurveyList($bReturnArray = false)
$surveyselecter .= "<optgroup label='".gT("Inactive")."' class='inactivesurveyselect'>\n";
$surveyselecter .= $inactivesurveys."</optgroup>";
}
if (!isset($svexist)) {
$surveyselecter = "<option selected='selected' value=''>".gT("Please choose...")."</option>\n".$surveyselecter;
} else {
$surveyselecter = "<option value=''>".gT("None")."</option>\n".$surveyselecter;
}
$surveyselecter = "<option selected='selected' value=''>".gT("Please choose...")."</option>\n".$surveyselecter;
return $surveyselecter;
}

Expand Down
2 changes: 1 addition & 1 deletion application/models/ParticipantAttributeName.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public function editParticipantAttributeValue($data)
* @param integer $attid
* @return void
*/
public public function delAttribute($attid)
public function delAttribute($attid)
{
Yii::app()->db->createCommand()->delete('{{participant_attribute_names_lang}}', 'attribute_id = '.$attid);
Yii::app()->db->createCommand()->delete('{{participant_attribute_names}}', 'attribute_id = '.$attid);
Expand Down

0 comments on commit 306cc98

Please sign in to comment.