You are here

function gallery_assist_update_5 in Gallery Assist 6

Implementation of hook_update_N().

File

./gallery_assist.install, line 812
Install, update and uninstall functions and DB tables for the Gallery Assist module.

Code

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

  // Add a identifier for the created path alias to the gallery items.
  $aid = array(
    'aid' => array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'description' => 'Url alias Identifier by using pathauto.',
    ),
  );
  db_add_field($ret, 'gallery_assist_item', 'aid', $aid['aid']);
  $types = array(
    'default' => 'Default',
  );
  $types += node_get_types('names');
  foreach (array_keys($types) as $type) {
    if (variable_get("gallery_assist_{$type}", 0) == 1) {
      $layout = array();
      $validate_upload = array();

      // Get the configuration data.
      $settings = variable_get('gallery_assist_' . $type . '_data', array());

      // Extract the layout array.
      $layout = $settings['layout'];
      unset($settings['layout']);

      // Extract the validate_upload array.
      $validate_upload = $settings['validate_upload'];
      unset($settings['validate_upload']);

      // Merge all to one level array.
      $new_settings = array_merge($settings, $layout, $validate_upload);

      // Add the new variables.
      $new_settings['ga_item_title_type'] = 0;
      $new_settings['pager_align'] = 'center';
      $new_settings['t_thm_link_format'] = 'item';

      // Save the system variable.
      variable_set('gallery_assist_' . $type . '_data', $new_settings);
    }
  }
  variable_set('gallery_assist_directory', file_directory_path() . '/gallery_assist');
  $cq = "TRUNCATE TABLE {cache_gallery_assist_data}";
  db_query($cq);
  return $ret;
}