diff --git a/extensions/suspend/LICENSE b/extensions/suspend/LICENSE index 1e346ea06..e6288c67a 100644 --- a/extensions/suspend/LICENSE +++ b/extensions/suspend/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2017 Toby Zerner +Copyright (c) 2014-2018 Toby Zerner Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/extensions/suspend/composer.json b/extensions/suspend/composer.json index 24b370c71..33b2830d7 100644 --- a/extensions/suspend/composer.json +++ b/extensions/suspend/composer.json @@ -15,7 +15,7 @@ "source": "https://github.com/flarum/flarum-ext-suspend" }, "require": { - "flarum/core": "^0.1.0-beta.6" + "flarum/core": "^0.1.0-beta.8" }, "autoload": { "psr-4": { diff --git a/extensions/suspend/js/forum/dist/extension.js b/extensions/suspend/js/forum/dist/extension.js index 0bf8c06f4..1a3219fea 100644 --- a/extensions/suspend/js/forum/dist/extension.js +++ b/extensions/suspend/js/forum/dist/extension.js @@ -71,7 +71,7 @@ System.register('flarum/suspend/components/SuspendUserModal', ['flarum/component m( 'label', { className: 'checkbox' }, - m('input', { type: 'radio', name: 'status', checked: !this.status(), onclick: m.withAttr('value', this.status) }), + m('input', { type: 'radio', name: 'status', checked: !this.status(), value: '', onclick: m.withAttr('value', this.status) }), app.translator.trans('flarum-suspend.forum.suspend_user.not_suspended_label') ), m( diff --git a/extensions/suspend/js/forum/src/components/SuspendUserModal.js b/extensions/suspend/js/forum/src/components/SuspendUserModal.js index 6175e9f34..4350e2e82 100644 --- a/extensions/suspend/js/forum/src/components/SuspendUserModal.js +++ b/extensions/suspend/js/forum/src/components/SuspendUserModal.js @@ -35,7 +35,7 @@ export default class SuspendUserModal extends Modal {
diff --git a/extensions/suspend/migrations/2017_07_22_000000_add_default_permissions.php b/extensions/suspend/migrations/2017_07_22_000000_add_default_permissions.php new file mode 100644 index 000000000..7f39b1fce --- /dev/null +++ b/extensions/suspend/migrations/2017_07_22_000000_add_default_permissions.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Flarum\Database\Migration; +use Flarum\Group\Group; + +return Migration::addPermissions([ + 'user.suspend' => Group::MODERATOR_ID +]); diff --git a/extensions/suspend/src/Access/UserPolicy.php b/extensions/suspend/src/Access/UserPolicy.php index 5708b5bfb..6493776ed 100644 --- a/extensions/suspend/src/Access/UserPolicy.php +++ b/extensions/suspend/src/Access/UserPolicy.php @@ -11,8 +11,8 @@ namespace Flarum\Suspend\Access; -use Flarum\Core\Access\AbstractPolicy; -use Flarum\Core\User; +use Flarum\User\AbstractPolicy; +use Flarum\User\User; class UserPolicy extends AbstractPolicy { diff --git a/extensions/suspend/src/Listener/AddClientAssets.php b/extensions/suspend/src/Listener/AddClientAssets.php deleted file mode 100644 index 4a80dacc2..000000000 --- a/extensions/suspend/src/Listener/AddClientAssets.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Suspend\Listener; - -use Flarum\Event\ConfigureWebApp; -use Illuminate\Contracts\Events\Dispatcher; - -class AddClientAssets -{ - /** - * @param Dispatcher $events - */ - public function subscribe(Dispatcher $events) - { - $events->listen(ConfigureWebApp::class, [$this, 'addAssets']); - } - - /** - * @param ConfigureClientView $event - */ - public function addAssets(ConfigureWebApp $event) - { - if ($event->isForum()) { - $event->addAssets([ - __DIR__.'/../../js/forum/dist/extension.js', - __DIR__.'/../../less/forum/extension.less' - ]); - $event->addBootstrapper('flarum/suspend/main'); - } - - if ($event->isAdmin()) { - $event->addAssets([ - __DIR__.'/../../js/admin/dist/extension.js', - __DIR__.'/../../less/admin/extension.less' - ]); - $event->addBootstrapper('flarum/suspend/main'); - } - } -} diff --git a/extensions/suspend/src/Listener/AddUserSuspendAttributes.php b/extensions/suspend/src/Listener/AddUserSuspendAttributes.php index 5049b81af..2d9865723 100755 --- a/extensions/suspend/src/Listener/AddUserSuspendAttributes.php +++ b/extensions/suspend/src/Listener/AddUserSuspendAttributes.php @@ -11,10 +11,10 @@ namespace Flarum\Suspend\Listener; +use Flarum\Api\Event\Serializing; use Flarum\Api\Serializer\UserSerializer; -use Flarum\Core\User; use Flarum\Event\ConfigureModelDates; -use Flarum\Event\PrepareApiAttributes; +use Flarum\User\User; use Illuminate\Contracts\Events\Dispatcher; class AddUserSuspendAttributes @@ -25,7 +25,7 @@ class AddUserSuspendAttributes public function subscribe(Dispatcher $events) { $events->listen(ConfigureModelDates::class, [$this, 'addDates']); - $events->listen(PrepareApiAttributes::class, [$this, 'addAttributes']); + $events->listen(Serializing::class, [$this, 'addAttributes']); } /** @@ -39,9 +39,9 @@ class AddUserSuspendAttributes } /** - * @param PrepareApiAttributes $event + * @param Serializing $event */ - public function addAttributes(PrepareApiAttributes $event) + public function addAttributes(Serializing $event) { if ($event->isSerializer(UserSerializer::class)) { $canSuspend = $event->actor->can('suspend', $event->model); diff --git a/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php b/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php index f9349f36b..2587d5b73 100755 --- a/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php +++ b/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php @@ -12,8 +12,8 @@ namespace Flarum\Suspend\Listener; use Carbon\Carbon; -use Flarum\Core\Group; use Flarum\Event\PrepareUserGroups; +use Flarum\Group\Group; use Illuminate\Contracts\Events\Dispatcher; class RevokeAccessFromSuspendedUsers diff --git a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php index 5a8e089f3..24c56d8a6 100755 --- a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php +++ b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php @@ -43,13 +43,13 @@ class SaveSuspensionToDatabase */ public function subscribe(Dispatcher $events) { - $events->listen(UserWillBeSaved::class, [$this, 'whenUserWillBeSaved']); + $events->listen(Saving::class, [$this, 'whenSavingUser']); } /** - * @param UserWillBeSaved $event + * @param Saving $event */ - public function whenUserWillBeSaved(UserWillBeSaved $event) + public function whenSavingUser(Saving $event) { $attributes = array_get($event->data, 'attributes', []); diff --git a/extensions/suspend/src/SuspendValidator.php b/extensions/suspend/src/SuspendValidator.php index 57daf0dd2..1b58684bf 100644 --- a/extensions/suspend/src/SuspendValidator.php +++ b/extensions/suspend/src/SuspendValidator.php @@ -11,7 +11,7 @@ namespace Flarum\Suspend; -use Flarum\Core\Validator\AbstractValidator; +use Flarum\Foundation\AbstractValidator; class SuspendValidator extends AbstractValidator { @@ -19,6 +19,6 @@ class SuspendValidator extends AbstractValidator * {@inheritdoc} */ protected $rules = [ - 'suspendUntil' => ['date'], + 'suspendUntil' => ['nullable', 'date'], ]; }