Hi, I have an issue with apps install which could be a misunderstanding, but I think it's a bug.

Problem/Motivation

When apps installs an app that has permissions specified in hook_apps_app_info(), roles not specified in the hook have the permission removed.

e.g.

administrator is an existing role on the site. It has 'administer blocks' permission.

'myapp editor' is a new role created by install of app 'myapp'.

The hook implementation is:

/**
 * Implements hook_apps_app_info().
 */
function myapp_apps_app_info() {
  return array(
    'permissions' => array(
      'administer blocks' => array(
        "myapp editor",
      ),
    ),
  );
}

On myapp install, 'myapp editor' is assigned the 'administer blocks' permission, but it is removed from the administrator role.

I believe that apps should only affect roles that are specified in the hook

Proposed resolution

apps_app_configure_permissions() would need modification. It should only apply permissions to roles specified in the hook.

An alternative (untested) would be to make the hook dynamic. When called, it would read all roles, and uses user_role_permissions() (or similar) to populate the 'permissions' key.

User interface changes

None - I don't see any problem with showing all roles and allowing user to assign the permissions defined in the hook. The issue is with the install behaviour.

API changes

Relying on hook to remove permissions would no longer work.

CommentFileSizeAuthor
#2 apps-permissions-2447209-2.patch2.12 KBandyrigby
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andyrigby’s picture

Issue summary: View changes
andyrigby’s picture

Attached a patch with proposed solution.

hefox’s picture

Title: App install removes permission for all roles not specified in hook_apps_app_info() » Change App install to only ad permissions, not remove, when used in hook_apps_app_info()
Category: Bug report » Feature request

Tis modeled after features, and follows the some logic to my memory