Skip to content

Commit

Permalink
Dev Scrutinizer indentation and 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 22, 2017
1 parent feb2ef0 commit 231773a
Show file tree
Hide file tree
Showing 30 changed files with 652 additions and 657 deletions.
20 changes: 13 additions & 7 deletions application/commands/WipeCommand.php
Expand Up @@ -109,15 +109,15 @@ public function run($sArgument)
$surveyidresult = dbGetTablesLike("survey\_%");
foreach ($surveyidresult as $sv)
{
if (strpos($sv, 'survey_links') === false && strpos($sv, 'survey_url_parameters') === false)
Yii::app()->db->createCommand("drop table ".$sv)->execute();
if (strpos($sv, 'survey_links') === false && strpos($sv, 'survey_url_parameters') === false) {
Yii::app()->db->createCommand("drop table ".$sv)->execute();
}
}
$sBaseUploadDir = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'upload';

SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'surveys', false);
SureRemoveDir($sBaseUploadDir.DIRECTORY_SEPARATOR.'templates', false);
}
else
} else
{
// TODO: a valid error process
echo 'This CLI command wipes a LimeSurvey installation clean (including all user except for the user ID 1 and user-uploaded content). For security reasons this command can only started if you add the parameter \'yes\' to the command line.';
Expand All @@ -130,10 +130,16 @@ public function run($sArgument)


function SureRemoveDir($dir, $DeleteMe) {
if (!$dh = @opendir($dir)) return;
if (!$dh = @opendir($dir)) {
return;
}
while (false !== ($obj = readdir($dh))) {
if ($obj == '.' || $obj == '..') continue;
if (!@unlink($dir.'/'.$obj)) SureRemoveDir($dir.'/'.$obj, true);
if ($obj == '.' || $obj == '..') {
continue;
}
if (!@unlink($dir.'/'.$obj)) {
SureRemoveDir($dir.'/'.$obj, true);
}
}
closedir($dh);
if ($DeleteMe) {
Expand Down
4 changes: 3 additions & 1 deletion application/config/config-sample-dblib.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');
}
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
Expand Down
4 changes: 3 additions & 1 deletion application/config/config-sample-mysql.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');
}
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
Expand Down
4 changes: 3 additions & 1 deletion application/config/config-sample-sqlsrv.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');
}
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
Expand Down
4 changes: 3 additions & 1 deletion application/config/packages.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');
}
/**
* Core packages , no third_party
* sees third_party.php for third party package
Expand Down
4 changes: 3 additions & 1 deletion application/config/third_party.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');
}

/**
* This file contains package definition for third party libraries.
Expand Down
120 changes: 60 additions & 60 deletions application/controllers/admin/themeoptions.php
Expand Up @@ -22,7 +22,7 @@ class themeoptions extends Survey_Common_Action
/**
* @param string $controller
*/
public function __construct($controller=null, $id=null)
public function __construct($controller = null, $id = null)
{
parent::__construct($controller, $id);
}
Expand All @@ -33,12 +33,12 @@ public function __construct($controller=null, $id=null)
*/
public function view($id)
{
if ( Permission::model()->hasGlobalPermission('templates','read')){
if (Permission::model()->hasGlobalPermission('templates', 'read')) {
$this->_renderWrappedTemplate('themeoptions', 'read', array(
'model'=>$this->loadModel($id),
));
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(App()->createUrl("/admin"));
}

Expand All @@ -50,21 +50,21 @@ public function view($id)
*/
public function create()
{
if ( Permission::model()->hasGlobalPermission('templates','update')){
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
$model = new TemplateOptions;

if(isset($_POST['TemplateOptions'])){
$model->attributes=$_POST['TemplateOptions'];
if($model->save()){
if (isset($_POST['TemplateOptions'])) {
$model->attributes = $_POST['TemplateOptions'];
if ($model->save()) {
$this->getController()->redirect(array('admin/themeoptions/sa/update/id/'.$model->id));
}
}

$this->render('create',array(
$this->render('create', array(
'model'=>$model,
));
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(array("admin/themeoptions"));
}
}
Expand All @@ -77,20 +77,20 @@ public function create()
*/
public function update($id)
{
if ( Permission::model()->hasGlobalPermission('templates', 'update')){
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
$model = $this->loadModel($id);

if(isset($_POST['TemplateConfiguration'])){
$model->attributes=$_POST['TemplateConfiguration'];
if($model->save()) {
if (isset($_POST['TemplateConfiguration'])) {
$model->attributes = $_POST['TemplateConfiguration'];
if ($model->save()) {
Yii::app()->user->setFlash('success', gT('Theme options saved.'));
$this->getController()->redirect(array('admin/themeoptions/sa/update/id/'.$model->id));
}
}

$this->_updateCommon($model);
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions"));
}
}
Expand All @@ -102,21 +102,21 @@ public function update($id)
*/
public function updatesurvey($sid)
{
if ( Permission::model()->hasGlobalPermission('templates', 'update')){
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
$model = TemplateConfiguration::getInstance(null, null, $sid);

if(isset($_POST['TemplateConfiguration'])){
$model->attributes=$_POST['TemplateConfiguration'];
if($model->save()) {
if (isset($_POST['TemplateConfiguration'])) {
$model->attributes = $_POST['TemplateConfiguration'];
if ($model->save()) {
Yii::app()->user->setFlash('success', gT('Theme options saved.'));
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions/sa/updatesurvey",['surveyid'=>$sid,'sid'=>$sid]));
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions/sa/updatesurvey", ['surveyid'=>$sid, 'sid'=>$sid]));
}
}

$this->_updateCommon($model, $sid);
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions/sa/updatesurvey",['surveyid'=>$sid,'sid'=>$sid]));
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/themeoptions/sa/updatesurvey", ['surveyid'=>$sid, 'sid'=>$sid]));
}
}

Expand All @@ -125,25 +125,25 @@ public function updatesurvey($sid)
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function updatesurveygroup($id=null, $gsid)
public function updatesurveygroup($id = null, $gsid)
{
if ( Permission::model()->hasGlobalPermission('templates', 'update')){
$sTemplateName = $id !==null ? TemplateConfiguration::model()->findByPk($id)->template_name : null;
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
$sTemplateName = $id !== null ? TemplateConfiguration::model()->findByPk($id)->template_name : null;
$model = TemplateConfiguration::getInstance($sTemplateName, $gsid);

if(isset($_POST['TemplateConfiguration'])){
if (isset($_POST['TemplateConfiguration'])) {
$model = TemplateConfiguration::getInstance($_POST['TemplateConfiguration']['template_name'], $gsid);
$model->attributes=$_POST['TemplateConfiguration'];
if($model->save()) {
$model->attributes = $_POST['TemplateConfiguration'];
if ($model->save()) {
Yii::app()->user->setFlash('success', gT('Theme options saved.'));
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/surveysgroups/sa/update/",['id'=>$gsid]));
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/surveysgroups/sa/update/", ['id'=>$gsid]));
}
}

$this->_updateCommon($model);
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/surveysgroups/sa/update/",['id'=>$gsid]));
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(Yii::app()->getController()->createUrl("/admin/surveysgroups/sa/update/", ['id'=>$gsid]));
}
}

Expand All @@ -152,13 +152,13 @@ public function updatesurveygroup($id=null, $gsid)
*/
public function index()
{
if ( Permission::model()->hasGlobalPermission('templates', 'read') ){
if (Permission::model()->hasGlobalPermission('templates', 'read')) {
$model = new TemplateConfiguration();
$aData = array();
$aData['model'] = $model;
$this->_renderWrappedTemplate('themeoptions', 'index', $aData);
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(App()->createUrl("/admin"));
}
}
Expand All @@ -168,18 +168,18 @@ public function index()
*/
public function admin()
{
if ( Permission::model()->hasGlobalPermission('templates','read')){
$model=new TemplateOptions('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['TemplateOptions'])){
$model->attributes=$_GET['TemplateOptions'];
if (Permission::model()->hasGlobalPermission('templates', 'read')) {
$model = new TemplateOptions('search');
$model->unsetAttributes(); // clear any default values
if (isset($_GET['TemplateOptions'])) {
$model->attributes = $_GET['TemplateOptions'];
}

$this->render('admin',array(
$this->render('admin', array(
'model'=>$model,
));
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(App()->createUrl("/admin"));
}
}
Expand All @@ -193,9 +193,9 @@ public function admin()
*/
public function loadModel($id)
{
$model=TemplateConfiguration::model()->findByPk($id);
if($model===null){
throw new CHttpException(404,'The requested page does not exist.');
$model = TemplateConfiguration::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}

return $model;
Expand All @@ -204,26 +204,26 @@ public function loadModel($id)

public function importManifest($templatename)
{
if ( Permission::model()->hasGlobalPermission('templates', 'update')){
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
TemplateManifest::importManifest($templatename);
$this->getController()->redirect(array("admin/themeoptions"));
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
$this->getController()->redirect(array("admin/themeoptions"));
}

}

public function uninstall($templatename)
{
if ( Permission::model()->hasGlobalPermission('templates','update')){
if (!Template::hasInheritance($templatename)){
if (Permission::model()->hasGlobalPermission('templates', 'update')) {
if (!Template::hasInheritance($templatename)) {
TemplateConfiguration::uninstall($templatename);
}else{
} else {
Yii::app()->setFlashMessage(sprintf(gT("You can't uninstall template '%s' because some templates inherit from it."), $templatename), 'error');
}
}else{
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."),'error');
} else {
Yii::app()->setFlashMessage(gT("We are sorry but you don't have permissions to do this."), 'error');
}

$this->getController()->redirect(array("admin/themeoptions"));
Expand All @@ -235,7 +235,7 @@ public function uninstall($templatename)
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='template-options-form'){
if (isset($_POST['ajax']) && $_POST['ajax'] === 'template-options-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
Expand All @@ -248,7 +248,7 @@ protected function performAjaxValidation($model)
* @param int $sid
* @return void
*/
private function _updateCommon(TemplateConfiguration $model,$sid=null)
private function _updateCommon(TemplateConfiguration $model, $sid = null)
{
$oModelWithInheritReplacement = TemplateConfiguration::model()->findByPk($model->id);
$templateOptionPage = $oModelWithInheritReplacement->optionPage;
Expand All @@ -259,7 +259,7 @@ private function _updateCommon(TemplateConfiguration $model,$sid=null)
'templateOptionPage' => $templateOptionPage
);

if($sid !== null){
if ($sid !== null) {
$aData['surveybar']['savebutton']['form'] = true;
$aData['surveyid'] = $sid;
$aData['title_bar']['title'] = gT("Survey template options");
Expand Down

0 comments on commit 231773a

Please sign in to comment.