Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!defined('BASEPATH'))
- exit('No direct script access allowed');
- class Admin extends CI_Controller {
- public function chapters($action="", $id="") {
- if (!$this->users->can_access(USERS_ADMIN)) {
- die($this->load->view("errors/users_cant_access", '', true));
- }
- $data = array(
- "title" => "Gestion des Chapitres",
- "output" => "",
- );
- if ($action == "add") {
- // Irelevant !
- } elseif ($action == "edit" && is_numeric($id)) {
- echo var_dump($_FILES); // Empty when I submit a .zip !
- echo var_dump($_POST); // Empty when I submit a .zip !
- $query = "SELECT *
- FROM webcopedia_chapters
- LEFT OUTER JOIN webcopedia_projects ON chapter_project = project_id
- LEFT OUTER JOIN webcopedia_teams ON chapter_team = team_id
- WHERE chapter_id = {$id}";
- $query = $this->db->query($query);
- if ($query->num_rows() == 1) {
- $data["chapter_data"] = $query->row_array();
- $data["title"] = "Edition de " . $data["chapter_data"]["project_name"];
- $this->form_validation->set_rules('chapter-edit-title', 'Titre', 'required');
- $this->form_validation->set_rules('chapter-edit-team', 'Team', 'required');
- $this->form_validation->set_rules('chapter-edit-project', 'Webcomic', 'required');
- $this->form_validation->set_rules('chapter-edit-sort', 'Numéro', 'required');
- if ($this->form_validation->run()) {
- $update = array(
- 'chapter_title' => $this->input->post("chapter-edit-title"),
- 'chapter_sort' => $this->input->post("chapter-edit-sort"),
- 'chapter_team' => $this->input->post("chapter-edit-team"),
- 'chapter_project' => $this->input->post("chapter-edit-project"),
- );
- $this->db->where('chapter_id', $id);
- $query = $this->db->update('webcopedia_chapters', $update);
- if ($query) {
- $data["output"] = "<div class='success'>Webcomic édité avec succés !</div>";
- $config['upload_path'] = './uploads/temps';
- $config['file_name'] = $id;
- $config['overwrite'] = TRUE;
- $this->load->library('upload', $config);
- if (!$this->upload->do_upload("chapter-edit-files")) {
- $data["output"] .= $this->upload->display_errors("<div class='error'>Chapitre : ", "</div>");
- } else {
- echo $data["chapter_data"]["chapter_project"] . "/" . $data["chapter_data"]["chapter_team"] . "/" . $data["chapter_data"]["chapter_sort"];
- }
- } else {
- $data["output"] = "<div class='error'>Une erreur est survenue !</div>";
- }
- } else {
- echo var_dump($this->input->post());
- echo var_dump($_POST);
- }
- $this->load->view('admin_chapter_edit', $data);
- } else {
- echo "Aucun résultat";
- }
- } else {
- // Irelevant !
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement