You are here

function flag_update_5003 in Flag 5

Remove the previous default views that are no longer bundled with Flag.

These views are saved to the database so that they are preserved.

File

./flag.install, line 372
Flag module install/update hooks.

Code

function flag_update_5003() {
  $ret = array();

  // Bail out if Views doesn't exist.
  if (!function_exists('views_get_view')) {
    return $ret;
  }
  drupal_load('module', 'flag');
  $flags = flag_get_flags();
  $disabled_views = variable_get('views_defaults', array());
  foreach ($flags as $name => $flag) {
    if ($view = views_get_view('flags_' . $name)) {
      if ($view->is_default && !isset($disabled_views[$view->name])) {
        _views_save_view($view);
        $ret[] = array(
          'success' => TRUE,
          'query' => t('The view %name as been saved to the database. Flag no longer provides this view by default.', array(
            '%name' => $view->name,
          )),
        );
      }
    }
  }
  return $ret;
}