You are here

function dynamic_background_update_7003 in Dynamic Background 7.2

Move saved images to new data structure.

File

./dynamic_background.install, line 120
Installation file for dynamic background, currently only the uninstall function is present.

Code

function dynamic_background_update_7003() {
  $images = variable_get('dynamic_background_images', array());
  foreach ($images as $id => $image) {
    if (isset($image['fid'])) {

      // Move image into the new table.
      db_insert('dynamic_background_images')
        ->fields(array(
        'fid' => $image['fid'],
        'data' => '-1',
        'extension' => 'default',
      ))
        ->execute();

      // Update usage table, with active table.
      if ($image['picture_use']) {
        db_insert('dynamic_background_usage')
          ->fields(array(
          'fid' => $image['fid'],
          'type' => 'default',
          'data' => '-1',
        ))
          ->execute();
      }
    }
  }

  // Remove active background image variable.
  variable_del('dynamic_background_active');
}