You are here

function quicktabs_update_7303 in Quick Tabs 7.3

Add support for view modes.

File

./quicktabs.install, line 185
Install, update and uninstall functions for the quicktabs module.

Code

function quicktabs_update_7303() {
  foreach (quicktabs_load_multiple() as $quicktab) {
    $updated = FALSE;
    foreach ($quicktab->tabs as &$tab) {
      if ($tab['type'] === 'node') {
        $tab['view_mode'] = !empty($tab['teaser']) ? 'teaser' : 'full';
        unset($tab['teaser']);
        $updated = TRUE;
      }
    }
    if (!$updated) {
      continue;
    }
    if (empty($quicktab->in_code_only)) {
      $result = drupal_write_record('quicktabs', $quicktab, 'machine_name');
    }
    else {
      $result = drupal_write_record('quicktabs', $quicktab);
    }
    if (!$result) {
      throw new DrupalUpdateException(t('Could not complete the update.'));
    }
  }
  return 'Added support for view modes.';
}