update.php and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning', FALSE);
$ret['#abort'] = array('success' => FALSE, 'query' => t('calendar.module has updates, but cannot be updated until views.module is updated first.'));
return $ret;
}
variable_del('calendar_empty_arg');
// Can't use variable_del because we don't have a reliable
// way to find the old view names.
db_query("DELETE FROM {variable} WHERE name LIKE 'calendar_%'");
cache_clear_all('variables', 'cache');
return $ret;
}
/**
* Make sure handlers for disabled Calendar iCal module don't get saved in the view.
*/
function calendar_update_6001() {
$ret = array();
// don't attempt to upgrade if views is not yet upgraded.
if (drupal_get_installed_schema_version('views', TRUE) < 6000) {
$ret = array();
drupal_set_message(t('Calendar module cannot be updated until after Views has been updated. Please return to update.php and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning', FALSE);
$ret['#abort'] = array('success' => FALSE, 'query' => t('calendar.module has updates, but cannot be updated until views.module is updated first.'));
return $ret;
}
if (!module_exists('calendar_ical')) {
$ret[] = update_sql("DELETE FROM {views_display} WHERE display_plugin = 'ical'");
}
return $ret;
}
function calendar_update_6002() {
$ret = array();
// don't attempt to upgrade if views is not yet upgraded.
if (drupal_get_installed_schema_version('views', TRUE) < 6000) {
$ret = array();
drupal_set_message(t('Calendar module cannot be updated until after Views has been updated. Please return to update.php and run the remaining updates.', array('@update-php' => base_path() .'update.php?op=selection')), 'warning', FALSE);
$ret['#abort'] = array('success' => FALSE, 'query' => t('calendar.module has updates, but cannot be updated until views.module is updated first.'));
return $ret;
}
$periods = array(
'calendar_month' => 'calendar_period_1',
'calendar_year' => 'calendar_period_2',
'calendar_day' => 'calendar_period_3',
'calendar_week' => 'calendar_period_4',
'calendar_block_view' => 'calendar_period_5',
);
$result = db_query("SELECT * FROM {views_display} d LEFT JOIN {views_view} v ON d.vid = v.vid");
drupal_load('module', 'views');
while ($row = db_fetch_array($result)) {
if (in_array($row['display_plugin'], array_keys($periods))) {
$id = $row['id'];
$options = unserialize($row['display_options']);
if ($row['display_plugin'] == 'calendar_block_view') {
$options['calendar_type'] = 'month';
$options['displays'] = array('calendar_1' => 0, 'default' => 0, 'calendar_block_1' => 'calendar_block_1');
}
else {
$options['calendar_type'] = str_replace('calendar_', '', $row['display_plugin']);
$options['displays'] = array('calendar_1' => 'calendar_1', 'default' => 0, 'calendar_block_1' => 0);
}
$row['id'] = $periods[$row['id']];
$row['display_plugin'] = 'calendar_period';
$row['display_options'] = serialize($options);
db_query("UPDATE {views_display} SET id='%s', display_plugin='%s', display_options='%s' WHERE id='%s'", $row['id'], $row['display_plugin'], $row['display_options'], $id);
}
elseif ($row['display_plugin'] == 'calendar' || $row['display_plugin'] == 'calendar_block') {
db_query("UPDATE {views_display} SET id='%s' WHERE id='%s'", $row['id'] .'_1', $row['id']);
}
db_query("DELETE FROM {views_object_cache} WHERE name = '%s'", $row['name']);
}
views_invalidate_cache();
$ret[] = array('success' => TRUE, 'query' => 'Updated calendar displays to use new handlers.');
return $ret;
}