You are here

public function OgEventSubscriber::provideDefaultOgPermissions in Organic groups 8

Provides default OG permissions.

Parameters

\Drupal\og\Event\PermissionEventInterface $event: The OG permission event.

File

src/EventSubscriber/OgEventSubscriber.php, line 102

Class

OgEventSubscriber
Event subscribers for Organic Groups.

Namespace

Drupal\og\EventSubscriber

Code

public function provideDefaultOgPermissions(PermissionEventInterface $event) {
  $event
    ->setPermissions([
    new GroupPermission([
      'name' => OgAccess::ADMINISTER_GROUP_PERMISSION,
      'title' => $this
        ->t('Administer group'),
      'description' => $this
        ->t('Manage group members and content in the group.'),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
      'restrict access' => TRUE,
    ]),
    new GroupPermission([
      'name' => OgAccess::DELETE_GROUP_PERMISSION,
      'title' => $this
        ->t('Delete group'),
      'description' => $this
        ->t('Delete the group entity.'),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
    ]),
    new GroupPermission([
      'name' => OgAccess::UPDATE_GROUP_PERMISSION,
      'title' => $this
        ->t('Edit group'),
      'description' => $this
        ->t('Edit the group entity.'),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
    ]),
    new GroupPermission([
      'name' => 'subscribe',
      'title' => $this
        ->t('Subscribe to group'),
      'description' => $this
        ->t('Allow non-members to request membership to a group (approval required).'),
      'roles' => [
        OgRoleInterface::ANONYMOUS,
      ],
      'default roles' => [
        OgRoleInterface::ANONYMOUS,
      ],
    ]),
    new GroupPermission([
      'name' => 'subscribe without approval',
      'title' => $this
        ->t('Subscribe to group (no approval required)'),
      'description' => $this
        ->t('Allow non-members to join a group without an approval from group administrators.'),
      'roles' => [
        OgRoleInterface::ANONYMOUS,
      ],
      'default roles' => [],
    ]),
    new GroupPermission([
      'name' => 'approve and deny subscription',
      'title' => $this
        ->t('Approve and deny subscription'),
      'description' => $this
        ->t("Users may allow or deny another user's subscription request."),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
    ]),
    new GroupPermission([
      'name' => 'add user',
      'title' => $this
        ->t('Add user'),
      'description' => $this
        ->t('Users may add other users to the group without approval.'),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
    ]),
    new GroupPermission([
      'name' => 'manage members',
      'title' => $this
        ->t('Manage members'),
      'description' => $this
        ->t('Users may remove group members and alter member status and roles.'),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
      'restrict access' => TRUE,
    ]),
    new GroupPermission([
      'name' => 'administer permissions',
      'title' => $this
        ->t('Administer permissions'),
      'description' => $this
        ->t('Users may view, create, edit and delete permissions and roles within the group.'),
      'default roles' => [
        OgRoleInterface::ADMINISTRATOR,
      ],
      'restrict access' => TRUE,
    ]),
  ]);

  // Add a list of generic CRUD permissions for all group content.
  $group_content_permissions = $this
    ->getDefaultEntityOperationPermissions($event
    ->getGroupContentBundleIds());
  $event
    ->setPermissions($group_content_permissions);
}