26 lines
465 B
PHP
26 lines
465 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace KbAntoraImporter\Access;
|
|
|
|
use KbAntoraImporter\Plugin;
|
|
|
|
final class AccessController
|
|
{
|
|
public function canView(): bool
|
|
{
|
|
$settings = Plugin::settings();
|
|
|
|
return '1' === $settings['public_docs'] || is_user_logged_in() || current_user_can('view_kb_docs');
|
|
}
|
|
|
|
public function enforce(): void
|
|
{
|
|
if ($this->canView()) {
|
|
return;
|
|
}
|
|
|
|
auth_redirect();
|
|
}
|
|
}
|