Skip to content

Commit

Permalink
Simplified acl for next omeka version (see #omeka/omeka-s/pull/2241).
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Dec 9, 2024
1 parent 2d21d7d commit bc6102c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,22 @@ protected function preInstall(): void
);
throw new \Omeka\Module\Exception\ModuleCannotInstallException((string) $message);
}

// Required during install because the role is set in config.
require_once __DIR__ . '/src/Permissions/Acl.php';
}

protected function preUninstall(): void
{
$this->deactivateGuests();
}

protected function preUpgrade(): void
{
// Required during upgrade because the role is set in config.
require_once __DIR__ . '/src/Permissions/Acl.php';
}

/**
* Add ACL role and rules for this module.
*/
Expand All @@ -104,6 +113,9 @@ protected function addAclRoleAndRules(): void
$services = $this->getServiceLocator();
$acl = $services->get('Omeka\Acl');

// TODO To be removed when roles will be integrated in core.
/** @see https://github.com/omeka/omeka-s/pull/2241 */

// This check allows to add the role "guest" by dependencies without
// complex process. It avoids issues when the module is disabled too.
// TODO Find a way to set the role "guest" during init or via Omeka\Service\AclFactory (allowing multiple delegators).
Expand Down
10 changes: 10 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

namespace Guest;

use \Guest\Permissions\Acl as GuestAcl;

return [
'acl' => [
'roles' => [
GuestAcl::ROLE_GUEST=> [],
],
'labels' => [
GuestAcl::ROLE_GUEST => 'Guest', // @translate
],
],
'entity_manager' => [
'mapping_classes_paths' => [
dirname(__DIR__) . '/src/Entity',
Expand Down
2 changes: 1 addition & 1 deletion src/Permissions/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Guest\Permissions;

class Acl extends \Omeka\Permissions\Acl
class Acl
{
const ROLE_GUEST = 'guest';
}

0 comments on commit bc6102c

Please sign in to comment.