function og_migrate_create_fields in Organic groups 7
Create group, group-audience and group description fields.
Helper function to help upgrade form Drupal 6.
2 calls to og_migrate_create_fields()
- og_migrate_og_migrate_upgrade_group in og_migrate/
plugins/ og_migrate/ upgrade_group.inc - OG Migrate callback; Upgrade group nodes.
- og_migrate_og_migrate_upgrade_group_content in og_migrate/
plugins/ og_migrate/ upgrade_group_content.inc - OG Migrate callback; Upgrade "group content" nodes.
File
- og_migrate/
og_migrate.module, line 390 - Migrate and upgrade Organic groups data.
Code
function og_migrate_create_fields() {
foreach (node_type_get_types() as $type) {
// check if the variable exists.
if ($type_usage = variable_get('og_content_type_usage_' . $type->type)) {
switch ($type_usage) {
case 'group':
$content_type['group'][] = $type->type;
break;
case 'group_post_standard':
case 'group_post_wiki':
// The type of the group content is now determined via the
// group permissions. We only care about adding the group content
// fields to the node.
$content_type['group content'][] = $type->type;
break;
}
}
}
if ($content_type) {
// Add group and group content fields to content types.
$fields = array(
'group' => OG_GROUP_FIELD,
'group content' => OG_AUDIENCE_FIELD,
);
foreach ($fields as $key => $field_name) {
foreach ($content_type[$key] as $type) {
og_create_field($field_name, 'node', $type);
if ($key == 'group') {
if (!field_info_field('og_description')) {
$field = array(
'field_name' => 'og_description',
'type' => 'text',
'entity_types' => array(
'node',
),
'cardinality' => 1,
);
$field = field_create_field($field);
}
if (!field_info_instance('node', 'og_description', $type)) {
// Create the "description" field for the bundle.
$instance = array(
'field_name' => 'og_description',
'bundle' => $type,
'entity_type' => 'node',
'label' => t('Group description'),
'description' => t('This is description of the group.'),
);
field_create_instance($instance);
}
}
}
}
}
}