initial COmmit: Add KB Antora Importer plugin files
This commit is contained in:
25
kb-antora-importer/includes/Access/AccessController.php
Normal file
25
kb-antora-importer/includes/Access/AccessController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user