2011-06-17 12:52:00 +00:00
|
|
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Notes extends CI_Controller {
|
|
|
|
|
2019-10-05 18:35:55 +00:00
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$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'); }
|
2021-01-11 15:22:48 +00:00
|
|
|
|
|
|
|
// Load language files
|
|
|
|
$this->lang->load('notes');
|
2019-10-05 18:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 12:52:00 +00:00
|
|
|
/* Displays all notes in a list */
|
|
|
|
public function index()
|
|
|
|
{
|
2011-07-22 00:08:47 +00:00
|
|
|
$this->load->model('note');
|
|
|
|
$data['notes'] = $this->note->list_all();
|
2011-11-04 17:32:03 +00:00
|
|
|
$data['page_title'] = "Notes";
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2011-11-04 17:32:03 +00:00
|
|
|
$this->load->view('notes/main');
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2011-06-17 12:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Provides function for adding notes to the system. */
|
|
|
|
function add() {
|
|
|
|
|
2011-07-22 00:08:47 +00:00
|
|
|
$this->load->model('note');
|
|
|
|
|
2011-06-17 12:52:00 +00:00
|
|
|
$this->load->library('form_validation');
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('title', 'Note Title', 'required');
|
|
|
|
$this->form_validation->set_rules('content', 'Content', 'required');
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->form_validation->run() == FALSE)
|
|
|
|
{
|
2011-11-04 17:32:03 +00:00
|
|
|
$data['page_title'] = "Add Notes";
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2011-06-17 12:52:00 +00:00
|
|
|
$this->load->view('notes/add');
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2011-06-17 12:52:00 +00:00
|
|
|
}
|
|
|
|
else
|
2011-07-22 00:08:47 +00:00
|
|
|
{
|
|
|
|
$this->note->add();
|
2011-06-17 12:52:00 +00:00
|
|
|
|
|
|
|
redirect('notes');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* View Notes */
|
|
|
|
function view($id) {
|
2011-07-22 00:08:47 +00:00
|
|
|
$this->load->model('note');
|
|
|
|
|
|
|
|
$data['note'] = $this->note->view($id);
|
2011-06-17 12:52:00 +00:00
|
|
|
|
|
|
|
// Display
|
2011-11-04 17:32:03 +00:00
|
|
|
$data['page_title'] = "Note";
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2011-11-04 17:32:03 +00:00
|
|
|
$this->load->view('notes/view');
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2011-06-17 12:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Edit Notes */
|
|
|
|
function edit($id) {
|
2011-07-22 00:08:47 +00:00
|
|
|
$this->load->model('note');
|
2011-06-17 12:52:00 +00:00
|
|
|
$data['id'] = $id;
|
2011-07-22 00:08:47 +00:00
|
|
|
|
|
|
|
$data['note'] = $this->note->view($id);
|
2011-06-17 12:52:00 +00:00
|
|
|
|
|
|
|
$this->load->library('form_validation');
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('title', 'Note Title', 'required');
|
|
|
|
$this->form_validation->set_rules('content', 'Content', 'required');
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->form_validation->run() == FALSE)
|
|
|
|
{
|
2011-11-04 17:32:03 +00:00
|
|
|
$data['page_title'] = "Edit Note";
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2011-11-04 17:32:03 +00:00
|
|
|
$this->load->view('notes/edit');
|
2019-05-13 17:28:16 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2011-06-17 12:52:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-22 00:08:47 +00:00
|
|
|
$this->note->edit();
|
|
|
|
|
2011-06-17 12:52:00 +00:00
|
|
|
redirect('notes');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete Note */
|
|
|
|
function delete($id) {
|
2011-07-22 00:08:47 +00:00
|
|
|
$this->load->model('note');
|
|
|
|
$this->note->delete($id);
|
|
|
|
|
2011-06-17 12:52:00 +00:00
|
|
|
redirect('notes');
|
|
|
|
}
|
|
|
|
}
|