function availability_calendars_update_6102 in Availability Calendars 6
Same name and namespace in other branches
- 6.2 availability_calendars.install \availability_calendars_update_6102()
Update the settings system.
File
- ./
availability_calendars.install, line 141 - Install, update and uninstall functions for the Availability Calendars module.
Code
function availability_calendars_update_6102(&$sandbox) {
$ret = array();
// system wide settings
$ret[] = update_sql("UPDATE {variable} SET name = 'availability_calendars_settings_system_nodeview' WHERE name = 'availability_calendars_display_nodeview'");
$ret[] = update_sql("UPDATE {variable} SET name = 'availability_calendars_settings_system_hideold' WHERE name = 'availability_calendars_display_hideallold'");
$ret[] = update_sql("UPDATE {variable} SET name = 'availability_calendars_settings_system_monthcount' WHERE name = 'availability_calendars_display_monthcount'");
// content type settings
$types = node_get_types();
foreach ($types as $id => $val) {
if (variable_get("availability_calendars_{$val->type}", 'marker') !== 'marker') {
$ret[] = update_sql("UPDATE {variable} SET name = 'availability_calendars_settings_system-type_{$val->type}' WHERE name = 'availability_calendars_{$val->type}'");
}
}
// Node specific settings.
// Rename all node specific settings, by inserting settings_node_, select by looking at
// the format (availability_calendar_%_%) and if the 24th character is a number.
// strlen('availability_calendars_') = 23
global $db_type;
$update_query = "UPDATE {variable} " . ($db_type === 'pgsql' ? "SET name = substring(name from 1 for 23) || 'settings_node_' || substring(name from 24) " : "SET name = concat(substring(name from 1 for 23), 'settings_node_', substring(name from 24)) ") . "WHERE name LIKE 'availability\\_calendars\\_%\\_%' " . " AND position(substring(name from 24 for 1) in '123456789') > 0";
$ret[] = update_sql($update_query);
return $ret;
}