destinations.browser.inc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * @file
  4. * Functions to handle the browser upload/download backup destination.
  5. */
  6. /**
  7. * A destination type for browser upload/download.
  8. *
  9. * @ingroup backup_migrate_destinations
  10. */
  11. class backup_migrate_destination_browser extends backup_migrate_destination {
  12. /**
  13. * Get a row of data to be used in a list of items of this type.
  14. */
  15. function get_list_row() {
  16. // Return none as this type should not be displayed.
  17. return array();
  18. }
  19. }
  20. /**
  21. * A destination type for browser upload.
  22. *
  23. * @ingroup backup_migrate_destinations
  24. */
  25. class backup_migrate_destination_browser_upload extends backup_migrate_destination_browser {
  26. var $supported_ops = array('restore');
  27. function __construct() {
  28. $params = array();
  29. $params['name'] = "Upload";
  30. $params['machine_name'] = 'upload';
  31. parent::__construct($params);
  32. }
  33. /**
  34. * File load destination callback.
  35. */
  36. function load_file($file_id) {
  37. if ($file = file_save_upload('backup_migrate_restore_upload')) {
  38. $out = new backup_file(array('filepath' => $file->uri));
  39. backup_migrate_temp_files_add($file->uri);
  40. return $out;
  41. }
  42. return NULL;
  43. }
  44. }
  45. /**
  46. * A destination type for browser download.
  47. *
  48. * @ingroup backup_migrate_destinations
  49. */
  50. class backup_migrate_destination_browser_download extends backup_migrate_destination_browser {
  51. var $supported_ops = array('manual backup');
  52. // Browser downloads must always be the last destination as they must end the current process when they are done.
  53. var $weight = 1000;
  54. function __construct() {
  55. $params = array();
  56. $params['name'] = "Download";
  57. $params['machine_name'] = 'download';
  58. parent::__construct($params);
  59. }
  60. /**
  61. * File save destination callback.
  62. */
  63. function save_file($file, $settings) {
  64. backup_migrate_include('files');
  65. $file->transfer();
  66. }
  67. }