Implement permission check on pages used in link lists.
This commit is contained in:
16
index.php
16
index.php
@@ -91,6 +91,22 @@ Kirby::plugin(
|
||||
$pages = site()->index(true)->filterBy("linkLocation", $linkLocation);
|
||||
|
||||
foreach ($pages as $page) {
|
||||
if (kirby()->plugin("hobbyhome/permissions")) {
|
||||
// Hacky way of allowing us to run a hook multiple times from within another hook.
|
||||
$events = kirby()->events;
|
||||
call_user_func(
|
||||
\Closure::bind(
|
||||
function () use ($events) {
|
||||
unset($events->processed["permissions.page:check"]);
|
||||
}, null, $events
|
||||
)
|
||||
);
|
||||
|
||||
if (!$page->hasPerm()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($page->isDraft() && !($user = kirby()->user() and $user->role()->isAdmin())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user