diff --git a/application/controllers/Themes.php b/application/controllers/Themes.php new file mode 100644 index 00000000..2420e689 --- /dev/null +++ b/application/controllers/Themes.php @@ -0,0 +1,89 @@ +lang->load('contesting'); + + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() + { + $this->load->model('Themes_model'); + + $data['themes'] = $this->Themes_model->getThemes(); + + // Render Page + $data['page_title'] = "Themes"; + $this->load->view('interface_assets/header', $data); + $this->load->view('themes/index.php'); + $this->load->view('interface_assets/footer'); + } + + public function add() + { + $this->load->model('Themes_model'); + $this->load->library('form_validation'); + + $this->form_validation->set_rules('name', 'Theme Name', 'required'); + $this->form_validation->set_rules('foldername', 'Folder Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $data['page_title'] = "Create Theme"; + $this->load->view('themes/add', $data); + } + else + { + $this->Themes_model->add(); + } + } + + public function edit($id) + { + $this->load->library('form_validation'); + + $this->load->model('Themes_model'); + + $item_id_clean = $this->security->xss_clean($id); + + $data['theme'] = $this->Themes_model->theme($item_id_clean); + + $data['page_title'] = "Edit Theme"; + + $this->form_validation->set_rules('name', 'Theme Name', 'required'); + $this->form_validation->set_rules('foldername', 'Folder Name', 'required'); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('interface_assets/header', $data); + $this->load->view('themes/edit'); + $this->load->view('interface_assets/footer'); + } + else + { + $this->Themes_model->edit($item_id_clean); + + $data['notice'] = "Theme ".$this->security->xss_clean($this->input->post('name', true))." Updated"; + + redirect('themes'); + } + } + + public function delete() { + $id = $this->input->post('id'); + $this->load->model('Themes_model'); + $this->Themes_model->delete($id); + } +} diff --git a/application/models/Themes_model.php b/application/models/Themes_model.php new file mode 100644 index 00000000..8f34435c --- /dev/null +++ b/application/models/Themes_model.php @@ -0,0 +1,56 @@ +db->query('SELECT * FROM themes order by name'); + + return $result->result(); + } + + function delete($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + // Delete Theme + $this->db->delete('themes', array('id' => $clean_id)); + } + + function add() { + $data = array( + 'name' => xss_clean($this->input->post('name', true)), + 'foldername' => xss_clean($this->input->post('foldername', true)), + ); + + $this->db->insert('themes', $data); + } + + + function theme($id) { + // Clean ID + $clean_id = $this->security->xss_clean($id); + + $sql = "SELECT * FROM themes where id =" . $clean_id; + + $data = $this->db->query($sql); + + return ($data->row()); + } + + function edit($id) { + $data = array( + 'name' => xss_clean($this->input->post('name', true)), + 'foldername' => xss_clean($this->input->post('foldername', true)), + ); + + $this->db->where('id', $id); + $this->db->update('themes', $data); + } +} diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index c8195c33..d6a6e15d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2025,6 +2025,71 @@ function deleteQsl(id) { +uri->segment(1) == "themes") { ?> + + uri->segment(1) == "qslprint") { ?>