mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Add forum thread and post policies
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use TeamTeaTime\Forum\Models\Post;
|
||||
|
||||
class PostPolicy extends \TeamTeaTime\Forum\Policies\PostPolicy
|
||||
{
|
||||
public function edit($user, Post $post): bool
|
||||
{
|
||||
// Admins can edit any post; users can edit their own
|
||||
return $user->hasRole('Admin') || ($user->getKey() === $post->author_id);
|
||||
}
|
||||
|
||||
public function delete($user, Post $post): bool
|
||||
{
|
||||
// Admins can delete any post; users can delete their own
|
||||
return $user->hasRole('Admin') || ($user->getKey() === $post->author_id);
|
||||
}
|
||||
|
||||
public function restore($user, Post $post): bool
|
||||
{
|
||||
// Admins can restore any post; users can restore their own
|
||||
return $user->hasRole('Admin') || ($user->getKey() === $post->author_id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use TeamTeaTime\Forum\Models\Thread;
|
||||
|
||||
class ThreadPolicy extends \TeamTeaTime\Forum\Policies\ThreadPolicy
|
||||
{
|
||||
public function view($user, Thread $thread): bool
|
||||
{
|
||||
// Everyone (including Admin) can view by default
|
||||
return parent::view($user, $thread);
|
||||
}
|
||||
|
||||
public function rename($user, Thread $thread): bool
|
||||
{
|
||||
// Admins can rename any thread; users can rename their own
|
||||
return $user->hasRole('Admin') || ($user->getKey() === $thread->author_id);
|
||||
}
|
||||
|
||||
public function reply($user, Thread $thread): bool
|
||||
{
|
||||
// Admins can reply even if locked; otherwise respect lock state
|
||||
return $user->hasRole('Admin') || (! $thread->locked);
|
||||
}
|
||||
|
||||
public function delete($user, Thread $thread): bool
|
||||
{
|
||||
// Admins can delete any thread; users can delete their own
|
||||
return $user->hasRole('Admin') || ($user->getKey() === $thread->author_id);
|
||||
}
|
||||
|
||||
public function restore($user, Thread $thread): bool
|
||||
{
|
||||
// Admins can restore any thread; users can restore their own
|
||||
return $user->hasRole('Admin') || ($user->getKey() === $thread->author_id);
|
||||
}
|
||||
|
||||
public function deletePosts($user, Thread $thread): bool
|
||||
{
|
||||
// Admins can delete posts in any thread; otherwise fall back to default (true)
|
||||
return $user->hasRole('Admin') || parent::deletePosts($user, $thread);
|
||||
}
|
||||
|
||||
public function restorePosts($user, Thread $thread): bool
|
||||
{
|
||||
// Admins can restore posts in any thread; otherwise fall back to default (true)
|
||||
return $user->hasRole('Admin') || parent::restorePosts($user, $thread);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"resources/css/app.css": {
|
||||
"file": "assets/app-CHtG3_Bv.css",
|
||||
"file": "assets/app-Ra66rJ-a.css",
|
||||
"src": "resources/css/app.css",
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/forum/livewire-tailwind/css/forum.css": {
|
||||
"file": "assets/forum-Dv9pV7PL.css",
|
||||
"file": "assets/forum-sBUJUSpH.css",
|
||||
"src": "resources/forum/livewire-tailwind/css/forum.css",
|
||||
"isEntry": true
|
||||
},
|
||||
"resources/forum/livewire-tailwind/js/forum.js": {
|
||||
"file": "assets/forum-DckUD3iN.js",
|
||||
"file": "assets/forum-DYii3E-X.js",
|
||||
"name": "forum",
|
||||
"src": "resources/forum/livewire-tailwind/js/forum.js",
|
||||
"isEntry": true,
|
||||
"css": [
|
||||
"assets/forum-qY4RLc9f.css"
|
||||
"assets/forum-B-iLUX4_.css"
|
||||
]
|
||||
},
|
||||
"resources/js/app.js": {
|
||||
"file": "assets/app-Xaw6OIO1.js",
|
||||
"file": "assets/app-CEsE5a7F.js",
|
||||
"name": "app",
|
||||
"src": "resources/js/app.js",
|
||||
"isEntry": true
|
||||
|
||||
Reference in New Issue
Block a user