You are here

function node_gallery_update_6303 in Node Gallery 6.3

Update for #997980. Add tags filtering to views selection.

File

./node_gallery.install, line 852
Install, update and uninstall functions for the node_gallery module.

Code

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

  // tag global summary view for /galleries page with 'galleries'
  $viewkey = unserialize(variable_get('node_gallery_galleries_summary_view', serialize(array(
    'name' => 'node_gallery_gallery_summaries',
    'display_id' => 'page_1',
  ))));
  $view = views_get_view($viewkey['name']);
  if ($view->type == t('Overridden')) {
    $view->tag = 'node_gallery_galleries';
    $view
      ->save();
    watchdog('node_gallery', 'Added \'node_gallery_galleries\' tag for view %viewname', array(
      '%viewname',
      $view->name,
    ));
  }

  // Tag image views with 'image'
  $view_names = array();
  $view_settings = array(
    'view_gallery_full_image_display',
    'view_gallery_teaser_view_image_display',
    'view_navigator_image_display',
  );
  foreach (node_gallery_get_all_relationships() as $rel) {
    foreach ($view_settings as $view_setting) {
      $viewkey = unserialize($rel['settings'][$view_setting]);
      $view_names[] = $viewkey['name'];
    }
  }
  $view_names = array_unique($view_names);
  foreach ($view_names as $view_name) {
    $view = views_get_view($view_name);
    if ($view->type == t('Overridden')) {
      $view->tag = 'node_gallery_images';
      $view
        ->save();
      watchdog('node_gallery', 'Added \'node_gallery_images\' tag for view %viewname', array(
        '%viewname',
        $view->name,
      ));
    }
  }
  cache_clear_all('*', 'cache_views');
  return $ret;
}