diff --git a/application/config/migration.php b/application/config/migration.php index ad5f4c8e..927c09f6 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 75; +$config['migration_version'] = 76; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/076_add_userid_to_notes.php b/application/migrations/076_add_userid_to_notes.php new file mode 100644 index 00000000..280dd4e9 --- /dev/null +++ b/application/migrations/076_add_userid_to_notes.php @@ -0,0 +1,19 @@ +dbforge->add_column('notes', $fields); + } + + public function down() + { + $this->dbforge->drop_column('notes', 'user_id'); + } +} diff --git a/application/models/Note.php b/application/models/Note.php index 3ccdbefa..22081b9d 100644 --- a/application/models/Note.php +++ b/application/models/Note.php @@ -9,6 +9,7 @@ class Note extends CI_Model { } function list_all() { + $this->db->where('user_id', $this->session->userdata('user_id')); return $this->db->get('notes'); } @@ -16,10 +17,11 @@ class Note extends CI_Model { $data = array( 'cat' => xss_clean($this->input->post('category')), 'title' => xss_clean($this->input->post('title')), - 'note' => xss_clean($this->input->post('content')) + 'note' => xss_clean($this->input->post('content')), + 'user_id' => $this->session->userdata('user_id') ); - $this->db->insert('notes', $data); + $this->db->insert('notes', $data); } function edit() { @@ -30,19 +32,21 @@ class Note extends CI_Model { ); $this->db->where('id', xss_clean($this->input->post('id'))); - $this->db->update('notes', $data); + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->update('notes', $data); } function delete($id) { - $this->db->delete('notes', array('id' => xss_clean($id))); + $this->db->delete('notes', array('id' => xss_clean($id), 'user_id' =>$this->session->userdata('user_id'))); } function view($id) { // Get Note - $this->db->where('id', xss_clean($id)); + $this->db->where('id', xss_clean($id)); + $this->db->where('user_id', $this->session->userdata('user_id')); return $this->db->get('notes'); } } -?> \ No newline at end of file +?>