function merci_enable in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6
Same name and namespace in other branches
- 6.2 merci.install \merci_enable()
- 7.2 merci.install \merci_enable()
Implementation of hook_enable().
File
- ./
merci.install, line 82 - merci Installer / Uninstaller
Code
function merci_enable() {
// Create the date, commercial_total, and member_total fields for the reservation.
$date_field = array(
'field_name' => 'field_merci_date',
'type_name' => 'merci_reservation',
'display_settings' => array(
'label' => array(
'format' => 'above',
'exclude' => 0,
),
'teaser' => array(
'format' => 'default',
'exclude' => 0,
),
'full' => array(
'format' => 'default',
'exclude' => 0,
),
4 => array(
'format' => 'default',
'exclude' => 0,
),
),
'widget_active' => '1',
'type' => 'datetime',
'required' => '1',
'multiple' => '0',
'db_storage' => '1',
'module' => 'date',
'active' => '1',
'locked' => '1',
'columns' => array(
'value' => array(
'type' => 'datetime',
'not null' => FALSE,
'sortable' => TRUE,
),
'value2' => array(
'type' => 'datetime',
'not null' => FALSE,
'sortable' => TRUE,
),
),
'granularity' => array(
'year' => 'year',
'month' => 'month',
'day' => 'day',
'hour' => 'hour',
'minute' => 'minute',
),
'timezone_db' => 'UTC',
'tz_handling' => 'site',
'todate' => 'required',
'repeat' => 0,
'repeat_collapsed' => '',
'output_format_date' => $short_date_format,
'output_format_custom' => '',
'output_format_date_long' => $date_only_format,
'output_format_custom_long' => '',
'output_format_date_medium' => $date_only_format,
'output_format_custom_medium' => '',
'output_format_date_short' => $date_only_format,
'output_format_custom_short' => '',
'widget' => array(
'default_value' => 'blank',
'default_value_code' => '',
'default_value2' => 'same',
'default_value_code2' => '',
'input_format' => $short_date_format,
'input_format_custom' => '',
'increment' => '15',
'text_parts' => array(),
'year_range' => '-3:+3',
'label_position' => 'above',
'label' => 'Reservation',
'weight' => '-1',
'description' => 'Select the start and end times for your reservation.',
'type' => 'date_popup',
'module' => 'date',
),
);
// Need to load the CCK include file where content_field_instance_create() is defined.
module_load_include('inc', 'content', 'includes/content.crud');
// Create the field.
content_field_instance_create($date_field);
add_cost_fields_and_group_taxonomy();
// Add any node types to the MERCI tables that aren't already there.
$existing_types = db_query("SELECT type FROM {merci_node_type}");
$types = array();
while ($existing_type = db_fetch_object($existing_types)) {
$types[] = $existing_type->type;
}
if (empty($types)) {
$new_types = db_query("SELECT type FROM {node_type}");
}
else {
$new_types = db_query("SELECT type FROM {node} WHERE type NOT IN (" . db_placeholders($types, 'varchar') . ")", $types);
}
while ($new_type = db_fetch_object($new_types)) {
db_query("INSERT INTO {merci_node_type} (type) VALUES ('%s')", $new_type->type);
}
}