From cc285f6fc869fdebe1df22564ea87f352c167e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sevilla=20Mart=C3=ADn?= Date: Mon, 12 Feb 2018 08:34:36 -0500 Subject: [PATCH] fix merge conflicts --- extensions/suspend/bootstrap.php | 26 +++++++++++++------ .../src/Listener/SaveSuspensionToDatabase.php | 10 ++++--- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/extensions/suspend/bootstrap.php b/extensions/suspend/bootstrap.php index 9c15afe7f..98d44bdcc 100644 --- a/extensions/suspend/bootstrap.php +++ b/extensions/suspend/bootstrap.php @@ -9,16 +9,26 @@ * file that was distributed with this source code. */ +use Flarum\Extend; use Flarum\Suspend\Access; use Flarum\Suspend\Listener; use Illuminate\Contracts\Events\Dispatcher; -return function (Dispatcher $events) { - $events->subscribe(Listener\AddClientAssets::class); - $events->subscribe(Listener\AddUserSuspendAttributes::class); - $events->subscribe(Listener\RevokeAccessFromSuspendedUsers::class); - $events->subscribe(Listener\SaveSuspensionToDatabase::class); - $events->subscribe(Listener\SendNotificationWhenUserIsSuspended::class); +return [ + (new Extend\Assets('forum')) + ->asset(__DIR__.'/js/forum/dist/extension.js') + ->asset(__DIR__.'/less/forum/extension.less') + ->bootstrapper('flarum/suspend/main'), + (new Extend\Assets('admin')) + ->asset(__DIR__.'/js/admin/dist/extension.js') + ->asset(__DIR__.'/less/admin/extension.less') + ->bootstrapper('flarum/suspend/main'), + function (Dispatcher $events) { + $events->subscribe(Listener\AddUserSuspendAttributes::class); + $events->subscribe(Listener\RevokeAccessFromSuspendedUsers::class); + $events->subscribe(Listener\SaveSuspensionToDatabase::class); + $events->subscribe(Listener\SendNotificationWhenUserIsSuspended::class); - $events->subscribe(Access\UserPolicy::class); -}; + $events->subscribe(Access\UserPolicy::class); + } +]; diff --git a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php index e0f414423..5a8e089f3 100755 --- a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php +++ b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php @@ -12,11 +12,11 @@ namespace Flarum\Suspend\Listener; use DateTime; -use Flarum\Core\Access\AssertPermissionTrait; -use Flarum\Event\UserWillBeSaved; +use Flarum\Suspend\SuspendValidator; use Flarum\Suspend\Event\UserWasSuspended; use Flarum\Suspend\Event\UserWasUnsuspended; -use Flarum\Suspend\SuspendValidator; +use Flarum\User\AssertPermissionTrait; +use Flarum\User\Event\Saving; use Illuminate\Contracts\Events\Dispatcher; class SaveSuspensionToDatabase @@ -61,7 +61,9 @@ class SaveSuspensionToDatabase $this->assertCan($actor, 'suspend', $user); - $user->suspend_until = new DateTime($attributes['suspendUntil']); + $user->suspend_until = $attributes['suspendUntil'] + ? new DateTime($attributes['suspendUntil']) + : null; if (isset($attributes['suspendUntil'])) { $user->raise(new UserWasSuspended($user, $actor));