kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #1188 from AndreasK79/userid_hardware
[Hardware] Added userid to everything that has to do with hardware.pull/1189/head^2
commit
d65f608439
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['migration_version'] = 76;
|
$config['migration_version'] = 77;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||||
|
|
||||||
// load the view
|
// load the view
|
||||||
$data['page_title'] = "Radio Interface";
|
$data['page_title'] = "Hardware Interfaces";
|
||||||
|
|
||||||
$this->load->view('interface_assets/header', $data);
|
$this->load->view('interface_assets/header', $data);
|
||||||
$this->load->view('radio/index');
|
$this->load->view('radio/index');
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Migration_add_userid_to_hardware extends CI_Migration {
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$fields = array(
|
||||||
|
'user_id BIGINT(20) DEFAULT NULL',
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->dbforge->add_column('cat', $fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->dbforge->drop_column('cat', 'user_id');
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
function update($result) {
|
function update($result) {
|
||||||
|
|
||||||
$this->db->where('radio', $result['radio']);
|
$this->db->where('radio', $result['radio']);
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$query = $this->db->get('cat');
|
$query = $this->db->get('cat');
|
||||||
|
|
||||||
if ($query->num_rows() > 0)
|
if ($query->num_rows() > 0)
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->db->where('id', $radio_id);
|
$this->db->where('id', $radio_id);
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->update('cat', $data);
|
$this->db->update('cat', $data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,6 +47,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->db->where('id', $radio_id);
|
$this->db->where('id', $radio_id);
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->update('cat', $data);
|
$this->db->update('cat', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +64,7 @@
|
||||||
'uplink_freq' => $result['uplink_freq'],
|
'uplink_freq' => $result['uplink_freq'],
|
||||||
'downlink_mode' => $result['downlink_mode'],
|
'downlink_mode' => $result['downlink_mode'],
|
||||||
'uplink_mode' => $result['uplink_mode'],
|
'uplink_mode' => $result['uplink_mode'],
|
||||||
|
'user_id' => $this->session->userdata('user_id'),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -68,6 +72,7 @@
|
||||||
'frequency' => $result['frequency'],
|
'frequency' => $result['frequency'],
|
||||||
'mode' => $result['mode'],
|
'mode' => $result['mode'],
|
||||||
'timestamp' => $result['timestamp'],
|
'timestamp' => $result['timestamp'],
|
||||||
|
'user_id' => $this->session->userdata('user_id'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,15 +81,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function status() {
|
function status() {
|
||||||
//$this->db->where('radio', $result['radio']);
|
//$this->db->where('radio', $result['radio']);
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$query = $this->db->get('cat');
|
$query = $this->db->get('cat');
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function recent_status() {
|
function recent_status() {
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->where("timestamp > date_sub(now(), interval 15 minute)", NULL, FALSE);
|
$this->db->where("timestamp > date_sub(now(), interval 15 minute)", NULL, FALSE);
|
||||||
|
|
||||||
$query = $this->db->get('cat');
|
$query = $this->db->get('cat');
|
||||||
|
@ -94,27 +100,23 @@
|
||||||
/* Return list of radios */
|
/* Return list of radios */
|
||||||
function radios() {
|
function radios() {
|
||||||
$this->db->select('id, radio');
|
$this->db->select('id, radio');
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$query = $this->db->get('cat');
|
$query = $this->db->get('cat');
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function radio_status($id) {
|
function radio_status($id) {
|
||||||
|
$sql = 'SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = ' . $id . ' and user_id =' . $this->session->userdata('user_id');
|
||||||
return $this->db->query('SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = '.$id.' ');
|
return $this->db->query($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function delete($id) {
|
function delete($id) {
|
||||||
$this->db->where('id', $id);
|
$this->db->where('id', $id);
|
||||||
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
$this->db->delete('cat');
|
$this->db->delete('cat');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Ładowanie…
Reference in New Issue