User or Group Permission on Languages

Hi there,

I just started to use cockpit ( it’s amazing !!! THX ).
I’m using Singeltons. I want to have n languages supported, but I want not all users or groups to have access to all languages. A user or a group should be limited to a subset of language. Is this possible? Thank you in advance for any help.

cheers,
Sebastian

There is no default option, to set such a permission.

Translated fields are internally stored with language suffixes. If your localized field name is title, there will be “hidden” fields like title_de, title_fr etc.

Do you need to limit the read access or is it enough to limit the write access?

You can use the event system to check against custom rules. Create a file /config/bootstrap.php.

$app->on('singleton.saveData.before.singleton_name', function($singleton, &$data) {

    // if user group is wrong
    // than unset fields with language suffix, e. g. "title_de"

});
2 Likes

you can also hook into the admin.init event to remove the languages for the admin ui

cockpit()->on('admin.init', function() {

    if (!in_array($this->module('cockpit')->getGroup(), ['admin', 'groupX'])) {

        $extract = $this->helper('admin')->data->get('extract');

        // remove unwanted languages

        unset($extract['languages'][1]);

        $this->helper('admin')->data['extract'] = $extract;
    }
});

Hi @raffaelj, @artur,

thank you for that quick response. This will do what I need.
THX a lot !!

cheers,
Sebastian