diff options
author | Frédéric Guillot <contact@fredericguillot.com> | 2014-01-25 14:56:02 -0500 |
---|---|---|
committer | Frédéric Guillot <contact@fredericguillot.com> | 2014-01-25 14:56:02 -0500 |
commit | 9383a15af699ede77142d040b65118e15754a2ca (patch) | |
tree | b550b5adf5bcf8f5a8793c188cc5630f26a27d49 /controllers/config.php |
First commit
Diffstat (limited to 'controllers/config.php')
-rw-r--r-- | controllers/config.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/controllers/config.php b/controllers/config.php new file mode 100644 index 00000000..96a6a085 --- /dev/null +++ b/controllers/config.php @@ -0,0 +1,70 @@ +<?php + +namespace Controller; + +class Config extends Base +{ + // Settings page + public function index() + { + $this->response->html($this->template->layout('config_index', array( + 'db_size' => $this->config->getDatabaseSize(), + 'user' => $_SESSION['user'], + 'projects' => $this->project->getList(), + 'languages' => $this->config->getLanguages(), + 'values' => $this->config->getAll(), + 'errors' => array(), + 'menu' => 'config', + 'title' => t('Settings') + ))); + } + + // Validate and save settings + public function save() + { + $this->checkPermissions(); + + $values = $this->request->getValues(); + list($valid, $errors) = $this->config->validateModification($values); + + if ($valid) { + + if ($this->config->save($values)) { + $this->config->reload(); + $this->session->flash(t('Settings saved successfully.')); + $this->response->redirect('?controller=config'); + } + else { + $this->session->flashError(t('Unable to save your settings.')); + } + } + + $this->response->html($this->template->layout('config_index', array( + 'db_size' => $this->config->getDatabaseSize(), + 'user' => $_SESSION['user'], + 'projects' => $this->project->getList(), + 'languages' => $this->config->getLanguages(), + 'values' => $values, + 'errors' => $errors, + 'menu' => 'config', + 'title' => t('Settings') + ))); + } + + // Download the database + public function downloadDb() + { + $this->checkPermissions(); + $this->response->forceDownload('db.sqlite.gz'); + $this->response->binary($this->config->downloadDatabase()); + } + + // Optimize the database + public function optimizeDb() + { + $this->checkPermissions(); + $this->config->optimizeDatabase(); + $this->session->flash(t('Database optimization done.')); + $this->response->redirect('?controller=config'); + } +} |