function og_features_permission_features_rebuild in Organic groups 7.2
Implements hook_features_rebuild().
Iterates through default permissions and update the permissions map.
Parameters
string $module: The modules whose default user permissions should be rebuild.
1 call to og_features_permission_features_rebuild()
- og_features_permission_features_revert in includes/
og_features_permission.features.inc - Implements hook_features_revert().
File
- includes/
og_features_permission.features.inc, line 123 - Integration with features for og permissions.
Code
function og_features_permission_features_rebuild($module) {
require_once dirname(__FILE__) . '/og_features_role.features.inc';
if ($defaults = features_get_default('og_features_permission', $module)) {
$grant = array();
$revoke = array();
foreach ($defaults as $key => $details) {
list($group_type, $bundle, $perm) = explode(':', $key);
// Make sure the role exists for this entity.
foreach ($details['roles'] as $role) {
$bundle_role = _og_features_role_exists($role, $group_type, $bundle);
if (empty($bundle_role)) {
og_role_save(og_role_create($role, $group_type, 0, $bundle));
}
}
$roles = og_roles($group_type, $bundle, 0);
foreach ($roles as $rid => $rolename) {
if (in_array($rolename, $details['roles'])) {
$grant[$rid][] = $perm;
}
else {
$revoke[$rid][] = $perm;
}
}
}
if (!empty($grant)) {
foreach ($grant as $rid => $permissions) {
og_role_grant_permissions($rid, $permissions);
}
}
if (!empty($revoke)) {
foreach ($revoke as $rid => $permissions) {
og_role_revoke_permissions($rid, $permissions);
}
}
}
}