Skip to content

Commit

Permalink
Dev More brace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scrutinizer-auto-fixer authored and c-schmitz committed Nov 23, 2017
1 parent 6bbeec2 commit 43ab5be
Show file tree
Hide file tree
Showing 39 changed files with 1,448 additions and 1,400 deletions.
25 changes: 10 additions & 15 deletions application/controllers/OptoutController.php
@@ -1,4 +1,6 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
Expand Down Expand Up @@ -47,8 +49,7 @@ function actiontokens()
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode)
{
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
}
else
} else
{
$sBaseLanguage = sanitize_languagecode($sLanguageCode);
}
Expand Down Expand Up @@ -102,8 +103,7 @@ function actionremovetokens()

if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
}
else
} else
{
LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $sToken, false);
$oToken = Token::model($iSurveyID)->findByAttributes(array('token'=>$sToken));
Expand All @@ -112,16 +112,14 @@ function actionremovetokens()
{
$sMessage = gT('You are not a participant in this survey.');
//throw new CHttpException(404, "You are not a participant in this survey.");
}
else
} else
{
if (substr($oToken->emailstatus, 0, strlen('OptOut')) !== 'OptOut')
{
$oToken->emailstatus = 'OptOut';
$oToken->save();
$sMessage = gT('You have been successfully removed from this survey.');
}
else
} else
{
$sMessage = gT('You have been already removed from this survey.');
}
Expand Down Expand Up @@ -164,24 +162,21 @@ function actionparticipants()
if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}"))
{
throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
}
else
} else
{
LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $sToken, false);
$oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $sToken));
if (!isset($oToken))
{
$sMessage = gT('You are not a participant in this survey.');
}
else
} else
{
if (substr($oToken->emailstatus, 0, strlen('OptOut')) !== 'OptOut')
{
$oToken->emailstatus = 'OptOut';
$oToken->save();
$sMessage = gT('You have been successfully removed from this survey.');
}
else
} else
{
$sMessage = gT('You have been already removed from this survey.');
}
Expand Down
48 changes: 25 additions & 23 deletions application/controllers/RegisterController.php
@@ -1,4 +1,6 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
/*
* LimeSurvey
* Copyright (C) 2007-2011 The LimeSurvey Project Team / Carsten Schmitz
Expand Down Expand Up @@ -87,10 +89,11 @@ public function actionAJAXRegisterForm($surveyid)
public function actionIndex($sid = null)
{

if (!is_null($sid))
$iSurveyId = $sid;
else
$iSurveyId = Yii::app()->request->getPost('sid');
if (!is_null($sid)) {
$iSurveyId = $sid;
} else {
$iSurveyId = Yii::app()->request->getPost('sid');
}

$oSurvey = Survey::model()->find("sid=:sid", array(':sid'=>$iSurveyId));
/* Throw 404 if needed */
Expand Down Expand Up @@ -168,7 +171,7 @@ public function getRegisterErrors($iSurveyId) {
//Check that the email is a valid style address
if ($aFieldValue['sEmail'] == "") {
$this->aRegisterErrors[] = gT("You must enter a valid email. Please try again.");
}elseif (!validateEmailAddress($aFieldValue['sEmail'])) {
} elseif (!validateEmailAddress($aFieldValue['sEmail'])) {
$this->aRegisterErrors[] = gT("The email you used is not valid. Please try again.");
}
//Check and validate attribute
Expand Down Expand Up @@ -196,8 +199,9 @@ public function getRegisterForm($iSurveyId)
$registerFormEvent = array();
if (!is_null($event->get('registerForm'))) {
$registerFormEvent = $event->get('registerForm');
if (!isset($registerFormEvent['append']) || $registerFormEvent['append'] == false)
return $event->get('registerForm');
if (!isset($registerFormEvent['append']) || $registerFormEvent['append'] == false) {
return $event->get('registerForm');
}
}
$aFieldValue = $this->getFieldValue($iSurveyId);
$aRegisterAttributes = $this->getExtraAttributeInfo($iSurveyId);
Expand All @@ -220,8 +224,7 @@ public function getRegisterForm($iSurveyId)
if (is_array($this->aRegisterErrors))
{
$aData['aErrors'] = $this->aRegisterErrors;
}
else
} else
{
$aData['aErrors'] = array();
}
Expand Down Expand Up @@ -266,8 +269,9 @@ public function sendRegistrationEmail($iSurveyId, $iTokenId) {
foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key)
{
$url = $aReplacementFields["{{$key}URL}"];
if ($useHtmlEmail)
$aReplacementFields["{{$key}URL}"] = "<a href='{$url}'>".htmlspecialchars($url).'</a>';
if ($useHtmlEmail) {
$aReplacementFields["{{$key}URL}"] = "<a href='{$url}'>".htmlspecialchars($url).'</a>';
}
$aMail['subject'] = str_replace("@@{$key}URL@@", $url, $aMail['subject']);
$aMail['message'] = str_replace("@@{$key}URL@@", $url, $aMail['message']);
}
Expand Down Expand Up @@ -338,8 +342,7 @@ public function sendRegistrationEmail($iSurveyId, $iTokenId) {
$aMessage['mail-message'] = $this->sMailMessage;
$aMessage['mail-contact'] = sprintf(gT("Survey administrator %s (%s)"), $aSurveyInfo['adminname'], $aSurveyInfo['adminemail']);
$this->sMessage = $this->renderPartial('/survey/system/message', array('aMessage'=>$aMessage), true);
}
else
} else
{
$aMessage['mail-thanks'] = gT("Thank you for registering to participate in this survey.");
$aMessage['mail-message-error'] = gT("You are registered but an error happened when trying to send the email - please contact the survey administrator.");
Expand Down Expand Up @@ -371,22 +374,20 @@ public function getTokenId($iSurveyId)
if ($oToken->usesleft < 1 && $aSurveyInfo['alloweditaftercompletion'] != 'Y')
{
$this->aRegisterErrors[] = gT("The email address you have entered is already registered and the survey has been completed.");
}
elseif (strtolower(substr(trim($oToken->emailstatus), 0, 6)) === "optout")// And global blacklisting ?
} elseif (strtolower(substr(trim($oToken->emailstatus), 0, 6)) === "optout") {
// And global blacklisting ?
{
$this->aRegisterErrors[] = gT("This email address cannot be used because it was opted out of this survey.");
}
elseif (!$oToken->emailstatus && $oToken->emailstatus != "OK")
} elseif (!$oToken->emailstatus && $oToken->emailstatus != "OK")
{
$this->aRegisterErrors[] = gT("This email address is already registered but the email adress was bounced.");
}
else
} else
{
$this->sMailMessage = gT("The address you have entered is already registered. An email has been sent to this address with a link that gives you access to the survey.");
return $oToken->tid;
}
}
else
} else
{
// TODO : move xss filtering in model
$oToken = Token::create($iSurveyId);
Expand Down Expand Up @@ -461,8 +462,9 @@ public function getExtraAttributeInfo($iSurveyId)
*/
public function getStartDate($iSurveyId) {
$aSurveyInfo = getSurveyInfo($iSurveyId, Yii::app()->language);
if (empty($aSurveyInfo['startdate']) || dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust")) >= $aSurveyInfo['startdate'])
return;
if (empty($aSurveyInfo['startdate']) || dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", Yii::app()->getConfig("timeadjust")) >= $aSurveyInfo['startdate']) {
return;
}
Yii::app()->loadHelper("surveytranslator");
$aDateFormat = getDateFormatData(getDateFormatForSID($iSurveyId, Yii::app()->language), Yii::app()->language);
$datetimeobj = new Date_Time_Converter($aSurveyInfo['startdate'], 'Y-m-d H:i:s');
Expand Down
28 changes: 13 additions & 15 deletions application/controllers/UploaderController.php
@@ -1,4 +1,6 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
<?php if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
/*
* LimeSurvey
* Copyright (C) 2007-2014 The LimeSurvey Project Team / Carsten Schmitz
Expand Down Expand Up @@ -104,7 +106,9 @@ function run($actionID)
}
$iFileIndex++;
}
if ($found == true) unset($aFiles[$iFileIndex]);
if ($found == true) {
unset($aFiles[$iFileIndex]);
}
$_SESSION[$sFieldName] = ls_json_encode($aFiles);
}
}
Expand All @@ -113,9 +117,9 @@ function run($actionID)
if (@unlink($sFileDir.$sFileName))
{
echo sprintf(gT('File %s deleted'), $sOriginalFileName);
} else {
echo gT('Oops, There was an error deleting the file');
}
else
echo gT('Oops, There was an error deleting the file');
Yii::app()->end();
}

Expand Down Expand Up @@ -174,9 +178,7 @@ function run($actionID)
//header('Content-Type: application/json');
echo ls_json_encode($return);
Yii::app()->end();
}

else if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $randfileloc))
} else if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $randfileloc))
{

$return = array(
Expand All @@ -195,8 +197,7 @@ function run($actionID)
echo ls_json_encode($return); ;
Yii::app()->end();
}
}
else
} else
{ // if everything went fine and the file was uploaded successfully,
// send the file related info back to the client
$iFileUploadTotalSpaceMB = Yii::app()->getConfig("iFileUploadTotalSpaceMB");
Expand All @@ -209,8 +210,7 @@ function run($actionID)
//header('Content-Type: application/json');
echo ls_json_encode($return);
Yii::app()->end();
}
elseif ($iFileUploadTotalSpaceMB > 0 && ((calculateTotalFileUploadUsage() + ($size / 1024 / 1024)) > $iFileUploadTotalSpaceMB))
} elseif ($iFileUploadTotalSpaceMB > 0 && ((calculateTotalFileUploadUsage() + ($size / 1024 / 1024)) > $iFileUploadTotalSpaceMB))
{
$return = array(
"success" => false,
Expand All @@ -219,8 +219,7 @@ function run($actionID)
//header('Content-Type: application/json');
echo ls_json_encode($return);
Yii::app()->end();
}
elseif (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $randfileloc))
} elseif (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $randfileloc))
{
$return = array(
"success" => true,
Expand Down Expand Up @@ -258,8 +257,7 @@ function run($actionID)
//header('Content-Type: application/json');
echo ls_json_encode($return);
Yii::app()->end();
}
else
} else
{
$return = array(
"success" => false,
Expand Down
25 changes: 13 additions & 12 deletions application/controllers/admin/SurveymenuController.php
Expand Up @@ -47,10 +47,11 @@ public function accessRules()
*/
public function update($id = 0)
{
if ($id != 0)
$model = $this->loadModel($id);
else
$model = new Surveymenu();
if ($id != 0) {
$model = $this->loadModel($id);
} else {
$model = new Surveymenu();
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

Expand All @@ -62,8 +63,9 @@ public function update($id = 0)
unset($aSurveymenu['id']);
$aSurveymenu['created_at'] = date('Y-m-d H:i:s');
$aSurveymenu['parent_id'] = (int) $aSurveymenu['parent_id'];
if ($aSurveymenu['parent_id'] > 0)
$aSurveymenu['level'] = ((Surveymenu::model()->findByPk($aSurveymenu['parent_id'])->level) + 1);
if ($aSurveymenu['parent_id'] > 0) {
$aSurveymenu['level'] = ((Surveymenu::model()->findByPk($aSurveymenu['parent_id'])->level) + 1);
}
}

$model->setAttributes($aSurveymenu);
Expand Down Expand Up @@ -140,15 +142,13 @@ public function batchEdit()
$aResults[$iSurveyMenuId]['message'] = $iSurveyMenuId->error;
}
}
}
else
} else
{
$aResults['global']['result'] = false;
$aResults['global']['message'] = gT('Nothing to update');
}

}
else
} else
{
$aResults['global']['result'] = false;
$aResults['global']['message'] = gT("We are sorry but you don't have permissions to do this.");
Expand Down Expand Up @@ -312,8 +312,9 @@ public function restore() {
public function loadModel($id)
{
$model = Surveymenu::model()->findByPk($id);
if ($model === null)
throw new CHttpException(404, 'The requested page does not exist.');
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}

Expand Down
25 changes: 13 additions & 12 deletions application/controllers/admin/SurveymenuEntryController.php
Expand Up @@ -64,8 +64,9 @@ public function create()
if (isset($_POST['SurveymenuEntries']))
{
$model->attributes = $_POST['SurveymenuEntries'];
if ($model->save())
$this->redirect(array('view', 'id'=>$model->id));
if ($model->save()) {
$this->redirect(array('view', 'id'=>$model->id));
}
}

$this->render('create', array(
Expand All @@ -80,10 +81,11 @@ public function create()
*/
public function update($id)
{
if ($id != 0)
$model = $this->loadModel($id);
else
$model = new SurveymenuEntries();
if ($id != 0) {
$model = $this->loadModel($id);
} else {
$model = new SurveymenuEntries();
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

Expand Down Expand Up @@ -164,15 +166,13 @@ public function batchEdit()
$aResults[$iSurveyMenuEntryId]['message'] = $oSurveyMenuEntry->error;
}
}
}
else
} else
{
$aResults['global']['result'] = false;
$aResults['global']['message'] = gT('Nothing to update');
}

}
else
} else
{
$aResults['global']['result'] = false;
$aResults['global']['message'] = gT("We are sorry but you don't have permissions to do this.");
Expand Down Expand Up @@ -355,8 +355,9 @@ public function reorder()
public function loadModel($id)
{
$model = SurveymenuEntries::model()->findByPk($id);
if ($model === null)
throw new CHttpException(404, 'The requested page does not exist.');
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}

Expand Down

0 comments on commit 43ab5be

Please sign in to comment.