Jump to content

Module permissions on the demo


Recommended Posts

Hi,

I'm setting up a module demo and I want to only enable the Configure button

3.jpg.7631e37d9451025610eb4a37fe42bddb.jpg

Is there a way to do it?

I tried to to it using the permissions but no luck

1.thumb.jpg.9decff59d67b33e998aba60667ff9d6e.jpg

2.thumb.jpg.1ee168cf8b23d54f8f6cdce62538c76c.jpg

When I remove the Edit permission from the module, the configure button is removed altogether

Any help is much appreciated

Thanks

Edited by Tuni-Soft (see edit history)
Link to comment
Share on other sites

I solved it by modifying this method directly

 

// /src/Adapter/Module/AdminModuleDataProvider.php

public function isAllowedAccess($action, $name = '')
{
    if (Tools::isPHPCLI()) {
        return true;
    }

    if (in_array($action, ['install', 'upgrade'])) {
        return $this->employee->can('add', 'AdminModulessf');
    }

    if ('uninstall' === $action) {
        return $this->employee->can('delete', 'AdminModulessf') && $this->moduleProvider->can('uninstall', $name);
    }

    // add this statement
    if (in_array($action, array('enable', 'disable', 'enable_mobile', 'disable_mobile', 'reset'))) {
        return $this->employee->isSuperAdmin();
    }

    return $this->employee->can('edit', 'AdminModulessf') && $this->moduleProvider->can('configure', $name);
}

or like this

public function isAllowedAccess($action, $name = '')
{
    if (Tools::isPHPCLI()) {
        return true;
    }

    if (in_array($action, ['install', 'upgrade', 'enable', 'enable_mobile'])) {
        return $this->employee->can('add', 'AdminModulessf');
    }

    if (in_array($action, ['uninstall', 'reset', 'disable', 'disable_mobile'])) {
        return $this->employee->can('delete', 'AdminModulessf') && $this->moduleProvider->can('uninstall', $name);
    }

    return $this->employee->can('edit', 'AdminModulessf') && $this->moduleProvider->can('configure', $name);
}

 

Edited by Tuni-Soft (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...