Perry
December 29, 2017, 10:06pm
1
hello,
i don’t how to set permissions for admin / editor / translator
my structur is:
the blueprint for person:
roles:
label: Who can edit?
type: select
options:
admin: Admin
editor: Editor
translator: Translator
the site/roles/translator.php
<?php
// site/roles/translator.php
return [
'name' => 'Translator',
'default' => false,
'permissions' => [
'*' => true,
'panel.site.*' => false,
'panel.page.update' => true,
'panel.page.delete' => false,
'panel.page.create' => false,
'panel.page.read' => function() {
return
$this->target()->page()->roles() == 'translator'||
$this->target()->page()->children()->roles() == 'translator' ||
$this->target()->page()->children()->children()->roles() == 'translator'||
$this->target()->page()->children()->children()->children()->roles() == 'translator';
}
]
]
?>
my idea is
the admin set the permissions for editor
if the editor has write the text
he set the permissions for the translator
greetings perry
texnixe
December 29, 2017, 10:42pm
2
Too tired too look into this now, but you can’t call a field on multiple pages (i.e. a children collection). This
$this->target()->page()->children()->roles() == 'translator' ||
does not work because syntactically incorrect.
But the first condition should be sufficient anyway.
Perry
December 30, 2017, 8:36am
3
texnixe:
syntactically incorrect
What it is syntactically wrong ?
texnixe
December 30, 2017, 8:46am
4
Well, roles
is a field in your page, so that makes it a page method. You are calling that method on a children collection, though. I guess what you are trying to do here is to make all pages above person readable if the roles field for the person page is set to translator, right?
Perry
December 30, 2017, 9:00am
5
how to do:
if the user with the role translator is in the level ‘laender’ and in level ‘person’ the field ‘role’ == translator how to do all parent pages are visible for the translator ?
or is it not posible an I must have in each level a role field ?
texnixe
December 30, 2017, 9:10am
6
Try this:
$this->target()->page()->roles() == 'translator'||
$this->target()->page()->index()->filterBy('roles', 'translator')->count();
1 Like
Perry
December 30, 2017, 9:33am
7
Yes it works ! thanks for the early support @texnixe