mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
Implement "move" permission
This commit is contained in:
3
extensions/tags/js/bootstrap.js
vendored
3
extensions/tags/js/bootstrap.js
vendored
@@ -35,6 +35,7 @@ app.initializers.add('categories', function() {
|
||||
// Register models.
|
||||
app.store.models['categories'] = Category;
|
||||
Discussion.prototype.category = Model.one('category');
|
||||
Discussion.prototype.canMove = Model.prop('canMove');
|
||||
|
||||
// Register components.
|
||||
app.postComponentRegistry['discussionMoved'] = PostDiscussionMoved;
|
||||
@@ -140,7 +141,7 @@ app.initializers.add('categories', function() {
|
||||
|
||||
// Add a control allowing the discussion to be moved to another category.
|
||||
extend(Discussion.prototype, 'controls', function(items) {
|
||||
if (this.canEdit()) {
|
||||
if (this.canMove()) {
|
||||
items.add('move', ActionButton.component({
|
||||
label: 'Move',
|
||||
icon: 'arrow-right',
|
||||
|
@@ -9,6 +9,7 @@ use Flarum\Extend\NotificationType;
|
||||
use Flarum\Extend\Relationship;
|
||||
use Flarum\Extend\SerializeRelationship;
|
||||
use Flarum\Extend\ApiInclude;
|
||||
use Flarum\Extend\Permission;
|
||||
|
||||
class CategoriesServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -41,7 +42,14 @@ class CategoriesServiceProvider extends ServiceProvider
|
||||
|
||||
new SerializeRelationship('Flarum\Api\Serializers\DiscussionSerializer', 'hasOne', 'category', 'Flarum\Categories\CategorySerializer'),
|
||||
|
||||
new ApiInclude(['discussions.index', 'discussions.show'], 'category', true)
|
||||
new ApiInclude(['discussions.index', 'discussions.show'], 'category', true),
|
||||
|
||||
(new Permission('discussion.move'))
|
||||
->serialize()
|
||||
->grant(function ($grant, $user) {
|
||||
$grant->where('start_user_id', $user->id);
|
||||
// @todo add limitations to time etc. according to a config setting
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user