function spaces_migrate_api_3_presets in Spaces 6.3
Helper function to update spaces 2 presets to spaces 3. Expects spaces 3 schema to be fully installed.
1 call to spaces_migrate_api_3_presets()
- spaces_update_6302 in ./
spaces.install - Update old spaces preset exportables. This update script may be re-run at any time to update spaces 2 preset objects that have been exported.
File
- ./
spaces.install, line 364
Code
function spaces_migrate_api_3_presets($presets) {
foreach ($presets as $name => $preset) {
if (!db_result(db_query("SELECT name FROM {spaces_presets} WHERE name = '%s'", $name))) {
$new = array(
'name' => $name,
'title' => isset($preset->name) ? $preset->name : $name,
'description' => isset($preset->description) ? $preset->description : '',
'space_type' => $preset->type,
'value' => array(),
);
// Features
if (!empty($preset->preset['features'])) {
$new['value']['variable']['spaces_features'] = $preset->preset['features'];
}
// Settings
if (!empty($preset->preset['settings'])) {
foreach ($preset->preset['settings'] as $key => $value) {
// Prefix settings so that someone can migrate them by hand.
$new['value']['variable']["spaces_setting_{$key}"] = $value;
}
}
// OG mask
if (!empty($preset->preset['og'])) {
foreach ($preset->preset['og'] as $key => $value) {
$new['value']['variable']["spaces_{$key}"] = $value;
}
}
// @TODO
// $preset->preset['locked']
$new['value'] = serialize($new['value']);
// update_sql does not escape strings properly.
db_query("INSERT INTO {spaces_presets} (name,title,description,space_type,value) VALUES ('%s', '%s', '%s', '%s', '%s')", $new['name'], $new['title'], $new['description'], $new['space_type'], $new['value']);
drupal_set_message('Updated spaces preset: ' . $new['name']);
}
}
}