Skip to content

Commit

Permalink
Merge pull request #90 from humhub/enh/php-cs-fixer
Browse files Browse the repository at this point in the history
Use PHP CS Fixer
  • Loading branch information
luke- authored Oct 3, 2024
2 parents 8a5b10f + 2c63b32 commit e772f1a
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 122 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: PHP CS Fixer

on: push

jobs:
fixers:
uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main
6 changes: 3 additions & 3 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public static function onFooterMenuInit($event)
$page = Page::getPage($pageKey);
if ($page !== null) {
$sortOrder += 10;
$event->sender->addItem(array(
$event->sender->addItem([
'label' => $page->title,
'url' => Url::to(['/legal/page/view', 'pageKey' => $pageKey], true),
'sortOrder' => $sortOrder,
));
]);
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ public static function onBeforeControllerAction(ActionEvent $event)
$event->result = Yii::$app->response->redirect(['/legal/page/update']);
}
// Show legal pages in full screen with confirm form, one by one (after account creation)
elseif($registrationCheck->showTermsCheck() || $registrationCheck->showPrivacyCheck()) {
elseif ($registrationCheck->showTermsCheck() || $registrationCheck->showPrivacyCheck()) {
$event->isValid = false;
$event->result = Yii::$app->response->redirect(['/legal/page/confirm']);
}
Expand Down
2 changes: 1 addition & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Module extends \humhub\components\Module
* @inheritdoc
*/
public $resourcesPath = 'resources';

/**
* @inheritdoc
*/
Expand Down
7 changes: 3 additions & 4 deletions assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@

class Assets extends AssetBundle
{

public $defer = true;

public $publishOptions = [
'forceCopy' => false
'forceCopy' => false,
];

public $sourcePath = '@legal/resources';
public $css = [
'cookieconsent.min.css'
'cookieconsent.min.css',
];
public $js = [
'cookieconsent.min.js'
'cookieconsent.min.js',
];

}
4 changes: 2 additions & 2 deletions assets/ContentAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ContentAssets extends AssetBundle
* @inheritdoc
*/
public $js = [
'js/humhub.legal.js'
'js/humhub.legal.js',
];

/**
Expand Down Expand Up @@ -51,4 +51,4 @@ public static function register($view)

return parent::register($view);
}
}
}
4 changes: 3 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php /** @noinspection MissedFieldInspection */
<?php

/** @noinspection MissedFieldInspection */

use humhub\commands\CronController;
use humhub\components\Controller;
Expand Down
5 changes: 2 additions & 3 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
class AdminController extends Controller
{

public function actionIndex()
{
$model = new ConfigureForm();
Expand Down Expand Up @@ -71,7 +70,7 @@ public function actionPage($pageKey)
'pages' => $pages,
'languages' => $languages,
'defaultLanguage' => $this->module->getDefaultLanguage(),
'pageKey' => $pageKey
'pageKey' => $pageKey,
]);
}

Expand Down Expand Up @@ -117,4 +116,4 @@ protected function getPages($pageKey)
return $pages;
}

}
}
148 changes: 74 additions & 74 deletions controllers/ExportController.php
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\legal\controllers;

use humhub\modules\legal\Module;
use humhub\modules\legal\services\ExportService;
use humhub\modules\user\components\BaseAccountController;
use Yii;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;

/* @property Module $module */
class ExportController extends BaseAccountController
{
/**
* @inheritdoc
*/
protected function getAccessRules()
{
return array_merge(parent::getAccessRules(), [
['checkEnabledExportUserData'],
]);
}

public function checkEnabledExportUserData($rule, $access)
{
return $this->module->isEnabledExportUserData();
}

public function actionIndex()
{
return $this->render('index', [
'service' => ExportService::instance(),
]);
}

public function actionRequest()
{
if (ExportService::instance()->requestPackage()) {
$this->view->success(Yii::t('LegalModule.base', 'The exporting of your data has been started, please wait some time.'));
} else {
$this->view->error('Cannot start the exporting of your data, please try again.');
}

return $this->redirect(['index']);
}

public function actionDownload()
{
$package = ExportService::instance()->downloadPackage();

if ($package === null) {
throw new NotFoundHttpException();
}

return $package;
}

public function actionDelete()
{
if (ExportService::instance()->deletePackage()) {
$this->view->success(Yii::t('LegalModule.base', 'The package has been deleted.'));
} else {
$this->view->error('Cannot delete the package, please try again.');
}

return $this->redirect(['index']);
}
}
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/

namespace humhub\modules\legal\controllers;

use humhub\modules\legal\Module;
use humhub\modules\legal\services\ExportService;
use humhub\modules\user\components\BaseAccountController;
use Yii;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;

/* @property Module $module */
class ExportController extends BaseAccountController
{
/**
* @inheritdoc
*/
protected function getAccessRules()
{
return array_merge(parent::getAccessRules(), [
['checkEnabledExportUserData'],
]);
}

public function checkEnabledExportUserData($rule, $access)
{
return $this->module->isEnabledExportUserData();
}

public function actionIndex()
{
return $this->render('index', [
'service' => ExportService::instance(),
]);
}

public function actionRequest()
{
if (ExportService::instance()->requestPackage()) {
$this->view->success(Yii::t('LegalModule.base', 'The exporting of your data has been started, please wait some time.'));
} else {
$this->view->error('Cannot start the exporting of your data, please try again.');
}

return $this->redirect(['index']);
}

public function actionDownload()
{
$package = ExportService::instance()->downloadPackage();

if ($package === null) {
throw new NotFoundHttpException();
}

return $package;
}

public function actionDelete()
{
if (ExportService::instance()->deletePackage()) {
$this->view->success(Yii::t('LegalModule.base', 'The package has been deleted.'));
} else {
$this->view->error('Cannot delete the package, please try again.');
}

return $this->redirect(['index']);
}
}
9 changes: 4 additions & 5 deletions controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function actionView($pageKey)

return $this->render('view', [
'page' => $page,
'canManagePages' => $this->canManagePages()
'canManagePages' => $this->canManagePages(),
]);
}

Expand All @@ -77,8 +77,7 @@ public function actionConfirm()
if ($model->showTermsCheck()) {
$model->restrictToSettingKey = RegistrationChecks::SETTING_KEY_TERMS;
$page = Page::getPage(Page::PAGE_KEY_TERMS);
}
elseif ($model->showPrivacyCheck()) {
} elseif ($model->showPrivacyCheck()) {
$model->restrictToSettingKey = RegistrationChecks::SETTING_KEY_PRIVACY;
$page = Page::getPage(Page::PAGE_KEY_PRIVACY_PROTECTION);
}
Expand All @@ -99,7 +98,7 @@ public function actionConfirm()
return $this->render('confirm', [
'page' => $page,
'model' => $model,
'module' => $this->module
'module' => $this->module,
]);
}

Expand Down Expand Up @@ -134,7 +133,7 @@ public function actionUpdate()
return $this->render('update', [
'page' => $page,
'model' => $model,
'module' => $this->module
'module' => $this->module,
]);
}

Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.4.3 (Unreleased)
--------------------------
- Fix #85: Fix downloading of large user export data file
- Enh #90: Use PHP CS Fixer

1.4.2 (September 13, 2024)
--------------------------
Expand Down
1 change: 0 additions & 1 deletion migrations/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class uninstall extends Migration
{

public function up()
{
$this->dropTable('legal_page');
Expand Down
16 changes: 8 additions & 8 deletions models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
/**
* This is the model class for table "legal_page".
*
* @property integer $id
* @property int $id
* @property string $page_key
* @property string $language
* @property string $title
* @property string $content
* @property integer $last_update
* @property int $last_update
*/
class Page extends ActiveRecord
{
const PAGE_KEY_IMPRINT = 'imprint';
const PAGE_KEY_TERMS = 'terms';
const PAGE_KEY_PRIVACY_PROTECTION = 'privacy';
const PAGE_KEY_COOKIE_NOTICE = 'cookies';
const PAGE_KEY_LEGAL_UPDATE = 'update';
public const PAGE_KEY_IMPRINT = 'imprint';
public const PAGE_KEY_TERMS = 'terms';
public const PAGE_KEY_PRIVACY_PROTECTION = 'privacy';
public const PAGE_KEY_COOKIE_NOTICE = 'cookies';
public const PAGE_KEY_LEGAL_UPDATE = 'update';

/**
* @inheritdoc
Expand Down Expand Up @@ -68,7 +68,7 @@ public function afterSave($insert, $changedAttributes)
public function rules()
{
return [
[['title', 'content'], 'safe']
[['title', 'content'], 'safe'],
];
}

Expand Down
9 changes: 4 additions & 5 deletions models/RegistrationChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
*/
class RegistrationChecks extends Model
{

const SETTING_KEY_TERMS = 'acceptedTerms';
const SETTING_KEY_PRIVACY = 'acceptedPrivacy';
const SETTING_KEY_AGE = 'acceptedAge';
public const SETTING_KEY_TERMS = 'acceptedTerms';
public const SETTING_KEY_PRIVACY = 'acceptedPrivacy';
public const SETTING_KEY_AGE = 'acceptedAge';

public $ageCheck;
public $termsCheck;
Expand Down Expand Up @@ -66,7 +65,7 @@ public function attributeLabels()
return [
'ageCheck' => Yii::t('LegalModule.base', 'I am older than {age} years', ['age' => \Yii::$app->getModule('legal')->getMinimumAge()]),
'termsCheck' => Yii::t('LegalModule.base', 'I have read and agree to the Terms and Conditions'),
'dataPrivacyCheck' => Yii::t('LegalModule.base', 'I have read and agree to the Privacy Policy')
'dataPrivacyCheck' => Yii::t('LegalModule.base', 'I have read and agree to the Privacy Policy'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/codeception/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ public function testPage(string $page, string $title, string $content, string $a
$this->amUser1(true);
$this->dontSee($title, '.panel-heading');
}
}
}
Loading

0 comments on commit e772f1a

Please sign in to comment.