destinations.browser.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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['destination_id'] = 'upload';
  31. parent::__construct($params);
  32. }
  33. /**
  34. * File load destination callback.
  35. */
  36. function load_file($file_id) {
  37. backup_migrate_include('files');
  38. if ($file = file_save_upload('backup_migrate_restore_upload')) {
  39. $out = new backup_file(array('filepath' => $file->uri));
  40. backup_migrate_temp_files_add($file->uri);
  41. return $out;
  42. }
  43. return NULL;
  44. }
  45. }
  46. /**
  47. * A destination type for browser download.
  48. *
  49. * @ingroup backup_migrate_destinations
  50. */
  51. class backup_migrate_destination_browser_download extends backup_migrate_destination_browser {
  52. var $supported_ops = array('manual backup');
  53. function __construct() {
  54. $params = array();
  55. $params['name'] = "Download";
  56. $params['destination_id'] = 'download';
  57. parent::__construct($params);
  58. }
  59. /**
  60. * File save destination callback.
  61. */
  62. function save_file($file, $settings) {
  63. backup_migrate_include('files');
  64. $file->transfer();
  65. }
  66. }