function apps_app_configure_permissions in Apps 7
Set the permissions for a role.
Parameters
$app: A fully loaded app object.
2 calls to apps_app_configure_permissions()
- apps_admin_permissions_revert_submit in ./
apps.pages.inc - Reverts the permission to default.
- user_apps_app_modules_enabled in ./
apps.module - Implements hook_apps_app_modules_enabled().
File
- ./
apps.module, line 696 - Module file for Apps
Code
function apps_app_configure_permissions($app) {
node_types_rebuild();
$modules = user_permission_get_modules();
if (!empty($app['permissions'])) {
$roles_to_permissions = array();
$roles = user_roles();
$warned = array();
foreach ($roles as $rid => $role_name) {
foreach ($app['permissions'] as $perm_name => $default_roles) {
if (empty($modules[$perm_name]) && empty($warned[$perm_name])) {
$warned[$perm_name] = TRUE;
$args = array(
'!name' => $perm_name,
'!module' => $app['machine_name'],
);
$msg = t('Warning in apps configuration of !module. No module defines permission "!name".', $args);
drupal_set_message($msg, 'warning');
}
else {
$roles_to_permissions[$rid][$perm_name] = in_array($role_name, $default_roles);
}
}
}
foreach ($roles_to_permissions as $rid => $permissions) {
user_role_change_permissions($rid, $permissions);
}
}
}