mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
85 lines
1.9 KiB
PHP
85 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\User;
|
|
use TeamTeaTime\Forum\Models\Category;
|
|
|
|
class CategoryPolicy extends \TeamTeaTime\Forum\Policies\CategoryPolicy
|
|
{
|
|
/**
|
|
* Create a new policy instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function manageThreads(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function deleteThreads(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function restoreThreads(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function enableThreads(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function moveThreadsFrom(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function moveThreadsTo(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function lockThreads(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function pinThreads(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function view(mixed $user, Category $category): bool
|
|
{
|
|
return $this->canViewCategory($user);
|
|
}
|
|
|
|
public function delete(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
public function edit(mixed $user, Category $category): bool
|
|
{
|
|
return $this->isAdmin($user);
|
|
}
|
|
|
|
private function isAdmin(mixed $user): bool
|
|
{
|
|
return $user instanceof User && $user->hasRole('Admin');
|
|
}
|
|
|
|
private function canViewCategory(mixed $user): bool
|
|
{
|
|
return $user instanceof User && $user->hasAnyRole(['Admin', 'Moderator']);
|
|
}
|
|
}
|