Rollen ausschließen: bei Inhalten (Zielgruppen) und für ganze Module
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m45s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m25s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m21s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m49s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m59s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m21s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m45s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m25s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m21s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m49s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m59s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m21s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m10s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
19193b850b
commit
1877a0922f
113 changed files with 699 additions and 428 deletions
|
|
@ -2,10 +2,15 @@
|
|||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Plugins\PluginAccess;
|
||||
use App\Plugins\PluginInstaller;
|
||||
use App\Plugins\PluginManager;
|
||||
use App\Plugins\PluginManifest;
|
||||
use App\Support\Audit;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
|
@ -38,6 +43,36 @@ class Plugins extends Page
|
|||
return auth()->user()?->can('plugins.manage') ?? false;
|
||||
}
|
||||
|
||||
/** Plugins ohne eigenen Bereich im Portal – für sie gibt es keinen „Zugang“. */
|
||||
private const WITHOUT_ACCESS = ['ldap', 'oidc', 'saml', 'wordpress-import'];
|
||||
|
||||
public function accessAction(): Action
|
||||
{
|
||||
return Action::make('access')
|
||||
->label('Zugang')
|
||||
->icon(Heroicon::OutlinedNoSymbol)
|
||||
->color('gray')
|
||||
->size('sm')
|
||||
->modalHeading(fn (array $arguments) => 'Zugang: '.(app(PluginManager::class)->find($arguments['slug'] ?? '')?->name ?? ''))
|
||||
->modalDescription('Personen mit einer dieser Rollen sehen den Bereich nicht: kein Menüpunkt, keine Seiten, keine Kacheln auf der Startseite, keine Suchtreffer. Wer Plugins verwalten darf, ist nie ausgeschlossen.')
|
||||
->fillForm(fn (array $arguments) => ['roles' => array_map('strval', app(PluginAccess::class)->excludedRoles($arguments['slug'] ?? ''))])
|
||||
->schema([
|
||||
Select::make('roles')
|
||||
->label('Ausgeschlossene Rollen')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->options(fn () => Role::query()->orderBy('name')->pluck('name', 'id')->mapWithKeys(fn ($name, $id) => [(string) $id => $name])->all()),
|
||||
])
|
||||
->modalSubmitActionLabel('Speichern')
|
||||
->action(function (array $data, array $arguments) {
|
||||
$slug = (string) ($arguments['slug'] ?? '');
|
||||
abort_unless(app(PluginManager::class)->find($slug), 404);
|
||||
app(PluginAccess::class)->exclude($slug, $data['roles'] ?? []);
|
||||
Audit::log('plugin.access', ['plugin' => $slug, 'excluded_roles' => array_map('intval', $data['roles'] ?? [])]);
|
||||
Notification::make()->success()->title('Zugang gespeichert')->send();
|
||||
});
|
||||
}
|
||||
|
||||
public function activate(string $slug, PluginManager $plugins): void
|
||||
{
|
||||
$this->run(fn () => $plugins->activate($slug), 'Plugin aktiviert', 'Die Änderungen sind ab dem nächsten Seitenaufruf sichtbar.');
|
||||
|
|
@ -95,6 +130,8 @@ class Plugins extends Page
|
|||
'enabled' => $plugins->isEnabled($m->slug),
|
||||
'problem' => $plugins->problem($m->slug) ?? (($issues = $m->incompatibilities()) ? implode(', ', $issues) : null),
|
||||
'dependents' => $plugins->dependents($m->slug),
|
||||
'accessible' => ! in_array($m->slug, self::WITHOUT_ACCESS, true),
|
||||
'excluded' => ($ids = app(PluginAccess::class)->excludedRoles($m->slug)) ? Role::query()->whereIn('id', $ids)->orderBy('name')->pluck('name')->all() : [],
|
||||
])->sortBy(fn (array $p) => [$p['manifest']->core ? 0 : 1, $p['manifest']->name])->values(),
|
||||
'uploadsAllowed' => PluginInstaller::uploadsAllowed(),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue