[Notes backup] Added support for backing up notes with an API key

This commit is contained in:
Andreas
2023-05-03 09:38:28 +02:00
parent d0e3408f34
commit 591bd15098
3 changed files with 29 additions and 11 deletions

View File

@@ -38,11 +38,11 @@ class Backup extends CI_Controller {
if ( ! write_file($data['filename'], $this->load->view('backup/exportall', $data, true)))
{
$data['status'] = false;
$data['status'] = false;
}
else
{
$data['status'] = true;
$data['status'] = true;
}
$data['page_title'] = "ADIF - Backup";
@@ -55,19 +55,26 @@ class Backup extends CI_Controller {
}
/* Export the notes to XML */
public function notes() {
public function notes($key = null) {
if ($key == null) {
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
}
$this->load->helper('file');
$this->load->model('note');
$data['list_note'] = $this->note->list_all();
$data['list_note'] = $this->note->list_all($key);
if ( ! write_file('backup/notes.xml', $this->load->view('backup/notes', $data, true)))
$data['filename'] = 'backup/notes'. date('_Y_m_d_H_i_s') .'.xml';
if ( ! write_file($data['filename'], $this->load->view('backup/notes', $data, true)))
{
$data['status'] = false;
$data['status'] = false;
}
else
{
$data['status'] = true;
$data['status'] = true;
}
$data['page_title'] = "Notes - Backup";