function party_activity_party_activity_type_insert in Party 8.2
Same name and namespace in other branches
- 7 modules/party_activity/party_activity.module \party_activity_party_activity_type_insert()
Implements hook_party_activity_type_insert().
File
- modules/
party_activity/ party_activity.module, line 301 - Functions and important hooks for the party_activity module
Code
function party_activity_party_activity_type_insert($activity_type) {
// Date field, this might change to be used
if (!field_info_field('activity_date')) {
//create field
$field = array(
'field_name' => 'activity_date',
'type' => 'datetime',
'settings' => array(
'granularity' => drupal_map_assoc(array(
'year',
'month',
'day',
'hour',
'minute',
)),
'tz_handling' => 'site',
),
);
field_create_field($field);
}
if (!field_info_instance('party_activity', 'activity_date', $activity_type->type)) {
//create instance
$instance = array(
'field_name' => 'activity_date',
'entity_type' => 'party_activity',
'bundle' => $activity_type->type,
'label' => 'Date',
'required' => TRUE,
'description' => "The date and time of the {$activity_type->label}",
'settings' => array(
'default_value' => 'blank',
),
'widget' => array(
'type' => 'date_popup',
'settings' => array(
'year_range' => '-2:+5',
'input_format' => 'j M Y - g:i:sa',
'increment' => 15,
),
),
'display' => array(
'default' => array(
'type' => 'date_default',
'label' => 'above',
),
'teaser' => array(
'type' => 'date_default',
'label' => 'inline',
),
),
);
field_create_instance($instance);
}
// Participants Field
if (!field_info_field('activity_participants')) {
//create field
$field = array(
'field_name' => 'activity_participants',
'type' => 'entityreference',
'cardinality' => -1,
'settings' => array(
'target_type' => 'party',
'handler' => 'base',
'handler_settings' => array(
'sort' => array(
'type' => 'none',
),
),
),
);
field_create_field($field);
}
if (!field_info_instance('party_activity', 'activity_participants', $activity_type->type)) {
//create instance
$instance = array(
'field_name' => 'activity_participants',
'entity_type' => 'party_activity',
'bundle' => $activity_type->type,
'label' => 'Participants',
'required' => TRUE,
'description' => "Those involved in the activity",
'settings' => array(
'default_value' => '',
),
'widget' => array(
'type' => 'entityreference_autocomplete',
'settings' => array(
'size' => '60',
'match_operator' => 'CONTAINS',
),
),
'display' => array(
'default' => array(
'type' => 'entityreference_label',
'label' => 'above',
'settings' => array(
'link' => TRUE,
),
),
'teaser' => array(
'type' => 'entityreference_label',
'label' => 'inline',
'settings' => array(
'link' => TRUE,
),
),
),
);
field_create_instance($instance);
}
// Assigned To Field
if (!field_info_field('activity_assigned_to')) {
//create field
$field = array(
'field_name' => 'activity_assigned_to',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'party',
'handler' => 'base',
'handler_settings' => array(
'sort' => array(
'type' => 'none',
),
),
),
);
field_create_field($field);
}
if (!field_info_instance('party_activity', 'activity_assigned_to', $activity_type->type)) {
//create instance
$instance = array(
'field_name' => 'activity_assigned_to',
'entity_type' => 'party_activity',
'bundle' => $activity_type->type,
'label' => 'Assigned To',
'required' => TRUE,
'description' => "The party to whom the activity is assigned",
'settings' => array(
'default_value' => '',
),
'widget' => array(
'type' => 'entityreference_autocomplete',
'settings' => array(
'size' => '60',
'match_operator' => 'CONTAINS',
),
),
'display' => array(
'default' => array(
'type' => 'entityreference_label',
'label' => 'above',
'settings' => array(
'link' => TRUE,
),
),
'teaser' => array(
'type' => 'entityreference_label',
'label' => 'inline',
'settings' => array(
'link' => TRUE,
),
),
),
);
field_create_instance($instance);
}
// Activity Details Field
if (!field_info_field('activity_details')) {
$field = array(
'field_name' => 'activity_details',
'type' => 'text_long',
);
$field = field_create_field($field);
}
if (!field_info_instance('party_activity', 'activity_details', $activity_type->type)) {
$instance = array(
'field_name' => 'activity_details',
'entity_type' => 'party_activity',
'bundle' => $activity_type->type,
'label' => 'Details',
'description' => t('(e.g. key information about the @type)', array(
'@type' => $activity_type->label,
)),
'widget' => array(
'type' => 'text_textarea',
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
),
'teaser' => array(
'label' => 'hidden',
'type' => 'text_default',
),
),
);
$instance = field_create_instance($instance);
}
}