function themekey_update_6200 in ThemeKey 6.3
Same name and namespace in other branches
- 6.4 themekey.install \themekey_update_6200()
- 6.2 themekey.install \themekey_update_6200()
- 7.3 themekey.install \themekey_update_6200()
- 7 themekey.install \themekey_update_6200()
- 7.2 themekey.install \themekey_update_6200()
Implements hook_update_N().
File
- ./
themekey.install, line 245 - Database schema of
Code
function themekey_update_6200() {
$field = array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '0',
'initial' => '1',
);
db_add_field($ret, 'themekey_properties', 'enabled', $field);
db_drop_index($ret, 'themekey_properties', 'property');
db_add_index($ret, 'themekey_properties', 'enabled', array(
'enabled',
));
$field = array(
'type' => 'text',
'not null' => TRUE,
);
db_add_field($ret, 'themekey_properties', 'wildcards', $field);
$weight = (int) db_result(db_query("SELECT MIN(weight) FROM {themekey_properties}")) - 1;
$insert_query = "INSERT INTO {themekey_properties} (property, value, weight, conditions, theme, enabled, wildcards) VALUES ('drupal:path', '%s', %d, '%s', '%s', 1, '%s')";
$result = db_query("SELECT * FROM {themekey_paths} WHERE custom = 1");
while ($item = db_fetch_array($result)) {
$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_query($insert_query, $item['path'], $weight, serialize($conditions), $item['theme'], $item['wildcards']);
$ret[] = array(
'success' => $insert_success,
'query' => $insert_query,
);
$ret[] = update_sql('DELETE FROM {themekey_paths} WHERE id = ' . $item['id']);
}
db_drop_field($ret, 'themekey_paths', 'conditions');
db_drop_field($ret, 'themekey_paths', 'custom');
db_drop_field($ret, 'themekey_paths', 'theme');
return $ret;
}