function ds_update_4 in Display Suite 6.2
Same name and namespace in other branches
- 6.3 ds.install \ds_update_4()
Implements hook_update_N().
File
- ./
ds.install, line 110 - Display suite install file.
Code
function ds_update_4() {
$ret = array();
// Create schema.
$schema = ds_schema();
foreach ($schema as $name => $spec) {
db_create_table($ret, $name, $spec);
}
// Refresh static cache.
drupal_get_schema('ds_settings', TRUE);
$all_build_modes = ds_get_build_modes(NULL, TRUE);
// Take the 'module'_display_settings and store them in the table.
foreach (module_implements('ds_api') as $module) {
$api_info = ds_api_info($module);
$module = $api_info['module'];
// Get all types.
foreach ($api_info['types']() as $type) {
// Get the display settings.
$display_settings = variable_get($module . '_display_settings_' . $type->type, array());
if (!empty($display_settings)) {
// Iterate over known build modes and save them.
$build_modes = $all_build_modes[$module];
foreach (array_keys($build_modes) as $build_mode) {
if (isset($display_settings[$build_mode])) {
$settings = $display_settings[$build_mode];
// Iterate over fields and ditch those which are hidden.
foreach ($settings['fields'] as $field_key => $field_value) {
if ($field_value['region'] == 'disabled') {
unset($settings['fields'][$field_key]);
}
}
// Save the record.
$record = new stdClass();
$record->module = $module;
$record->type = $type->type;
$record->build_mode = $build_mode;
$record->settings = serialize($settings);
drupal_write_record('ds_settings', $record);
}
}
}
// Delete variable.
variable_del($module . '_display_settings_' . $type->type);
}
// Remove the fields cached.
variable_del('ds_fields_cached');
}
return $ret;
}