You are here

function nivo_slider_update_7002 in Nivo Slider 7

Update existing slide property names and add new properties.

File

./nivo_slider.install, line 93
Install, update and uninstall functions for the Nivo Slider module.

Code

function nivo_slider_update_7002() {

  // Create an array to hold the new slider settings
  $new_slider = array();

  // Get the old slider settings
  $old_slider = variable_get('nivo_slider_banner_settings', array());
  foreach ($old_slider as $old_slide) {
    $new_slider[] = array(
      'path' => isset($old_slide['image_path']) ? $old_slide['image_path'] : '',
      'title' => isset($old_slide['image_title']) ? $old_slide['image_title'] : '',
      'description' => array(
        'value' => isset($old_slide['image_description']) ? $old_slide['image_description'] : '',
        'format' => 'plain_text',
      ),
      'url' => isset($old_slide['image_url']) ? $old_slide['image_url'] : '',
      'visibility' => isset($old_slide['image_visibility']) ? $old_slide['image_visibility'] : '*',
      'transition' => isset($old_slide['image_transition']) ? $old_slide['image_transition'] : '',
      'weight' => isset($old_slide['image_weight']) ? $old_slide['image_weight'] : 1,
      'published' => isset($old_slide['image_published']) ? $old_slide['image_published'] : TRUE,
      'delete' => isset($old_slide['image_delete']) ? $old_slide['image_delete'] : '',
    );
  }

  // Save the new settings
  variable_set('nivo_slider_banner_settings', $new_slider);
  return t('Updated existing slide property names and added new properties.');
}