function commons_groups_system_info_alter in Drupal Commons 7.3
Implements hook_system_info_alter().
File
- modules/
commons/ commons_groups/ commons_groups.module, line 391
Code
function commons_groups_system_info_alter(&$info, $file, $type) {
// Commons Groups dynamically adds the og_group_ref field to
// content types that request it by altering the
// commons_groups_entity_types variable.
// We must add a corresponding line for each field instance
// to commons_groups.info so that Features is aware of the instance
// and can successfully revert the field_instance component back
// to its default state.
if ($file->name == 'commons_groups') {
$group_bundles = og_get_all_group_bundle();
if (!empty($group_bundles['node'])) {
foreach ($group_bundles['node'] as $bundle => $name) {
// These field instances should be added to groups regardless of
// whether og_access.module is enabled.
$info['features']['field_instance'][] = "node-{$bundle}-field_og_access_default_value";
$info['features']['field_instance'][] = "node-{$bundle}-field_og_subscribe_settings";
$info['features']['field_instance'][] = "node-{$bundle}-og_roles_permissions";
$info['features']['field_instance'][] = "node-{$bundle}-body";
$info['features']['field_instance'][] = "node-{$bundle}-group_group";
// These fields are only necessary when og_access.module is enabled.
$info['features']['field_instance'][] = "node-{$bundle}-group_access";
$info['features']['field_instance'][] = "node-{$bundle}-field_group_logo";
// Add default strongarm settings.
$info['features']['variable'][] = "comment_anonymous_{$bundle}";
$info['features']['variable'][] = "comment_default_mode_{$bundle}";
$info['features']['variable'][] = "comment_default_per_page_{$bundle}";
$info['features']['variable'][] = "comment_form_location_{$bundle}";
$info['features']['variable'][] = "comment_{$bundle}";
$info['features']['variable'][] = "comment_preview_{$bundle}";
$info['features']['variable'][] = "comment_subject_field_{$bundle}";
$info['features']['variable'][] = "field_bundle_settings_node__{$bundle}";
}
}
$group_content_entity_types = commons_groups_get_group_content_entity_types();
if (!empty($group_content_entity_types)) {
foreach ($group_content_entity_types as $entity_type => $bundles) {
foreach (array_keys($bundles) as $bundle) {
$info['features']['field_instance'][] = "{$entity_type}-{$bundle}-og_group_ref";
$info['features']['field_instance'][] = "{$entity_type}-{$bundle}-group_content_access";
}
}
}
// Commons specific group variables.
$commons_groups = commons_groups_get_group_types();
if (isset($commons_groups['node'])) {
foreach ($commons_groups['node'] as $bundle => $group_info) {
$info['features']['variable'][] = "node_options_{$bundle}";
$info['features']['variable'][] = "node_preview_{$bundle}";
$info['features']['variable'][] = "node_submitted_{$bundle}";
$info['features']['variable'][] = "og_group_manager_default_rids_node_{$bundle}";
}
}
}
// Dynamically adding a field instance to an entity type results in features
// automatically detecting Commons Groups as a dependency.
// We manually exclude the dependency in order to prevent entity type provider
// modules from appearing overridden and to allow them to be used
// independently of Commons Groups.
$commons_entity_integrations =& drupal_static(__FUNCTION__);
if (!isset($commons_entity_integrations)) {
foreach (module_implements('commons_entity_integration') as $module) {
$commons_entity_integrations[$module] = call_user_func($module . '_commons_entity_integration');
}
}
if (isset($commons_entity_integrations[$file->name])) {
foreach ($commons_entity_integrations[$file->name] as $entity_type => $integration) {
foreach ($integration as $bundle => $options) {
if (commons_groups_is_group_content($entity_type, $bundle)) {
$info['features_exclude']['dependencies']['commons_groups'] = 'commons_groups';
}
}
}
}
}