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.
Comment | File | Size | Author |
---|---|---|---|
#2 | apps-permissions-2447209-2.patch | 2.12 KB | andyrigby |
Comments
Comment #1
andyrigby CreditAttribution: andyrigby commentedComment #2
andyrigby CreditAttribution: andyrigby commentedAttached a patch with proposed solution.
Comment #3
hefox CreditAttribution: hefox commentedTis modeled after features, and follows the some logic to my memory