View source
<?php
function vcardfield_field_schema($field) {
if ($field['type'] == 'vcardfield') {
$schema['columns']['prefix'] = array(
'type' => 'varchar',
'length' => '10',
'not null' => FALSE,
);
$schema['columns']['first_name'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['middle_name'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['last_name'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['suffix'] = array(
'type' => 'varchar',
'length' => '25',
'not null' => FALSE,
);
$schema['columns']['full_name'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['columns']['photo'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['columns']['title'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['organization'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['address_type'] = array(
'type' => 'varchar',
'length' => '4',
'not null' => FALSE,
);
$schema['columns']['address'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['columns']['city'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['region'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['postalcode'] = array(
'type' => 'varchar',
'length' => '15',
'not null' => FALSE,
);
$schema['columns']['country'] = array(
'type' => 'varchar',
'length' => '100',
'not null' => FALSE,
);
$schema['columns']['phone_default'] = array(
'type' => 'varchar',
'length' => '25',
'not null' => FALSE,
);
$schema['columns']['phone_cell'] = array(
'type' => 'varchar',
'length' => '25',
'not null' => FALSE,
);
$schema['columns']['phone_fax'] = array(
'type' => 'varchar',
'length' => '25',
'not null' => FALSE,
);
$schema['columns']['phone_home'] = array(
'type' => 'varchar',
'length' => '25',
'not null' => FALSE,
);
$schema['columns']['email'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['columns']['link'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['columns']['label'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['columns']['instance'] = array(
'type' => 'varchar',
'length' => '255',
'not null' => FALSE,
);
$schema['indexes'] = array(
'name' => array(
'last_name',
'first_name',
),
'link' => array(
'link',
),
);
return $schema;
}
}
function vcardfield_update_7002(&$sandbox) {
$fields = field_info_fields();
foreach ($fields as $field_name => $field) {
if ($field['type'] == 'vcardfield' && $field['storage']['type'] == 'field_sql_storage') {
$schema = vcardfield_field_schema($field);
foreach ($field['storage']['details']['sql'] as $type => $table_info) {
foreach ($table_info as $table_name => $columns) {
$column_name = _field_sql_storage_columnname($field_name, 'photo');
if (!db_field_exists($table_name, $column_name)) {
db_add_field($table_name, $column_name, $schema['columns']['photo']);
db_add_index($table_name, $column_name, array(
$column_name,
));
}
}
}
}
}
field_cache_clear();
}
function vcardfield_update_7003(&$sandbox) {
$fields = field_info_fields();
foreach ($fields as $field_name => $field) {
if ($field['type'] == 'vcardfield' && $field['storage']['type'] == 'field_sql_storage') {
$schema = vcardfield_field_schema($field);
foreach ($field['storage']['details']['sql'] as $type => $table_info) {
foreach ($table_info as $table_name => $columns) {
$column_name = _field_sql_storage_columnname($field_name, 'middle_name');
if (!db_field_exists($table_name, $column_name)) {
db_add_field($table_name, $column_name, $schema['columns']['middle_name']);
db_add_index($table_name, $column_name, array(
$column_name,
));
}
}
}
}
}
field_cache_clear();
}