You are here

function demo_dump_submit in Demonstration site (Sandbox / Snapshot) 5

File

./demo.admin.inc, line 151
Demonstration Site administrative pages

Code

function demo_dump_submit($form_id, $values) {
  global $db_type;

  // Generate info file.
  $info = demo_set_info($values);
  if (!$info) {
    return FALSE;
  }

  // Include database specific functions.
  $engine = $db_type == 'mysqli' ? 'mysql' : $db_type;
  $inc_file = drupal_get_path('module', 'demo') . '/database_' . $engine . '_dump.inc';
  if (file_exists($inc_file)) {
    require_once $inc_file;
    if (!empty($values['default'])) {

      // Set new default snapshot.
      demo_set_default($info['filename']);
    }

    // Increase PHP's max_execution_time for large dumps.
    @set_time_limit(600);

    // Perform dump.
    $fileconfig = demo_get_fileconfig($info['filename']);
    $exclude = array(
      '{cache}',
      '{cache_admin_menu}',
      '{cache_content}',
      '{cache_filter}',
      '{cache_menu}',
      '{cache_page}',
      '{cache_views}',
      '{panels_object_cache}',
      '{watchdog}',
    );
    $exclude = array_map('db_prefix_tables', $exclude);
    demo_dump_db($fileconfig['sqlfile'], $exclude);
    drupal_set_message(t('Successfully created snapshot %filename.', array(
      '%filename' => $fileconfig['sqlfile'],
    )));
  }
  else {
    drupal_set_message(t('@engine support not implemented yet.', array(
      '@engine' => ucfirst($engine),
    )), 'error');
  }
  drupal_goto('admin/build/demo/manage');
}