You are here

function calendar_ical_update_6000 in Calendar 6.2

File

calendar_ical/calendar_ical.install, line 36

Code

function calendar_ical_update_6000() {
  $ret = array();
  $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 ($row['display_plugin'] == 'ical') {
      $options = unserialize($row['display_options']);
      $options['displays'] = array(
        'calendar_1' => 'calendar_1',
        'default' => 0,
        'calendar_block_1' => 'calendar_block_1',
      );
      $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'", 'calendar_ical_1', 'calendar_ical', $row['display_options'], $row['id']);
      db_query("DELETE FROM {views_object_cache} WHERE name = '%s'", $row['name']);
    }
  }
  $ret[] = array(
    'success' => TRUE,
    'query' => 'Updated calendar ical displays to use new handlers and ids.',
  );
  views_invalidate_cache();
  return $ret;
}