function themekey_update_6200 in ThemeKey 7
Same name and namespace in other branches
- 6.4 themekey.install \themekey_update_6200()
- 6.2 themekey.install \themekey_update_6200()
- 6.3 themekey.install \themekey_update_6200()
- 7.3 themekey.install \themekey_update_6200()
- 7.2 themekey.install \themekey_update_6200()
Implements hook_update_N().
File
- ./
themekey.install, line 306 - Database schema of
Code
function themekey_update_6200() {
$field = array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '0',
'initial' => '1',
);
db_add_field('themekey_properties', 'enabled', $field);
db_drop_index('themekey_properties', 'property');
db_add_index('themekey_properties', 'enabled', array(
'enabled',
));
$field = array(
'type' => 'text',
'not null' => TRUE,
);
db_add_field('themekey_properties', 'wildcards', $field);
$weight = (int) db_query("SELECT MIN(weight) FROM {themekey_properties}")
->fetchField() - 1;
$result = db_query("SELECT * FROM {themekey_paths} WHERE custom = :custom", array(
':custom' => 1,
));
foreach ($result as $item) {
$conditions = unserialize($item->conditions);
if (is_array($conditions) && !empty($conditions)) {
if (!is_array($conditions[0])) {
// ThemeKey 6.x-1.1 stored conditions for paths as simple string within an array
$conditions = _themekey_properties_explode_conditions($conditions[0]);
}
}
$insert_success = db_insert('themekey_properties')
->fields(array(
'property' => 'drupal:path',
'value' => $item->path,
'weight' => $weight,
'conditions' => serialize($conditions),
'theme' => $item->theme,
'enabled' => 1,
'wildcards' => $item->wildcards,
))
->execute();
$num_deleted = db_delete('themekey_paths')
->condition('id', $item->id)
->execute();
}
db_drop_field('themekey_paths', 'conditions');
db_drop_field('themekey_paths', 'custom');
db_drop_field('themekey_paths', 'theme');
return t('Updated Themekey properties.');
}