You are here

function finder_update_6101 in Finder 6

Same name and namespace in other branches
  1. 7 finder.install \finder_update_6101()

Implementation of hook_update_N().

Copies match method setting into each of the elements.

See also

hook_update_N()

File

./finder.install, line 231
Finder module install file.

Code

function finder_update_6101() {
  module_load_include('module', 'finder', 'finder');

  // Update finder's settings where possible to avoid problems in this update.
  $finders = finder_load_multiple(NULL, array(), TRUE);
  foreach ($finders as $finder) {
    $changed = FALSE;
    if (isset($finder->settings['advanced']['match'])) {
      foreach ($finder->elements as $key => $element) {
        if (!isset($element->settings['advanced']['match'])) {
          $element->settings['advanced']['match'] = $finder->settings['advanced']['match'];
          $finder->elements[$key] = $element;
          $changed = TRUE;
        }
      }

      // No need to remove the setting from the finder.
    }
    if ($changed) {
      finder_save($finder);
    }
  }
  return array(
    array(
      'success' => TRUE,
      'query' => t('Moved match method setting into each element.'),
    ),
  );
}