diff --git a/extensions/suspend/js/src/forum/components/SuspendUserModal.js b/extensions/suspend/js/src/forum/components/SuspendUserModal.js index 4350e2e82..984cde8fd 100644 --- a/extensions/suspend/js/src/forum/components/SuspendUserModal.js +++ b/extensions/suspend/js/src/forum/components/SuspendUserModal.js @@ -5,7 +5,7 @@ export default class SuspendUserModal extends Modal { init() { super.init(); - let until = this.props.user.suspendUntil(); + let until = this.props.user.suspendedUntil(); let status = null; if (new Date() > until) until = null; @@ -81,21 +81,21 @@ export default class SuspendUserModal extends Modal { this.loading = true; - let suspendUntil = null; + let suspendedUntil = null; switch (this.status()) { case 'indefinitely': - suspendUntil = new Date('2038-01-01'); + suspendedUntil = new Date('2038-01-01'); break; case 'limited': - suspendUntil = moment().add(this.daysRemaining(), 'days').toDate(); + suspendedUntil = moment().add(this.daysRemaining(), 'days').toDate(); break; default: // no default } - this.props.user.save({suspendUntil}).then( + this.props.user.save({suspendedUntil}).then( () => this.hide(), this.loaded.bind(this) ); diff --git a/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js b/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js index 8333bc428..cb0f91895 100644 --- a/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js +++ b/extensions/suspend/js/src/forum/components/UserSuspendedNotification.js @@ -13,11 +13,11 @@ export default class UserSuspendedNotification extends Notification { content() { const notification = this.props.notification; - const suspendUntil = notification.content(); - const timeReadable = moment(suspendUntil.date).from(notification.time(), true); + const suspendedUntil = notification.content(); + const timeReadable = moment(suspendedUntil.date).from(notification.createdAt(), true); return app.translator.trans('flarum-suspend.forum.notifications.user_suspended_text', { - user: notification.sender(), + user: notification.fromUser(), timeReadable, }); } diff --git a/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js b/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js index 01ef72ab3..31bcb5ce1 100644 --- a/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js +++ b/extensions/suspend/js/src/forum/components/UserUnsuspendedNotification.js @@ -15,7 +15,7 @@ export default class UserUnsuspendedNotification extends Notification { const notification = this.props.notification; return app.translator.trans('flarum-suspend.forum.notifications.user_unsuspended_text', { - user: notification.sender(), + user: notification.fromUser(), }); } } diff --git a/extensions/suspend/js/src/forum/index.js b/extensions/suspend/js/src/forum/index.js index faf644700..95570a727 100644 --- a/extensions/suspend/js/src/forum/index.js +++ b/extensions/suspend/js/src/forum/index.js @@ -15,7 +15,7 @@ app.initializers.add('flarum-suspend', () => { app.notificationComponents.userUnsuspended = UserUnsuspendedNotification; User.prototype.canSuspend = Model.attribute('canSuspend'); - User.prototype.suspendUntil = Model.attribute('suspendUntil', Model.transformDate); + User.prototype.suspendedUntil = Model.attribute('suspendedUntil', Model.transformDate); extend(UserControls, 'moderationControls', (items, user) => { if (user.canSuspend()) { @@ -28,7 +28,7 @@ app.initializers.add('flarum-suspend', () => { }); extend(User.prototype, 'badges', function(items) { - const until = this.suspendUntil(); + const until = this.suspendedUntil(); if (new Date() < until) { items.add('suspended', Badge.component({ diff --git a/extensions/suspend/migrations/2018_06_27_111400_change_users_rename_suspend_until_to_suspended_until.php b/extensions/suspend/migrations/2018_06_27_111400_change_users_rename_suspend_until_to_suspended_until.php new file mode 100644 index 000000000..d67b23002 --- /dev/null +++ b/extensions/suspend/migrations/2018_06_27_111400_change_users_rename_suspend_until_to_suspended_until.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Flarum\Database\Migration; + +return Migration::renameColumn('users', 'suspend_until', 'suspended_until'); diff --git a/extensions/suspend/src/Listener/AddUserSuspendAttributes.php b/extensions/suspend/src/Listener/AddUserSuspendAttributes.php index 2d9865723..aa307c2d1 100755 --- a/extensions/suspend/src/Listener/AddUserSuspendAttributes.php +++ b/extensions/suspend/src/Listener/AddUserSuspendAttributes.php @@ -34,7 +34,7 @@ class AddUserSuspendAttributes public function addDates(ConfigureModelDates $event) { if ($event->isModel(User::class)) { - $event->dates[] = 'suspend_until'; + $event->dates[] = 'suspended_until'; } } @@ -47,7 +47,7 @@ class AddUserSuspendAttributes $canSuspend = $event->actor->can('suspend', $event->model); if ($canSuspend) { - $event->attributes['suspendUntil'] = $event->formatDate($event->model->suspend_until); + $event->attributes['suspendedUntil'] = $event->formatDate($event->model->suspended_until); } $event->attributes['canSuspend'] = $canSuspend; diff --git a/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php b/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php index 2587d5b73..9e6f395a8 100755 --- a/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php +++ b/extensions/suspend/src/Listener/RevokeAccessFromSuspendedUsers.php @@ -31,9 +31,9 @@ class RevokeAccessFromSuspendedUsers */ public function prepareUserGroups(PrepareUserGroups $event) { - $suspendUntil = $event->user->suspend_until; + $suspendedUntil = $event->user->suspended_until; - if ($suspendUntil && $suspendUntil->gt(Carbon::now())) { + if ($suspendedUntil && $suspendedUntil->gt(Carbon::now())) { $event->groupIds = [Group::GUEST_ID]; } } diff --git a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php index c9961defb..b2ab469ad 100755 --- a/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php +++ b/extensions/suspend/src/Listener/SaveSuspensionToDatabase.php @@ -59,7 +59,7 @@ class SaveSuspensionToDatabase { $attributes = array_get($event->data, 'attributes', []); - if (array_key_exists('suspendUntil', $attributes)) { + if (array_key_exists('suspendedUntil', $attributes)) { $this->validator->assertValid($attributes); $user = $event->user; @@ -67,13 +67,13 @@ class SaveSuspensionToDatabase $this->assertCan($actor, 'suspend', $user); - $user->suspend_until = $attributes['suspendUntil'] - ? new DateTime($attributes['suspendUntil']) + $user->suspended_until = $attributes['suspendedUntil'] + ? new DateTime($attributes['suspendedUntil']) : null; - if ($user->isDirty('suspend_until')) { + if ($user->isDirty('suspended_until')) { $this->events->dispatch( - $user->suspend_until === null ? + $user->suspended_until === null ? new Unsuspended($user, $actor) : new Suspended($user, $actor) ); diff --git a/extensions/suspend/src/Notification/UserSuspendedBlueprint.php b/extensions/suspend/src/Notification/UserSuspendedBlueprint.php index 52ac92d4a..ab24e8427 100644 --- a/extensions/suspend/src/Notification/UserSuspendedBlueprint.php +++ b/extensions/suspend/src/Notification/UserSuspendedBlueprint.php @@ -47,7 +47,7 @@ class UserSuspendedBlueprint implements BlueprintInterface /** * {@inheritdoc} */ - public function getSender() + public function getFromUser() { return $this->actor; } @@ -57,7 +57,7 @@ class UserSuspendedBlueprint implements BlueprintInterface */ public function getData() { - return $this->user->suspend_until; + return $this->user->suspended_until; } /** diff --git a/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php b/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php index d9e1806a8..33a6cf23c 100644 --- a/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php +++ b/extensions/suspend/src/Notification/UserUnsuspendedBlueprint.php @@ -47,7 +47,7 @@ class UserUnsuspendedBlueprint implements BlueprintInterface /** * {@inheritdoc} */ - public function getSender() + public function getFromUser() { return $this->actor; } diff --git a/extensions/suspend/src/SuspendValidator.php b/extensions/suspend/src/SuspendValidator.php index 1b58684bf..36e8dc5a4 100644 --- a/extensions/suspend/src/SuspendValidator.php +++ b/extensions/suspend/src/SuspendValidator.php @@ -19,6 +19,6 @@ class SuspendValidator extends AbstractValidator * {@inheritdoc} */ protected $rules = [ - 'suspendUntil' => ['nullable', 'date'], + 'suspendedUntil' => ['nullable', 'date'], ]; }