芝麻web文件管理V1.00
编辑当前文件:/home/prismawe/www/resupres/application/classes/controller/admin/duels.php
where('dateDebut', '>', DB::expr('current_date')) ->order_by('dateDebut') ->find_all(); $this->template->content = View::factory('admin/duels/list'); $this->template->content->duels = $duels; } public function action_new(){ $candidats = ORM::factory('candidat') //->where('isCandidate', '=', 1) ->order_by('nom', 'ASC') ->order_by('prenom', 'ASC') ->find_all(); $this->template->content = View::factory('admin/duels/new'); $this->template->content->candidats = $candidats; } public function action_newPost(){ $duel = ORM::factory('duel'); $duel->dateDebut = $this->request->post('dateDebut'); $duel->dateFin = $this->request->post('dateFin'); $duel->candidat1_id = $this->request->post('candidat1'); $duel->candidat2_id = $this->request->post('candidat2'); $duel->description = $this->request->post('description'); $duel->candidat_blanc = 0; $duel->save(); $this->request->redirect('admin/duels'); } public function action_modify(){ $duel = ORM::factory('duel') ->where('id', '=', $this->request->param('id')) ->and_where('dateDebut', '>', DB::expr('current_date')) ->find(); $candidats = ORM::factory('candidat') ->where('isCandidate', '=', 1) ->order_by('nom', 'ASC') ->order_by('prenom', 'ASC') ->find_all(); if ($duel->loaded()){ $this->template->content = View::factory('admin/duels/modify'); $this->template->content->duel = $duel; $this->template->content->candidats = $candidats; } else $this->request->redirect('admin/duels'); } public function action_modifyPost(){ $duel = ORM::factory('duel') ->where('id', '=', $this->request->param('id')) ->and_where('dateDebut', '>', DB::expr('current_date')) ->find(); if ($duel->loaded()){ $duel->dateDebut = $this->request->post('dateDebut'); $duel->dateFin = $this->request->post('dateFin'); $duel->candidat1_id = $this->request->post('candidat1'); $duel->candidat2_id = $this->request->post('candidat2'); $duel->description = $this->request->post('description'); $duel->candidat_blanc = 0; $duel->save(); } $this->request->redirect('admin/duels'); } public function action_delete(){ $duel = ORM::factory('duel') ->where('id', '=', $this->request->param('id')) ->and_where('dateDebut', '>', DB::expr('current_date')) ->find(); if ($duel->loaded()){ $duel->delete(); } $this->request->redirect('admin/duels'); } }