kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #2107 from AndreasK79/notes_backup_api
commit
994c447ccf
|
@ -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";
|
||||
|
|
|
@ -2,8 +2,19 @@
|
|||
|
||||
class Note extends CI_Model {
|
||||
|
||||
function list_all() {
|
||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||
function list_all($api_key = null) {
|
||||
if ($api_key == null) {
|
||||
$user_id = $this->session->userdata('user_id');
|
||||
} else {
|
||||
$CI =& get_instance();
|
||||
$CI->load->model('api_model');
|
||||
if (strpos($this->api_model->access($api_key), 'r') !== false) {
|
||||
$this->api_model->update_last_used($api_key);
|
||||
$user_id = $this->api_model->key_userid($api_key);
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->where('user_id', $user_id);
|
||||
return $this->db->get('notes');
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
|
||||
<?php if($status == true) { ?>
|
||||
|
||||
<p>The backup of your notes completed successfully. The output can be found at: <a href="<?php echo base_url(); ?>backup/notes.xml"><?php echo base_url(); ?>backup/notes.xml</a></p>
|
||||
|
||||
<p>The backup of your notes completed successfully. The output can be found at: <a href="<?php echo base_url().$filename;?>"><?php echo base_url() . $filename; ?></a></p>
|
||||
|
||||
<p>You could automate this process by making it a cronjob.</p>
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue