<?php
// $Id: emthumb.install,v 1.1.2.2 2010/07/19 18:17:48 aaron Exp $

/**
 * @file
 * Updates for the emthumb module.
 */

/**
 *  New formatters and theme functions.
 */
function emthumb_update_6002() {
  drupal_rebuild_theme_registry();
  return _emthumb_update_reset_cache();
}


/**
 *  Rebuild the theme for new formatters.
 */
function _emthumb_update_add_new_formatters($message = NULL) {
  if (!isset($output)) {
    $output = t('Rebuilt the theme to accommodate new formatters.');
  }

  // Adding new formatters, so need to rebuild the theme.
  drupal_rebuild_theme_registry();

  // Also need to make sure we grab the new formatters themselves.
  $ret = _emthumb_update_reset_cache();

  $ret[] = array(
    'query' => $message,
    'success' => TRUE,
  );

  return $ret;
}

/**
 * Clear the Views cache.
 */
function _emthumb_update_reset_cache_views() {
  $ret = array();
  if (module_exists('views')) {
    $ret[] = update_sql("DELETE FROM {cache_views}");
  }

  return $ret;
}

/**
 *  Clear the content and views caches.
 */
function _emthumb_update_reset_cache() {
  $ret = _emthumb_update_reset_cache_views();
  $ret[] = update_sql("DELETE FROM {cache_content}");

  return $ret;
}
