From 6e9de547c074ad794b6d272eda9bf9b7d7bef792 Mon Sep 17 00:00:00 2001 From: Konstantin Vorobyev Date: Wed, 15 Feb 2017 17:38:48 +0900 Subject: Fix #3030: Add upload the sqlite database feature --- app/Controller/ConfigController.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'app/Controller/ConfigController.php') diff --git a/app/Controller/ConfigController.php b/app/Controller/ConfigController.php index 8572316e..222549f4 100644 --- a/app/Controller/ConfigController.php +++ b/app/Controller/ConfigController.php @@ -200,6 +200,32 @@ class ConfigController extends BaseController $this->response->redirect($this->helper->url->to('ConfigController', 'index')); } + /** + * Display the Sqlite database upload page + * + * @access public + */ + public function uploadDb() + { + $this->response->html($this->helper->layout->config('config/upload_db', array())); + } + + /** + * Replace current Sqlite db with uploaded file + * + * @access public + */ + public function uploadDbSave() + { + $filename = $this->request->getFilePath('file'); + if (!file_exists($filename) || !$this->configModel->uploadDatabase($filename)) { + $this->flash->failure(t('Unable to read your file')); + } else { + $this->flash->success(t('Database upload done.')); + } + $this->response->redirect($this->helper->url->to('ConfigController', 'index')); + } + /** * Regenerate webhook token * -- cgit v1.2.3