Improve PR #3038
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
Version 1.0.40 (unreleased)
|
Version 1.0.40 (unreleased)
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
New features:
|
||||||
|
|
||||||
|
* Upload Sqlite database from user interface
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
* Use contextual menu instead of action column in users management
|
* Use contextual menu instead of action column in users management
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ class ConfigController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function uploadDb()
|
public function uploadDb()
|
||||||
{
|
{
|
||||||
$this->response->html($this->helper->layout->config('config/upload_db', array()));
|
$this->response->html($this->template->render('config/upload_db'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,14 +215,16 @@ class ConfigController extends BaseController
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function uploadDbSave()
|
public function saveUploadedDb()
|
||||||
{
|
{
|
||||||
$filename = $this->request->getFilePath('file');
|
$filename = $this->request->getFilePath('file');
|
||||||
|
|
||||||
if (!file_exists($filename) || !$this->configModel->uploadDatabase($filename)) {
|
if (!file_exists($filename) || !$this->configModel->uploadDatabase($filename)) {
|
||||||
$this->flash->failure(t('Unable to read your file'));
|
$this->flash->failure(t('Unable to read uploaded file.'));
|
||||||
} else {
|
} else {
|
||||||
$this->flash->success(t('Database upload done.'));
|
$this->flash->success(t('Database upload done.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->redirect($this->helper->url->to('ConfigController', 'index'));
|
$this->response->redirect($this->helper->url->to('ConfigController', 'index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,14 +52,13 @@ class ConfigModel extends SettingModel
|
|||||||
* Replace database file with uploaded one
|
* Replace database file with uploaded one
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @param string $file
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function uploadDatabase($file)
|
public function uploadDatabase($file)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->db->closeConnection();
|
$this->db->closeConnection();
|
||||||
$result = file_put_contents(DB_FILENAME, gzdecode(file_get_contents($file)));
|
return file_put_contents(DB_FILENAME, gzdecode(file_get_contents($file))) !== false;
|
||||||
return $result == false? false: true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert">
|
<div class="alert">
|
||||||
<ul>
|
<p>
|
||||||
<li><?= t('You can upload Gzip compressed Sqlite database you previously downloaded') ?></li>
|
<?= t('You can upload the Gzip compressed Sqlite database previously downloaded.') ?>
|
||||||
</ul>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="<?= $this->url->href('ConfigController', 'uploadDbSave') ?>" method="post" enctype="multipart/form-data">
|
<form action="<?= $this->url->href('ConfigController', 'saveUploadedDb') ?>" method="post" enctype="multipart/form-data">
|
||||||
<?= $this->form->csrf() ?>
|
<?= $this->form->csrf() ?>
|
||||||
|
|
||||||
<?= $this->form->label(t('Database file'), 'file') ?>
|
<?= $this->form->label(t('Database file'), 'file') ?>
|
||||||
|
|||||||
Reference in New Issue
Block a user