Some minor backup example extension changes for #1042

This commit is contained in:
the-djmaze 2024-03-18 16:28:54 +01:00
parent 190db75c19
commit 570c7e1a1a
2 changed files with 9 additions and 10 deletions

View file

@ -6,8 +6,8 @@ class BackupPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Backup', NAME = 'Backup',
AUTHOR = 'SnappyMail', AUTHOR = 'SnappyMail',
URL = 'https://snappymail.eu/', URL = 'https://snappymail.eu/',
VERSION = '1.1', VERSION = '1.2',
RELEASE = '2023-12-12', RELEASE = '2024-03-18',
REQUIRED = '2.30.0', REQUIRED = '2.30.0',
CATEGORY = 'General', CATEGORY = 'General',
LICENSE = 'MIT', LICENSE = 'MIT',
@ -17,12 +17,12 @@ class BackupPlugin extends \RainLoop\Plugins\AbstractPlugin
{ {
// Admin Settings tab // Admin Settings tab
$this->addJs('js/BackupAdminSettings.js', true); // add js file $this->addJs('js/BackupAdminSettings.js', true); // add js file
$this->addJsonHook('JsonAdminGetData'); $this->addJsonHook('JsonAdminBackupData');
$this->addJsonHook('JsonAdminRestoreData'); $this->addJsonHook('JsonAdminRestoreData');
$this->addTemplate('templates/BackupAdminSettingsTab.html', true); $this->addTemplate('templates/BackupAdminSettingsTab.html', true);
} }
public function JsonAdminGetData() public function JsonAdminBackupData()
{ {
if (!($this->Manager()->Actions() instanceof \RainLoop\ActionsAdmin) if (!($this->Manager()->Actions() instanceof \RainLoop\ActionsAdmin)
|| !$this->Manager()->Actions()->IsAdminLoggined() || !$this->Manager()->Actions()->IsAdminLoggined()
@ -79,18 +79,17 @@ class BackupPlugin extends \RainLoop\Plugins\AbstractPlugin
return $this->jsonResponse(__FUNCTION__, false); return $this->jsonResponse(__FUNCTION__, false);
} }
$result = false;
if (\class_exists('ZipArchive')) { if (\class_exists('ZipArchive')) {
$oArchive = new \ZipArchive(); $oArchive = new \ZipArchive();
$oArchive->open($_FILES['backup']['tmp_name'], \ZIPARCHIVE::CREATE); $oArchive->open($_FILES['backup']['tmp_name'], \ZIPARCHIVE::CREATE);
$oArchive->extractTo(APP_PRIVATE_DATA); $result = $oArchive->extractTo(APP_PRIVATE_DATA);
} else if (\class_exists('PharData')) { } else if (\class_exists('PharData')) {
$oArchive = new \PharData($sTmp, 0, null, \Phar::GZ); $oArchive = new \PharData($sTmp, 0, null, \Phar::GZ);
$oArchive->extractTo(APP_PRIVATE_DATA); $result = $oArchive->extractTo(APP_PRIVATE_DATA);
} }
return $this->jsonResponse(__FUNCTION__, array( return $this->jsonResponse(__FUNCTION__, $result);
'$_FILES' => $_FILES
));
} }
} }

View file

@ -30,7 +30,7 @@
link.remove(); link.remove();
} }
}, 'JsonAdminGetData'); }, 'JsonAdminBackupData');
} }
submitForm(form) { submitForm(form) {