function skinr_update_6000 in Skinr 6.2
Install new skinr table and convert old variables to the new db system.
File
- ./
skinr.install, line 195 - skinr.install Contains install, update, and uninstall functions for Skinr.
Code
function skinr_update_6000() {
$ret = array();
// Install skinr table.
if (!db_table_exists('skinr')) {
$schema = drupal_get_schema_unprocessed('skinr');
_drupal_initialize_schema('skinr', $schema);
db_create_table($ret, 'skinr', $schema['skinr']);
// Exclude variables that aren't theme settings.
$exclude = array(
'skinr_overlay_width',
'skinr_overlay_height',
'skinr_overlay_autofit',
'skinr_overlay_draggable',
);
$result = db_query("SELECT name FROM {variable} WHERE name LIKE 'skinr_%'");
while ($variable = db_fetch_object($result)) {
if (!in_array($variable->name, $exclude)) {
// Convert from variable to db.
$theme = substr($variable->name, 6);
$skinr = variable_get($variable->name, array());
foreach ($skinr as $module => $sids) {
foreach ($sids as $sid => $skins) {
db_query("INSERT INTO {skinr} (theme, module, sid, skins, settings) VALUES ('%s', '%s', '%s', '%s', '%s')", $theme, $module, $sid, serialize($skins), serialize(array()));
}
}
// Delete the old variable.
variable_del($variable->name);
}
}
}
return $ret;
}