Skip to content

Commit

Permalink
Dev: Apply PSR-12
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Nov 10, 2021
1 parent 2220867 commit 7b9e671
Show file tree
Hide file tree
Showing 127 changed files with 1,412 additions and 1,360 deletions.
4 changes: 2 additions & 2 deletions application/controllers/HomepageSettingsController.php
Expand Up @@ -62,8 +62,8 @@ public function actionIndex()
'fullpagebar' => [
'boxbuttons' => true,
'returnbutton' => [
'url'=>'admin/index',
'text'=>gT('Back'),
'url' => 'admin/index',
'text' => gT('Back'),
],
],
'pageTitle' => gT('Dashboard'),
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/InstallerController.php
Expand Up @@ -635,7 +635,7 @@ public function checkPHPFunctionOrClass($sFunctionName, &$sImage)
$sImage = $this->check_HTML_image($bExists);
return $bExists;
}


/**
* check if file or directory exists and is writeable, returns via parameters by reference
Expand Down
8 changes: 4 additions & 4 deletions application/controllers/LimereplacementfieldsController.php
Expand Up @@ -40,7 +40,7 @@ public function actionIndex()

if ($newType) {
$newTypeResponse = $this->getNewTypeResponse($fieldtype, $surveyid, $gid, $qid);

return $this->renderPartial('/admin/super/_renderJson', ['data' => $newTypeResponse]);
}

Expand Down Expand Up @@ -470,7 +470,7 @@ private function collectQuestionReplacements($surveyid, $gid = null, $qid = null
$oSurvey = Survey::model()->findByPk($surveyid);
$oCurrentQuestion = Question::model()->findByPk($qid);
$aResult = [];

$oCriteria = new CDbCriteria();
$oCriteria->compare('t.sid', $surveyid);
$oCriteria->compare('parent_qid', 0);
Expand All @@ -492,7 +492,7 @@ private function collectQuestionReplacements($surveyid, $gid = null, $qid = null
}

$aQuestions = Question::model()->findAll($oCriteria);

uasort(
$aQuestions,
function ($a, $b) {
Expand All @@ -510,7 +510,7 @@ function ($a, $b) {

if (safecount($oQuestion->subquestions) != 0) {
$aSubquestions = $oQuestion->subquestions;

uasort($aSubquestions, function ($a, $b) {
return $a->question_order < $b->question_order ? -1 : 1;
});
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/PrintanswersController.php
Expand Up @@ -175,7 +175,7 @@ function actionView($surveyid, $printableexport = false)
$oPDF->writeHTML($html, true, false, true, false, '');

header("Cache-Control: must-revalidate, no-store, no-cache"); // Don't store in cache because it is sensitive data

$sExportFileName = sanitize_filename($sSurveyName);
$oPDF->Output($sExportFileName . "-" . $iSurveyID . ".pdf", "D");
LimeExpressionManager::FinishProcessingGroup();
Expand Down
11 changes: 6 additions & 5 deletions application/controllers/QuestionAdministrationController.php
@@ -1,4 +1,5 @@
<?php

/**
* Class QuestionAdministrationController
*/
Expand Down Expand Up @@ -227,13 +228,13 @@ public function renderFormAux(Question $question)

// Delete Button
$this->aData['showDeleteButton'] = true;

$this->aData['sid'] = $question->sid;
$this->aData['gid'] = $question->gid;
$this->aData['qid'] = $question->qid;

$this->aData['hasdefaultvalues'] = (QuestionTheme::findQuestionMetaData($question->type)['settings'])->hasdefaultvalues;

$generalSettings = $this->getGeneralOptions(
$question->qid,
$question->type,
Expand Down Expand Up @@ -1089,7 +1090,7 @@ public function actionImport()

$sFullFilepath = App()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
$fatalerror = '';

// Check file size and redirect on error
$uploadValidator = new LimeSurvey\Models\Services\UploadValidator();
$uploadValidator->redirectOnError('the_file', \Yii::app()->createUrl('questionAdministration/importView', array('surveyid' => $iSurveyID)));
Expand Down Expand Up @@ -1609,7 +1610,7 @@ public function actionCopyQuestion()
$oSurvey = Survey::model()->findByPk($surveyId);
$oQuestionGroup = QuestionGroup::model()->find('gid=:gid', array(':gid' => $questionGroupId));
$aData['surveyid'] = $surveyId; //this is important to load the correct layout (see beforeRender)

//array elements for frontend (topbar etc.)
$aData['sidemenu']['landOnSideMenuTab'] = 'structure';
$aData['title_bar']['title'] = $oSurvey->currentLanguageSettings->surveyls_title
Expand Down Expand Up @@ -1647,7 +1648,7 @@ public function actionCopyQuestion()
)
);
}

$newQuestionL10n = Yii::app()->request->getParam('questionI10N');
$copyQuestionTextValues = [];
if (!empty($newQuestionL10n)) {
Expand Down
Expand Up @@ -132,7 +132,7 @@ public function actionView($surveyid, $gid, $landOnSideMenuTab = 'structure', $m

$aData['title_bar']['title'] = $survey->currentLanguageSettings->surveyls_title
. " (" . gT("ID") . ":" . $iSurveyID . ")";

$aData['topBar']['name'] = 'baseTopbar_view';
$aData['topBar']['leftSideView'] = 'groupTopbarLeft_view';
$aData['topBar']['rightSideView'] = 'groupTopbarRight_view';
Expand Down Expand Up @@ -221,7 +221,7 @@ public function actionEdit($surveyid, $gid, $landOnSideMenuTab = 'structure')

$aData['title_bar']['title'] = $oSurvey->currentLanguageSettings->surveyls_title
. " (" . gT("ID") . ":" . $surveyid . ")";

// White Close Button
$aData['showWhiteCloseButton'] = true;
$aData['closeUrl'] = $this->createUrl(
Expand Down Expand Up @@ -301,7 +301,8 @@ public function actionAdd(int $surveyid, string $landOnSideMenuTab = 'structure'
[
'surveyid' => $surveyid
]
);;
);
;
///////////
// sidemenu
$aData['sidemenu']['state'] = false;
Expand Down Expand Up @@ -501,7 +502,7 @@ public function actionImportView($surveyid, $landOnSideMenuTab = 'structure')
$aData['topBar']['showSaveButton'] = true;*/
$aData['topBar']['name'] = 'baseTopbar_view';
$aData['topBar']['rightSideView'] = 'importGroupTopbarRight_view';


$aData['title_bar']['title'] = $survey->currentLanguageSettings->surveyls_title
. " (" . gT("ID") . ":" . $iSurveyID . ")";
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/RegisterController.php
Expand Up @@ -195,9 +195,9 @@ public function getRegisterErrors($iSurveyId)
public function getRegisterSuccess($iSurveyId, $iTokenId)
{
$oSurvey = Survey::model()->findByPk($iSurveyId);

$oToken = Token::model($iSurveyId)->findByPk($iTokenId)->decrypt();

$aData['active'] = $oSurvey->active;
$aData['iSurveyId'] = $iSurveyId;
$aData['sLanguage'] = App()->language;
Expand Down
3 changes: 1 addition & 2 deletions application/controllers/ResponsesController.php
Expand Up @@ -621,7 +621,7 @@ public function actionDownloadfile(int $surveyId, int $responseId, int $qid, int

if (Permission::model()->hasSurveyPermission($surveyId, 'responses', 'read')) {
$oResponse = Response::model($surveyId)->findByPk($responseId);
if (is_null($oResponse)){
if (is_null($oResponse)) {
App()->user->setFlash('error', gT('Found no response with ID %d'), $responseId);
$this->redirect(["responses/browse", "surveyId" => $surveyId]);
}
Expand Down Expand Up @@ -1024,5 +1024,4 @@ private function deleteResponse($surveyId, $iResponseId): array

return ['numberOfErrors' => $errors, 'numberOfTimingErrors' => $timingErrors];
}

}
6 changes: 3 additions & 3 deletions application/controllers/SurveyAdministrationController.php
Expand Up @@ -223,7 +223,7 @@ public function actionListsurveys()

// Create Survey Groups Button
$aData['fullpagebar']['listSurveys']['buttons']['createSurveyGroups'] = true;

// Return Button
$aData['fullpagebar']['returnbutton']['url'] = 'admin/index';
$aData['fullpagebar']['returnbutton']['text'] = gT('Back');
Expand Down Expand Up @@ -2038,7 +2038,7 @@ public function actionOrganize()

// Display 'Reorder question/question groups' in Green Bar
$aData['subaction'] = gT('Reorder question/question groups');

$this->aData = $aData;
$this->render('/admin/survey/organizeGroupsAndQuestions_view', $aData);
}
Expand Down Expand Up @@ -2839,7 +2839,7 @@ private function surveysummary(&$aData)

if ($oSurvey->currentLanguageSettings->surveyls_url != "") {
$aData['endurl'] = " <a target='_blank' href=\"" .
htmlspecialchars($aSurveyInfo['surveyls_url']) .
htmlspecialchars($aSurveyInfo['surveyls_url']) .
"\" title=\"" .
htmlspecialchars($aSurveyInfo['surveyls_url']) .
"\">" .
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/SurveysController.php
Expand Up @@ -155,7 +155,7 @@ public function spitOutHtmlError(array $error, $oException = null)
$aError['title'] = nl2br(CHtml::encode($error['message']));
$aError['message'] = $message;
$aError['contact'] = $contact;

if (App()->getConfig('debug') != 0) {
$aError['trace'] = $error['trace'];
}
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/ThemeOptionsController.php
Expand Up @@ -471,7 +471,7 @@ public function actionIndex()

// Green Bar Page Title
$aData['pageTitle'] = gT('Themes');

// White Bar with Buttons
$aData['fullpagebar']['returnbutton'] = [
'url' => 'admin/index',
Expand Down Expand Up @@ -693,7 +693,7 @@ private function updateCommon(TemplateConfiguration $model, int $sid = null, int
$oTemplate = $oModelWithInheritReplacement->prepareTemplateRendering($oModelWithInheritReplacement->template->name); // Fix empty file lists
$aTemplateConfiguration = $oTemplate->getOptionPageAttributes();
App()->clientScript->registerPackage('bootstrap-switch', LSYii_ClientScript::POS_BEGIN);

if ($aOptionAttributes['optionsPage'] == 'core') {
App()->clientScript->registerPackage('themeoptions-core');
$templateOptionPage = '';
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/UploaderController.php
Expand Up @@ -24,7 +24,7 @@ class UploaderController extends SurveyController
public function run($actionID)
{
$surveyid = Yii::app()->session['LEMsid'];
if(empty($surveyid)) {
if (empty($surveyid)) {
throw new CHttpException(401, gT("We are sorry but your session has expired."));
}
$oSurvey = Survey::model()->findByPk($surveyid);
Expand Down Expand Up @@ -300,7 +300,7 @@ public function run($actionID)
/* No action */
$meta = '';
App()->getClientScript()->registerPackage('question-file-upload');

$aSurveyInfo = getSurveyInfo($surveyid, $sLanguage);
$oEvent = new PluginEvent('beforeSurveyPage');
$oEvent->set('surveyId', $surveyid);
Expand Down
1 change: 1 addition & 0 deletions application/controllers/UserGroupController.php
@@ -1,4 +1,5 @@
<?php

/**
* class UserGroupController
**/
Expand Down
11 changes: 5 additions & 6 deletions application/controllers/UserManagementController.php
Expand Up @@ -166,20 +166,19 @@ public function actionApplyEdit()
]
]);
} else {

//generate random password when password is empty
if (empty($aUser['password'])) {
$newPassword = \LimeSurvey\Models\Services\PasswordManagement::getRandomPassword();
$aUser['password'] = $newPassword;
}

//retrive the raw password
$aUser['rawPassword'] = $aUser['password'];

$passwordSetByUser = Yii::app()->request->getParam('preset_password');
if($passwordSetByUser == 0){ //in this case admin has not set a password, email with link will be sent
if ($passwordSetByUser == 0) { //in this case admin has not set a password, email with link will be sent
$data = $this->createAdminUser($aUser);
}else{ //in this case admin has set a password, no email will be send ...just create user with given credentials
} else { //in this case admin has set a password, no email will be send ...just create user with given credentials
$data = $this->createAdminUser($aUser, false);
}

Expand Down Expand Up @@ -347,7 +346,7 @@ public function actionDeleteConfirm()
* @return string|null
* @throws CException
*/
public function actionViewUser(int $userid) : ?string
public function actionViewUser(int $userid): ?string
{
if (!Permission::model()->hasGlobalPermission('users', 'read')) {
return $this->renderPartial(
Expand Down Expand Up @@ -1257,7 +1256,7 @@ public function createNewUser(array $aUser): array
return Yii::app()->getController()->renderPartial('/admin/super/_renderJson', [
"data" => [
'success' => false,
'errors' => $event->get('errorMessageTitle')
'errors' => $event->get('errorMessageTitle')
. '<br/>'
. $event->get('errorMessageBody'),
'debug' => [
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/UserRoleController.php
Expand Up @@ -506,7 +506,7 @@ private function applyPermissionFromXML($iRoleId, $oPermissionObject)
* @param integer|null $ptid the ID of the model to be loaded
* @return Permissiontemplates the loaded model
*/
private function loadModel($ptid):Permissiontemplates
private function loadModel($ptid): Permissiontemplates
{
$model = Permissiontemplates::model()->findByPk($ptid);
if ($model === null) {
Expand All @@ -523,7 +523,7 @@ private function loadModel($ptid):Permissiontemplates
*
* @return string $errorDiv
*/
private function renderErrors(array $errors):string
private function renderErrors(array $errors): string
{
$errorDiv = '<ul class="list-unstyled">';
foreach ($errors as $key => $error) {
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/NotificationController.php
Expand Up @@ -59,7 +59,7 @@ public function notificationRead($notId)
if ($not->entity == 'user' && $not->entity_id <> Yii::app()->user->id) {
throw new CHttpException(404, sprintf(gT("Invalid notification id"), $notId));
}

$result = $not->markAsRead();
header('Content-type: application/json');
echo json_encode(array('result' => $result));
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/PluginHelper.php
Expand Up @@ -41,7 +41,7 @@ public function sidebody($surveyid = 0, $plugin = '', $method = '')
$aData['sidemenu']['state'] = false;
$aData['sideMenuBehaviour'] = getGlobalSetting('sideMenuBehaviour');
$aData['content'] = $content;

$aData['sideMenuOpen'] = false; // TODO: Assume this for all plugins?
$this->_renderWrappedTemplate(null, array('super/sidebody'), $aData);
}
Expand Down

0 comments on commit 7b9e671

Please sign in to comment.