Permissions editor / translator

hello,

i don’t how to set permissions for admin / editor / translator

my structur is:

  • laender
    • austria
      • person

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

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.

What it is syntactically wrong ?

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?

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 ?

Try this:

 $this->target()->page()->roles() == 'translator'||
 $this->target()->page()->index()->filterBy('roles', 'translator')->count();
1 Like

Yes it works ! thanks for the early support @texnixe