diff --git a/app/Services/Upkeep/MaintenanceService.php b/app/Services/Upkeep/MaintenanceService.php index 21853ff..fbcf883 100644 --- a/app/Services/Upkeep/MaintenanceService.php +++ b/app/Services/Upkeep/MaintenanceService.php @@ -8,10 +8,14 @@ use Carbon\Carbon; class MaintenanceService { protected $settings; + protected $filePaths = []; public function __construct(SettingsService $settingsService) { - $this->settings = $settingsService; + $this->settings = $settingsService; + $this->filePaths = ['../public/assets/images/blog', + '../public/assets/images/user', '../public/assets/docs/blog', + '../public/assets/video/blog', '../public/assets/sound/blog']; } public function createContentBackUp() @@ -133,36 +137,21 @@ class MaintenanceService \ZipArchive::CREATE | \ZipArchive::OVERWRITE ); //gather data and path info for blog images - $blogImagesPath = '../public/assets/images/blog'; - $yearPaths = glob($blogImagesPath . '/*', GLOB_ONLYDIR); - foreach ($yearPaths as $years) { - $year = explode('/', $years); - $monthsPath = glob($blogImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR); - foreach ($monthsPath as $months) { - $month = explode('/', $months); - //once info is collected, add images pages to zip - $options = [ - 'add_path' => 'public/assets/images/blog/' . $year[5] . '/' . $month[6] . '/', - 'remove_all_path' => true, - ]; - $zip->addGlob($months . '/*.*', GLOB_BRACE, $options); - } - } - //gather data and path info for user images - $userImagesPath = '../public/assets/images/user'; - $yearPaths = glob($userImagesPath . '/*', GLOB_ONLYDIR); - foreach ($yearPaths as $years) { - $year = explode('/', $years); - $monthsPath = glob($userImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR); - foreach ($monthsPath as $months) { - $month = explode('/', $months); - //once info is collected, add images pages to zip - $options = [ - 'add_path' => 'public/assets/images/user/' . $year[5] . '/' . $month[6] . '/', - 'remove_all_path' => true, - ]; - $zip->addGlob($months . '/*.*', GLOB_BRACE, $options); + foreach ($this->filePaths as $path) { + $yearPaths = glob($path . '/*', GLOB_ONLYDIR); + foreach ($yearPaths as $years) { + $year = explode('/', $years); + $monthsPath = glob($path . '/' . $year[5] . '/*', GLOB_ONLYDIR); + foreach ($monthsPath as $months) { + $month = explode('/', $months); + //once info is collected, add images pages to zip + $options = [ + 'add_path' => substr($path, 3) . '/' . $year[5] . '/' . $month[6] . '/', + 'remove_all_path' => true, + ]; + $zip->addGlob($months . '/*.*', GLOB_BRACE, $options); + } } } diff --git a/public/assets/scripts/dash/app/controllers/MaintenanceManager.js b/public/assets/scripts/dash/app/controllers/MaintenanceManager.js index ce961c9..8f92c53 100644 --- a/public/assets/scripts/dash/app/controllers/MaintenanceManager.js +++ b/public/assets/scripts/dash/app/controllers/MaintenanceManager.js @@ -281,7 +281,7 @@ class MaintenanceManager { } }; if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) { - if (eventType === TASK_UPLOAD_FILES) + if (eventType === TASK_UPLOAD_FILES || eventType === TASK_BACKUP_CREATE) request.setRequestHeader('fipamo-access-token', self.token); switch (contentType) { case CONTENT_TYPE_JSON: