From e04e324365d405230b542d4532709e368ae3415f Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Tue, 13 Nov 2012 20:14:39 +0000 Subject: [PATCH] Added the ability to delete radio profiles --- application/controllers/radio.php | 38 ++++++++++++++++++++++++++++++- application/models/cat.php | 7 ++++++ application/views/radio/index.php | 10 +++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/application/controllers/radio.php b/application/controllers/radio.php index 36ec380d..74ba5474 100644 --- a/application/controllers/radio.php +++ b/application/controllers/radio.php @@ -4,6 +4,10 @@ public function index() { + // Check Auth + $this->load->model('user_model'); + 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 Status"; @@ -13,15 +17,21 @@ } function status() { + + // Check Auth + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $this->load->model('cat'); $query = $this->cat->status(); if ($query->num_rows() > 0) { - echo ""; + echo ""; echo "Radio"; echo "Frequency"; echo "Mode"; echo "Timestamp" ; + echo "Options"; echo ""; foreach ($query->result() as $row) { @@ -30,6 +40,7 @@ echo "".$row->frequency.""; echo "".$row->mode.""; echo "".$row->timestamp."" ; + echo "id."\" >\"Delete\"" ; echo ""; } } else { @@ -41,6 +52,11 @@ } function frequency($id) { + + // Check Auth + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + //$this->db->where('radio', $result['radio']); $this->db->select('frequency'); $this->db->where('id', $id); @@ -56,6 +72,11 @@ } function mode($id) { + + // Check Auth + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + //$this->db->where('radio', $result['radio']); $this->db->select('mode'); $this->db->where('id', $id); @@ -69,6 +90,21 @@ } } } + + function delete($id) { + // Check Auth + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + $this->load->model('cat'); + + $this->cat->delete($id); + + $this->session->set_flashdata('message', 'Radio Profile Deleted'); + + redirect('radio'); + + } } ?> \ No newline at end of file diff --git a/application/models/cat.php b/application/models/cat.php index bcb00920..1e776faf 100644 --- a/application/models/cat.php +++ b/application/models/cat.php @@ -57,6 +57,13 @@ return $query; } + function delete($id) { + $this->db->where('id', $id); + $this->db->delete('cat'); + + return true; + } + } diff --git a/application/views/radio/index.php b/application/views/radio/index.php index d6c6706b..55edb122 100644 --- a/application/views/radio/index.php +++ b/application/views/radio/index.php @@ -13,10 +13,18 @@

+ + session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+
- + +