function og_features_permission_features_export in Organic groups 7.2
Implements hook_features_export().
File
- includes/
og_features_permission.features.inc, line 10 - Integration with features for og permissions.
Code
function og_features_permission_features_export($data, &$export, $module_name = '') {
$map = features_get_default_map('og_features_permission');
$permissions = _og_features_get_permissions();
$pipe = array();
foreach ($data as $key) {
// If this og permission is provided by a module, add it as a dependency.
if (isset($map[$key]) && $map[$key] != $module_name) {
$export['dependencies'][$map[$key]] = $map[$key];
}
else {
// $key is 'entity_type:bundle:permission'.
list($group_type, $bundle, $perm) = explode(':', $key);
if (isset($permissions[$group_type][$bundle][$perm]['roles'])) {
// Pipe in og roles.
$roles = array();
foreach ($permissions[$group_type][$bundle][$perm]['roles'] as $role) {
$dep = $group_type . ':' . $bundle . ':' . $role;
if (empty($pipe['og_features_role']) || !in_array($dep, $pipe['og_features_role'])) {
$pipe['og_features_role'][] = $dep;
}
}
}
if (isset($permissions[$group_type][$bundle][$perm]['module'])) {
// Add the module which defines the permission as a dependency.
$module = $permissions[$group_type][$bundle][$perm]['module'];
$export['dependencies'][$module] = $module;
$export['dependencies']['features'] = 'features';
$export['dependencies']['og'] = 'og';
$export['features']['og_features_permission'][$key] = $key;
}
}
}
return $pipe;
}