You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which goal is to allow the creation of sub-objects if the logged-in user has the create permissions on the parent as well.
I also needed to update the theme with a function that kicks in to add the user as the author by default, so that it inherits the permissions. Otherwise, Joe does not have any access to the page:
/** * Handle restrictions and initialization of the theme as early as possible. * […] */publicfunctiononThemeInitialized(Event$event)
{
[…]
$this->enable([
'onAdminCreatePageFrontmatter' => [
[ 'addPermissionsToPageOwned', 1 ],
],
]);
}
/** * [onAdminCreatePageFrontmatter] * Add the current user as author in the header when creating a page. * Also allows them to delete the page they created. * […] */publicfunctionaddPermissionsToPageOwned( Event$event )
{
$page = $event;
$header = $page['header'];
if (!isset($header['permissions']['authors'])) {
$header['permissions']['authors'] = [
$this->grav['admin']->user->get('username')
];
}
$header['permissions']['groups']['authors']['delete'] = true;
$event['header'] = $header;
}
Not sure if it’s any good way to solve this Issue and if it does not create other issues, but it works for me™ for now. :)
The text was updated successfully, but these errors were encountered:
I basically changed $object->isAuthorized('create') behavior so that it automatically detects if you are creating the current page or if you are asking if you can create a new page under the existing page.
In short:
If the page exists, create has the current behavior: can you create a page under the current page?
If the page does not exist, create has a new behavior: can you create this page under the parent page?
PS: This is a backward-incompatible change and causes no access to the new page if you rely on the old behavior.
This Issue is detailing the discussion I initiated on Discord.
With this structure as example:
I tried the following on the function taskSave in flex-objects/classes/Admin/AdminController.php, from:
to:
which goal is to allow the creation of sub-objects if the logged-in user has the create permissions on the parent as well.
I also needed to update the theme with a function that kicks in to add the user as the author by default, so that it inherits the permissions. Otherwise, Joe does not have any access to the page:
Not sure if it’s any good way to solve this Issue and if it does not create other issues, but it works for me™ for now. :)
The text was updated successfully, but these errors were encountered: