Merge pull request #1188 from AndreasK79/userid_hardware

[Hardware] Added userid to everything that has to do with hardware.
pull/1189/head^2
Andreas Kristiansen 2021-09-20 19:33:53 +02:00 zatwierdzone przez GitHub
commit d65f608439
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
4 zmienionych plików z 63 dodań i 41 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 76;
$config['migration_version'] = 77;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -9,7 +9,7 @@
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
// load the view
$data['page_title'] = "Radio Interface";
$data['page_title'] = "Hardware Interfaces";
$this->load->view('interface_assets/header', $data);
$this->load->view('radio/index');

Wyświetl plik

@ -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');
}
}

Wyświetl plik

@ -11,6 +11,7 @@
function update($result) {
$this->db->where('radio', $result['radio']);
$this->db->where('user_id', $this->session->userdata('user_id'));
$query = $this->db->get('cat');
if ($query->num_rows() > 0)
@ -30,6 +31,7 @@
);
$this->db->where('id', $radio_id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->update('cat', $data);
}
} else {
@ -45,6 +47,7 @@
);
$this->db->where('id', $radio_id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->update('cat', $data);
}
}
@ -61,6 +64,7 @@
'uplink_freq' => $result['uplink_freq'],
'downlink_mode' => $result['downlink_mode'],
'uplink_mode' => $result['uplink_mode'],
'user_id' => $this->session->userdata('user_id'),
);
} else {
$data = array(
@ -68,6 +72,7 @@
'frequency' => $result['frequency'],
'mode' => $result['mode'],
'timestamp' => $result['timestamp'],
'user_id' => $this->session->userdata('user_id'),
);
}
@ -76,15 +81,16 @@
}
}
function status() {
//$this->db->where('radio', $result['radio']);
$this->db->where('user_id', $this->session->userdata('user_id'));
$query = $this->db->get('cat');
return $query;
}
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);
$query = $this->db->get('cat');
@ -94,27 +100,23 @@
/* Return list of radios */
function radios() {
$this->db->select('id, radio');
$this->db->where('user_id', $this->session->userdata('user_id'));
$query = $this->db->get('cat');
return $query;
}
function radio_status($id) {
return $this->db->query('SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = '.$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($sql);
}
function delete($id) {
$this->db->where('id', $id);
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->delete('cat');
return true;
}
}
?>