function date_field_schema in Date 7
Same name and namespace in other branches
- 8 date.install \date_field_schema()
- 7.3 date.install \date_field_schema()
- 7.2 date.install \date_field_schema()
@file Installation code for CCK date module.
File
- ./
date.install, line 6 - Installation code for CCK date module.
Code
function date_field_schema($field) {
$db_columns = array();
switch ($field['type']) {
case 'datestamp':
$db_columns['value'] = array(
'type' => 'int',
'not null' => FALSE,
'sortable' => TRUE,
'views' => TRUE,
);
break;
case 'datetime':
$db_columns['value'] = array(
'type' => 'datetime',
'mysql_type' => 'DATETIME',
'pgsql_type' => 'timestamp without time zone',
'not null' => FALSE,
'sortable' => TRUE,
'views' => TRUE,
);
break;
default:
$db_columns['value'] = array(
'type' => 'varchar',
'length' => 20,
'not null' => FALSE,
'sortable' => TRUE,
'views' => TRUE,
);
break;
}
// If a second date is needed for 'To date', just make a copy of the first one.
if (!empty($field['settings']['todate'])) {
$db_columns['value2'] = $db_columns['value'];
// We don't want CCK to create additional columns, just the first.
// We modify them our own way in views data.
$db_columns['value2']['views'] = FALSE;
}
// timezone and offset columns are used only if date-specific dates are chosen.
if (isset($field['settings']['tz_handling']) && $field['settings']['tz_handling'] == 'date') {
$db_columns['timezone'] = array(
'type' => 'varchar',
'length' => 50,
'not null' => FALSE,
'sortable' => TRUE,
'views' => FALSE,
);
$db_columns['offset'] = array(
'type' => 'int',
'not null' => FALSE,
'sortable' => TRUE,
'views' => FALSE,
);
if (!empty($field['settings']['todate'])) {
$db_columns['offset2'] = array(
'type' => 'int',
'not null' => FALSE,
'sortable' => TRUE,
'views' => FALSE,
);
}
}
if (isset($field['settings']['repeat']) && $field['settings']['repeat'] == 1) {
$db_columns['rrule'] = array(
'type' => 'text',
'not null' => FALSE,
'sortable' => FALSE,
'views' => FALSE,
);
}
return array(
'columns' => $db_columns,
);
}