You are here

function backup_migrate_ui_saved_backups in Backup and Migrate 7.3

Same name and namespace in other branches
  1. 8.3 backup_migrate.module \backup_migrate_ui_saved_backups()
  2. 6.3 backup_migrate.module \backup_migrate_ui_saved_backups()

List the previously created backups from across multiple destinations.

1 string reference to 'backup_migrate_ui_saved_backups'
backup_migrate_menu in ./backup_migrate.module
Implements hook_menu().

File

./backup_migrate.module, line 1453
Backup and restore databases for Drupal.

Code

function backup_migrate_ui_saved_backups() {
  require_once dirname(__FILE__) . '/includes/destinations.inc';
  require_once dirname(__FILE__) . '/includes/profiles.inc';
  require_once dirname(__FILE__) . '/includes/sources.inc';
  drupal_add_css(drupal_get_path('module', 'backup_migrate') . '/backup_migrate.css');
  $remote = FALSE;
  $now = $fetch_time = time();
  $refresh = isset($_GET['refresh']);
  $out = '';
  list($files, $fetch_time, $remote) = backup_migrate_get_saved_backups($refresh);

  // Redirect if refreshing instead of displaying.
  if ($refresh) {
    drupal_goto($_GET['q']);
  }
  $fetch = $out = '';

  // Get the fetch link.
  if ($fetch_time < $now) {
    $fetch = '<div class="description">' . t('This listing was fetched !time ago. !refresh', array(
      '!time' => format_interval($now - $fetch_time, 1),
      '!refresh' => l(t('fetch now'), $_GET['q'], array(
        'query' => array(
          'refresh' => 'true',
        ),
      )),
    )) . '</div>';
  }

  // Render the list.
  $out .= $fetch;
  $out .= _backup_migrate_ui_destination_display_file_list($files, array(
    'limit' => 20,
    'pager' => TRUE,
  ));
  $out .= $fetch;

  // Add a remote backups warning if there are no remote backups.
  if (!$remote && user_access('administer backup and migrate')) {
    drupal_set_message(t('You do not have any offsite backups. For the highest level of protection, <a href="!addurl">create an offsite destination</a> to save your backups to.', array(
      '!addurl' => url(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/add'),
    )), 'warning', FALSE);
  }
  return $out;
}