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 d717cb7 commit 94e3196
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 135 deletions.
17 changes: 10 additions & 7 deletions application/controllers/admin/ExpressionValidate.php
@@ -1,5 +1,7 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
/*
* Offer some way to validate Expression in survey
*
Expand Down Expand Up @@ -40,15 +42,15 @@ public function index()
*/
public function quota($iSurveyId, $quota, $lang = null)
{
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'read'))
throw new CHttpException(401, "401 Unauthorized");
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'quotas', 'read')) {
throw new CHttpException(401, "401 Unauthorized");
}
$iQuotaId = $quota;
if (is_string($lang))
{
$oValidator = new LSYii_Validators;
$aLangs = array($oValidator->languageFilter($lang));
}
else
} else
{
$aLangs = Survey::model()->findByPk($iSurveyId)->getAllLanguages();
}
Expand Down Expand Up @@ -97,8 +99,9 @@ public function quota($iSurveyId, $quota, $lang = null)
*/
public function email($iSurveyId, $lang)
{
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'read'))
throw new CHttpException(401, "401 Unauthorized");
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'read')) {
throw new CHttpException(401, "401 Unauthorized");
}
$sType = Yii::app()->request->getQuery('type');
$this->sLang = $sLang = $lang;
$this->iSurveyId = $iSurveyId; // This start the survey before Expression : is this allways needed ?
Expand Down
134 changes: 55 additions & 79 deletions application/controllers/admin/printablesurvey.php

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions application/controllers/admin/questions.php
Expand Up @@ -941,8 +941,7 @@ public function getSubquestionRow($surveyid, $gid, $qid, $codes, $language, $fir
if (ctype_digit($currentCharacter)) { // check if it's numerical
$numericSuffix = $currentCharacter.$numericSuffix; // store it in a string
$n = $n + 1;
}
else
} else
{
$numeric = false; // At first non numeric character found, the loop is stoped
}
Expand Down Expand Up @@ -1227,9 +1226,9 @@ public function index($sa, $surveyid, $gid, $qid = null)
{
if (!array_key_exists($esrow->language, $questlangs)) { // Language Exists, BUT ITS NOT ON THE SURVEY ANYMORE.
$esrow->delete();
} else {
$questlangs[$esrow->language] = 99;
}
else
$questlangs[$esrow->language] = 99;

if ($esrow->language == $baselang)
{
Expand Down Expand Up @@ -1924,8 +1923,9 @@ public function preview($surveyid, $qid, $lang = null)

// Prefill question/answer from defaultvalues
foreach ($_SESSION['survey_'.$surveyid]['fieldmap'] as $field) {
if (isset($field['defaultvalue']))
$_SESSION['survey_'.$surveyid][$field['fieldname']] = $field['defaultvalue'];
if (isset($field['defaultvalue'])) {
$_SESSION['survey_'.$surveyid][$field['fieldname']] = $field['defaultvalue'];
}
}

App()->setLanguage($language);
Expand Down
18 changes: 8 additions & 10 deletions application/controllers/admin/responses.php
Expand Up @@ -68,8 +68,7 @@ private function _getData($params)
if (!$thissurvey) { // Already done in Survey_Common_Action
Yii::app()->session['flashmessage'] = gT("Invalid survey ID");
$this->getController()->redirect(array("admin/index"));
}
elseif ($thissurvey['active'] != 'Y')
} elseif ($thissurvey['active'] != 'Y')
{
Yii::app()->session['flashmessage'] = gT("This survey has not been activated. There are no results to browse.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
Expand Down Expand Up @@ -674,22 +673,21 @@ public function actionDownloadfiles($iSurveyId, $sResponseId)
$aResponseId = $oSurvey->getCommandBuilder()
->createFindCommand($oSurvey->tableSchema, $oCriteria)
->queryColumn();
}
else
} else
{
$aResponseId = explode(",", $sResponseId);
}
if (!empty($aResponseId))
{
// Now, zip all the files in the filelist
if (count($aResponseId) == 1)
$zipfilename = "Files_for_survey_{$iSurveyId}_response_{$aResponseId[0]}.zip";
else
$zipfilename = "Files_for_survey_{$iSurveyId}.zip";
if (count($aResponseId) == 1) {
$zipfilename = "Files_for_survey_{$iSurveyId}_response_{$aResponseId[0]}.zip";
} else {
$zipfilename = "Files_for_survey_{$iSurveyId}.zip";
}

$this->_zipFiles($iSurveyId, $aResponseId, $zipfilename);
}
else
} else
{
// No response : redirect to browse with a alert
Yii::app()->setFlashMessage(gT("The requested files do not exist on the server."), 'error');
Expand Down
5 changes: 2 additions & 3 deletions application/core/LSETwigViewRenderer.php
Expand Up @@ -292,7 +292,7 @@ private function getAdditionalInfos($aDatas, $oTemplate)
if (!empty($aDatas['aSurveyInfo']['sid'])) {
if (Yii::app()->session['survey_'.$aDatas['aSurveyInfo']['sid']]['s_lang']) {
$languagecode = Yii::app()->session['survey_'.$aDatas['aSurveyInfo']['sid']]['s_lang'];
}elseif ($aDatas['aSurveyInfo']['sid'] && Survey::model()->findByPk($aDatas['aSurveyInfo']['sid'])) {
} elseif ($aDatas['aSurveyInfo']['sid'] && Survey::model()->findByPk($aDatas['aSurveyInfo']['sid'])) {
$languagecode = Survey::model()->findByPk($aDatas['aSurveyInfo']['sid'])->language;
}
}
Expand Down Expand Up @@ -341,8 +341,7 @@ public function addExtensions($extensions)
$sandbox = new Twig_Extension_Sandbox($policy, true);

$this->_twig->addExtension($sandbox);
}
else {
} else {
$this->_twig->addExtension(new $extName());
}
}
Expand Down
5 changes: 3 additions & 2 deletions application/core/LSYii_ClientScript.php
Expand Up @@ -381,8 +381,9 @@ public function renderCoreScripts()
{
foreach ($jsFilesPositioned as $position=>$fileArray) {
if (isset($this->scriptFiles[$position])) {
foreach ($this->scriptFiles[$position] as $url => $value)
$fileArray[$url] = $value;
foreach ($this->scriptFiles[$position] as $url => $value) {
$fileArray[$url] = $value;
}
}
$this->scriptFiles[$position] = $fileArray;
}
Expand Down
15 changes: 9 additions & 6 deletions application/core/LSYii_Controller.php
Expand Up @@ -90,14 +90,17 @@ protected function _init()
// Do not localize/translate this!

$dieoutput = '';
if (version_compare(PHP_VERSION, '5.3.3', '<'))
$dieoutput .= 'This script can only be run on PHP version 5.3.3 or later! Your version: '.PHP_VERSION.'<br />';
if (version_compare(PHP_VERSION, '5.3.3', '<')) {
$dieoutput .= 'This script can only be run on PHP version 5.3.3 or later! Your version: '.PHP_VERSION.'<br />';
}

if (!function_exists('mb_convert_encoding'))
$dieoutput .= "This script needs the PHP Multibyte String Functions library installed: See <a href='http://manual.limesurvey.org/wiki/Installation_FAQ'>FAQ</a> and <a href='http://de.php.net/manual/en/ref.mbstring.php'>PHP documentation</a><br />";
if (!function_exists('mb_convert_encoding')) {
$dieoutput .= "This script needs the PHP Multibyte String Functions library installed: See <a href='http://manual.limesurvey.org/wiki/Installation_FAQ'>FAQ</a> and <a href='http://de.php.net/manual/en/ref.mbstring.php'>PHP documentation</a><br />";
}

if ($dieoutput != '')
throw new CException($dieoutput);
if ($dieoutput != '') {
throw new CException($dieoutput);
}

if (ini_get("max_execution_time") < 1200) {
@set_time_limit(1200); // Maximum execution time - works only if safe_mode is off
Expand Down
6 changes: 2 additions & 4 deletions application/core/UserIdentity.php
Expand Up @@ -47,12 +47,10 @@ public function authenticate($sOneTimePassword = '')
$this->user = $user;
$this->errorCode = self::ERROR_NONE;
}
}
elseif (Yii::app()->getConfig("auth_webserver") === true && (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['LOGON_USER']) || isset($_SERVER['REMOTE_USER']))) { // normal login through webserver authentication
} elseif (Yii::app()->getConfig("auth_webserver") === true && (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['LOGON_USER']) || isset($_SERVER['REMOTE_USER']))) { // normal login through webserver authentication
if (isset($_SERVER['PHP_AUTH_USER'])) {
$sUser = $_SERVER['PHP_AUTH_USER'];
}
elseif (isset($_SERVER['REMOTE_USER'])) {
} elseif (isset($_SERVER['REMOTE_USER'])) {
$sUser = $_SERVER['REMOTE_USER'];
} else {
$sUser = $_SERVER['LOGON_USER'];
Expand Down
3 changes: 1 addition & 2 deletions application/helpers/admin/export/Writer.php
Expand Up @@ -327,8 +327,7 @@ final public function write(SurveyObj $oSurvey, $sLanguageCode, FormattingOption
$elementArray[] = $this->getShortAnswer($oSurvey, $oOptions, $column, $value);
break;
}
}
else { //Token table value
} else { //Token table value
$elementArray[] = $value;
}
}
Expand Down
3 changes: 1 addition & 2 deletions application/libraries/PluginManager/PluginBase.php
Expand Up @@ -181,8 +181,7 @@ public function publish($fileName)
{
$url = \Yii::getPathOfAlias('webroot').$fileName;

}
else
} else
{ // This is a plugin relative path.
$path = \Yii::getPathOfAlias('webroot.plugins.'.get_class($this)).DIRECTORY_SEPARATOR.$fileName;
/*
Expand Down
12 changes: 4 additions & 8 deletions application/libraries/Save.php
Expand Up @@ -212,16 +212,13 @@ function savedcontrol()
{
$this->aSaveErrors[] = gT("You may not use slashes or ampersands in your name or password.");
return;
}
elseif (!empty($duplicate) && $duplicate->count() > 0) { // OK - AR count
} elseif (!empty($duplicate) && $duplicate->count() > 0) { // OK - AR count
$this->aSaveErrors[] = gT("This name has already been used for this survey. You must use a unique save name.");
return;
}
elseif (!empty($_POST['saveemail']) && !validateEmailAddress($_POST['saveemail'])) { // Check if the email address is valid
} elseif (!empty($_POST['saveemail']) && !validateEmailAddress($_POST['saveemail'])) { // Check if the email address is valid
$errormsg .= gT("This is not a valid email address. Please provide a valid email address or leave it empty.")."<br />\n";
return;
}
else
} else
{
//INSERT BLANK RECORD INTO "survey_x" if one doesn't already exist
if (!isset($_SESSION['survey_'.$surveyid]['srid']))
Expand All @@ -236,8 +233,7 @@ function savedcontrol()
if (SurveyDynamic::model($thissurvey['sid'])->insert($sdata)) {
$srid = getLastInsertID($survey->responsesTableName);
$_SESSION['survey_'.$surveyid]['srid'] = $srid;
}
else
} else
{
safeDie("Unable to insert record into survey table.<br /><br />");
}
Expand Down
7 changes: 4 additions & 3 deletions application/models/ParticipantShare.php
Expand Up @@ -322,11 +322,12 @@ public function storeParticipantShare($data)
$ownerid = Yii::app()->db->createCommand()->select('*')->from('{{participants}}')->where('participant_id = :participant_id')->bindParam(":participant_id", $data['participant_id'], PDO::PARAM_STR)->queryRow();
// CHeck if share already exists
$arShare = self::findByPk(array('participant_id'=>$data['participant_id'], 'share_uid'=>$data['share_uid']));
if ($ownerid['owner_uid'] == $data['share_uid']) return;
if ($ownerid['owner_uid'] == $data['share_uid']) {
return;
}
if (is_null($arShare)) { // A check to ensure that the participant is not added to it's owner
Yii::app()->db->createCommand()->insert('{{participant_shares}}', $data);
}
else
} else
{
self::updateShare($data);
}
Expand Down
3 changes: 1 addition & 2 deletions application/models/QuestionGroup.php
Expand Up @@ -375,8 +375,7 @@ protected function beforeSave()
return false;
}
return true;
}
else {
} else {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/models/TemplateConfiguration.php
Expand Up @@ -156,7 +156,7 @@ public static function getInstanceFromTemplateName($sTemplateName) {
);

// If the survey configuration table of the wanted template doesn't exist (eg: manually deleted), then we provide the default one.
if (! is_a($oInstance, 'TemplateConfiguration') ){
if (!is_a($oInstance, 'TemplateConfiguration')) {
$oInstance = self::getInstanceFromTemplateName('default');
}

Expand Down

0 comments on commit 94e3196

Please sign in to comment.