You are here

function fullcalendar_colors_update_7200 in FullCalendar 7.2

Upgrade FullCalendar Colors alpha6 to beta1 FullCalendar Colors API.

File

fullcalendar_colors/fullcalendar_colors.install, line 39
Install, update and uninstall functions for the FullCalendar Colors module.

Code

function fullcalendar_colors_update_7200(&$sandbox) {
  if (!function_exists('colors_include_api')) {
    $t = get_t();
    throw new DrupalUpdateException($t('You need to download the latest version of the !colors_module.', array(
      '!colors_module' => l(t('Colors API module'), 'http://drupal.org/project/colors'),
    )));
  }

  // Changed variable names.
  variable_set('fullcalendar_colors_node_types_enabled', variable_get('fullcalendar_color_node_types_enabled', 0));
  variable_del('fullcalendar_color_node_types_enabled');
  if (module_exists('taxonomy')) {
    $taxonomies = taxonomy_get_vocabularies();
    foreach ($taxonomies as $vid => $vocab) {
      variable_set('fullcalendar_colors_taxo_' . $vid . '_enabled', variable_get('fullcalendar_color_taxo_' . $vid . '_enabled', 0));
      variable_del('fullcalendar_color_taxo_' . $vid . '_enabled');
    }
  }
  variable_set('fullcalendar_colors_user_roles_enabled', variable_get('fullcalendar_color_user_roles_enabled', 0));
  variable_del('fullcalendar_color_user_roles_enabled');

  // Move the node type, taxonomy terms and user roles colors.
  $items = array_map('unserialize', db_select('variable', 'v')
    ->fields('v', array(
    'name',
    'value',
  ))
    ->condition('name', db_like('fullcalendar_color_') . '%', 'LIKE')
    ->execute()
    ->fetchAllKeyed());
  foreach ($items as $key => $item) {
    $colors = array(
      'background' => $item,
      'border' => $item,
      'text' => '#ffffff',
    );
    colors_set_colors(preg_replace('/_color_/', '_colors_', $key), $colors, 'fullcalendar_colors');
    variable_del($item['name']);
  }

  // Add the default configuration.
  $color_options = array(
    'background' => '#3366cc',
    'border' => '#3366cc',
    'text' => '#ffffff',
  );
  colors_set_colors('fullcalendar_colors_default', $color_options, 'fullcalendar_colors');
}