View source
<?php
function commons_groups_field_default_field_instances() {
$field_instances = array();
$commons_groups_entity_types = commons_groups_get_group_content_entity_types();
if (!empty($commons_groups_entity_types)) {
foreach ($commons_groups_entity_types as $entity_type => $bundles) {
foreach (array_keys($bundles) as $bundle) {
commons_groups_field_definition($field_instances, $entity_type, $bundle);
}
}
}
$group_bundles = og_get_all_group_bundle();
if (empty($group_bundles['node'])) {
$group_bundles['node'] = array(
'group' => TRUE,
);
}
foreach (array_keys($group_bundles['node']) as $bundle) {
commons_groups_field_definition_group($field_instances, 'node', $bundle);
}
$field_instances['og_membership-og_membership_type_default-og_membership_request'] = array(
'bundle' => 'og_membership_type_default',
'default_value' => NULL,
'deleted' => '0',
'description' => 'This is the text a user may send to the group administrators.',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => 0,
),
),
'entity_type' => 'og_membership',
'field_name' => 'og_membership_request',
'label' => 'Request message',
'required' => FALSE,
'settings' => array(
'text_processing' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'module' => 'text',
'settings' => array(
'rows' => 5,
),
'type' => 'text_textarea',
'weight' => 0,
),
);
t('Determine if this is an OG group.');
t('Group');
t('Group membership');
t('Group visibility');
t('Group content visibility');
t('Group roles and permissions');
t('Request message');
t('This is the text a user may send to the group administrators.');
t('Group Logo');
t('Hide contributed content from non-members');
t('Privacy settings');
return $field_instances;
}
function commons_groups_field_definition_group(&$field_instances, $entity_type, $bundle) {
$field_instances["{$entity_type}-{$bundle}-field_og_subscribe_settings"] = array(
'bundle' => $bundle,
'default_value' => array(
0 => array(
'value' => 'anyone',
),
),
'deleted' => '0',
'description' => t("These privacy settings will not change the visibility of content that has already posted into this group. It takes effect only for content created after the group is saved with new privacy settings."),
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'list',
'settings' => array(),
'type' => 'list_default',
'weight' => 4,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_og_subscribe_settings',
'label' => 'Privacy settings',
'required' => 1,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'options',
'settings' => array(),
'type' => 'options_buttons',
'weight' => '41',
),
);
$field_instances["{$entity_type}-{$bundle}-field_og_access_default_value"] = array(
'bundle' => $bundle,
'default_value' => array(
0 => array(
'value' => 0,
),
),
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 5,
),
'teaser' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_og_access_default_value',
'label' => 'Hide contributed content from non-members',
'required' => 0,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'options',
'settings' => array(
'display_label' => 1,
),
'type' => 'options_onoff',
'weight' => '42',
),
);
$field_instances["{$entity_type}-{$bundle}-og_roles_permissions"] = array(
'bundle' => $bundle,
'default_value' => array(
0 => array(
'value' => 1,
),
),
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'list',
'settings' => array(),
'type' => 'list_default',
'weight' => 1,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'og_roles_permissions',
'label' => 'Group roles and permissions',
'required' => TRUE,
'settings' => array(
'user_register_form' => FALSE,
),
'view modes' => array(
'full' => array(
'custom settings' => FALSE,
'label' => 'Full',
'type' => 'list_default',
),
'teaser' => array(
'custom settings' => FALSE,
'label' => 'Teaser',
'type' => 'list_default',
),
),
'widget' => array(
'module' => 'options',
'settings' => array(),
'type' => 'options_select',
'weight' => 1,
),
);
$field_instances["{$entity_type}-{$bundle}-body"] = array(
'bundle' => $bundle,
'default_value' => NULL,
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => 1,
),
'teaser' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'body',
'label' => 'Description',
'required' => 0,
'settings' => array(
'display_summary' => 0,
'text_processing' => '1',
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'rows' => '20',
'summary_rows' => 5,
),
'type' => 'text_textarea_with_summary',
'weight' => '4',
),
);
$field_instances["{$entity_type}-{$bundle}-" . OG_GROUP_FIELD] = array(
'bundle' => $bundle,
'default_value' => array(
0 => array(
'value' => 1,
),
),
'deleted' => '0',
'description' => 'Determine if this is an OG group.',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'commons_groups',
'settings' => array(
'field_name' => '0',
),
'type' => 'commons_groups_group_subscribe',
'weight' => '0',
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'display_label' => 1,
'entity_type' => 'node',
'field_name' => OG_GROUP_FIELD,
'label' => 'Group',
'required' => FALSE,
'settings' => array(
'user_register_form' => FALSE,
),
'view modes' => array(
'full' => array(
'custom settings' => FALSE,
'label' => 'Full',
'type' => 'og_group_subscribe',
),
'teaser' => array(
'custom settings' => FALSE,
'label' => 'Teaser',
'type' => 'og_group_subscribe',
),
),
'widget' => array(
'module' => 'options',
'settings' => array(
'display_label' => 0,
'og_hide' => TRUE,
),
'type' => 'options_onoff',
'weight' => 0,
),
);
$field_instances["{$entity_type}-{$bundle}-group_access"] = array(
'bundle' => $bundle,
'default_value' => array(
0 => array(
'value' => 0,
),
),
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 4,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'group_access',
'label' => 'Group visibility',
'required' => TRUE,
'settings' => array(
'user_register_form' => FALSE,
),
'view modes' => array(
'full' => array(
'label' => 'above',
'type' => 'options_onoff',
),
'teaser' => array(
'label' => 'above',
'type' => 'options_onoff',
),
),
'widget' => array(
'module' => 'options',
'settings' => array(),
'type' => 'options_buttons',
'weight' => 41,
),
'widget_type' => 'options_select',
);
$field_instances["{$entity_type}-{$bundle}-field_group_logo"] = array(
'bundle' => $bundle,
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'image',
'settings' => array(
'image_link' => '',
'image_style' => '50x50',
),
'type' => 'image',
'weight' => '0',
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_group_logo',
'label' => 'Group Logo',
'required' => 0,
'settings' => array(
'alt_field' => 0,
'default_image' => 0,
'file_directory' => '',
'file_extensions' => 'png gif jpg jpeg',
'max_filesize' => '20mb',
'max_resolution' => '',
'min_resolution' => '30x30',
'title_field' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'image',
'settings' => array(
'preview_image_style' => 'thumbnail',
'progress_indicator' => 'throbber',
),
'type' => 'image_image',
'weight' => '5',
),
);
}
function commons_groups_field_definition(&$field_instances, $entity_type, $bundle) {
$field_instances["{$entity_type}-{$bundle}-og_group_ref"] = array(
'bundle' => $bundle,
'default_value' => NULL,
'default_value_function' => 'commons_groups_entityreference_default_value',
'deleted' => '0',
'description' => 'Separate group names with commas',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'og_ui',
'settings' => array(),
'type' => 'og_list_default',
'weight' => 11,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => $entity_type,
'field_name' => 'og_group_ref',
'label' => 'Groups',
'required' => 0,
'settings' => array(
'behaviors' => array(
'og_widget' => array(
'admin' => array(
'widget_type' => 'entityreference_autocomplete_tags',
),
'default' => array(
'widget_type' => 'entityreference_autocomplete_tags',
),
'status' => TRUE,
),
'prepopulate' => array(
'action' => 'none',
'fallback' => 'none',
'og_context' => 0,
'skip_perm' => '0',
'status' => 1,
),
),
'user_register_form' => FALSE,
),
'view modes' => array(
'full' => array(
'custom settings' => FALSE,
'label' => 'Full',
'type' => 'og_list_default',
),
'teaser' => array(
'custom settings' => FALSE,
'label' => 'Teaser',
'type' => 'og_list_default',
),
),
'widget' => array(
'active' => 0,
'module' => 'og',
'settings' => array(),
'type' => 'og_complex',
'weight' => 5,
),
);
$field_instances["{$entity_type}-{$bundle}-group_content_access"] = array(
'bundle' => $bundle,
'default_value' => array(
0 => array(
'value' => 0,
),
),
'deleted' => '0',
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 5,
),
'teaser' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => $entity_type,
'field_name' => 'group_content_access',
'label' => 'Group content visibility',
'required' => TRUE,
'settings' => array(
'user_register_form' => FALSE,
),
'view modes' => array(
'full' => array(
'label' => 'above',
'type' => 'list_default',
),
'teaser' => array(
'label' => 'above',
'type' => 'list_default',
),
),
'widget' => array(
'module' => 'options',
'settings' => array(),
'type' => 'options_select',
'weight' => 16,
),
'widget_type' => 'options_select',
);
}