kopia lustrzana https://github.com/magicbug/Cloudlog
commit
ad045a1a8d
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
|||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 75;
|
||||
$config['migration_version'] = 76;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Migration_add_userid_to_notes extends CI_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$fields = array(
|
||||
'user_id BIGINT(20) DEFAULT NULL',
|
||||
);
|
||||
|
||||
$this->dbforge->add_column('notes', $fields);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dbforge->drop_column('notes', 'user_id');
|
||||
}
|
||||
}
|
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Ładowanie…
Reference in New Issue