| 1 |
<?php |
| 2 |
|
| 3 |
class UpdraftPlus_BackupModule_webdav { |
| 4 |
|
| 5 |
// backup method: takes an array, and shovels them off to the cloud storage |
| 6 |
public function backup($backup_array) { |
| 7 |
|
| 8 |
global $updraftplus; |
| 9 |
|
| 10 |
$addon_exists = apply_filters('updraft_webdav_exists', 'no'); |
| 11 |
if ($addon_exists !== 'yes') { |
| 12 |
$updraftplus->log('You do not have the UpdraftPlus WebDAV add-on installed - get it from http://updraftplus.com/shop/'); |
| 13 |
$updraftplus->log(sprintf(__('You do not have the UpdraftPlus %s add-on installed - get it from %s','updraftplus'),'WebDAV','http://updraftplus.com/shop/'), 'error'); |
| 14 |
return false; |
| 15 |
} |
| 16 |
|
| 17 |
// Do our uploading stuff... |
| 18 |
|
| 19 |
// If successful, then you must do this: |
| 20 |
// $updraftplus->uploaded_file($file); |
| 21 |
|
| 22 |
return apply_filters('updraft_webdav_upload_files', null, $backup_array); |
| 23 |
|
| 24 |
} |
| 25 |
|
| 26 |
// delete method: takes a file name (base name) (or array thereof), and removes it from the cloud storage |
| 27 |
public function delete($files, $method_obj = false) { |
| 28 |
|
| 29 |
global $updraftplus; |
| 30 |
|
| 31 |
$addon_exists = apply_filters('updraft_webdav_exists', 'no'); |
| 32 |
if ($addon_exists !== 'yes') { |
| 33 |
$updraftplus->log('You do not have the UpdraftPlus WebDAV add-on installed - get it from http://updraftplus.com/shop/'); |
| 34 |
$updraftplus->log(sprintf(__('You do not have the UpdraftPlus %s add-on installed - get it from %s','updraftplus'),'WebDAV','http://updraftplus.com/shop/'), 'error'); |
| 35 |
return false; |
| 36 |
} |
| 37 |
|
| 38 |
return apply_filters('updraft_webdav_delete_files', false, $files, $method_obj); |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
// download method: takes a file name (base name), and removes it from the cloud storage |
| 43 |
public function download($file) { |
| 44 |
|
| 45 |
global $updraftplus; |
| 46 |
|
| 47 |
$addon_exists = apply_filters('updraft_webdav_exists', 'no'); |
| 48 |
if ($addon_exists !== 'yes') { |
| 49 |
$updraftplus->log('You do not have the UpdraftPlus WebDAV add-on installed - get it from http://updraftplus.com/shop/'); |
| 50 |
$updraftplus->log(sprintf(__('You do not have the UpdraftPlus %s add-on installed - get it from %s','updraftplus'),'WebDAV','http://updraftplus.com/shop/'), 'error'); |
| 51 |
return false; |
| 52 |
} |
| 53 |
|
| 54 |
return apply_filters('updraft_webdav_download_file', false, $file); |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
// config_print: prints out table rows for the configuration screen |
| 59 |
// Your rows need to have a class exactly matching your method (in this example, webdav), and also a class of updraftplusmethod |
| 60 |
// Note that logging is not available from this context; it will do nothing. |
| 61 |
public function config_print() { |
| 62 |
|
| 63 |
$link = sprintf(__('%s support is available as an add-on','updraftplus'),'WebDAV').' - <a href="http://updraftplus.com/shop/webdav/">'.__('follow this link to get it','updraftplus'); |
| 64 |
|
| 65 |
$default = <<<ENDHERE |
| 66 |
<tr class="updraftplusmethod webdav"> |
| 67 |
<th>WebDAV:</th> |
| 68 |
<td>$link</a></td> |
| 69 |
</tr> |
| 70 |
ENDHERE; |
| 71 |
|
| 72 |
echo apply_filters('updraft_webdav_config_print', $default); |
| 73 |
} |
| 74 |
|
| 75 |
public function config_print_javascript_onready() { |
| 76 |
do_action('updraft_webdav_config_javascript'); |
| 77 |
} |
| 78 |
|
| 79 |
public function credentials_test() { |
| 80 |
do_action('updraft_webdav_credentials_test'); |
| 81 |
die; |
| 82 |
} |
| 83 |
|
| 84 |
} |
| 85 |
|