You are here

function backup_migrate_prune_update_7101 in Backup and migrate prune 7

Same name and namespace in other branches
  1. 7.2 backup_migrate_prune.install \backup_migrate_prune_update_7101()

Clarifies time slots

File

./backup_migrate_prune.install, line 88
Install hooks for Backup and Migrate.

Code

function backup_migrate_prune_update_7101(&$sandbox) {

  // Find all gardeners that had a 0 for the keep day and change them to a 7
  $records = db_select('backup_migrate_gardener', 'bmg')
    ->fields('bmg', array(
    'settings',
    'gardener_id',
  ))
    ->execute();
  foreach ($records as $record) {
    $settings = unserialize($record->settings);

    // Modify the settings
    $new_settings = array(
      'thisweek_slot' => $settings['lessthanday'],
      'thismonth_slot' => $settings['day'],
      'thisyear_slot' => $settings['week'],
      'pastyears_slot' => $settings['month'],
    );

    // Save the record
    $record = array(
      'settings' => $new_settings,
      'gardener_id' => $record->gardener_id,
    );
    drupal_write_record('backup_migrate_gardener', $record, 'gardener_id');
  }
}