Relax self edit/rename restrictions

- Fixes the last post not being self-editable if it's hidden
- Fixes the discussion not being self-renameable its only post is hidden
This commit is contained in:
Toby Zerner 2015-09-22 17:56:09 +09:30
parent 8a5a3a0624
commit 394ae32657
3 changed files with 5 additions and 2 deletions

View File

@ -24,6 +24,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Output forum description in meta description tag. ([#506](https://github.com/flarum/core/issues/506))
- Allow users to edit their last post in a discussion even if it's hidden.
- Allow users to rename their discussion even if their first post is hidden.
- Fix several design bugs.
## [0.1.0-beta.2] - 2015-09-15

View File

@ -48,7 +48,7 @@ class DiscussionsServiceProvider extends ServiceProvider
$allowRenaming = $settings->get('allow_renaming');
if ($allowRenaming === '-1' ||
($allowRenaming === 'reply' && $event->model->participants_count == 1) ||
($allowRenaming === 'reply' && $event->model->participants_count <= 1) ||
($event->model->start_time->diffInMinutes(Carbon::now()) < $allowRenaming)) {
return true;
}

View File

@ -55,11 +55,12 @@ class PostsServiceProvider extends ServiceProvider
if ($post->discussion->can($actor, 'editPosts')) {
return true;
}
if ($post->user_id == $actor->id && (! $post->hide_time || $post->hide_user_id == $actor->id)) {
$allowEditing = $settings->get('allow_post_editing');
if ($allowEditing === '-1' ||
($allowEditing === 'reply' && $event->model->number == $event->model->discussion->last_post_number) ||
($allowEditing === 'reply' && $event->model->number >= $event->model->discussion->last_post_number) ||
($event->model->time->diffInMinutes(Carbon::now()) < $allowEditing)) {
return true;
}