X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fpltableeditor.php;h=78d9fa48befcc3cd3734ad0a56678a678827833b;hb=7efca70c0648539d1fd38d77d4e60b33356c01dd;hp=35d5aae7d03497119052af0424fd62718ed8fffc;hpb=03849c3e86daed5b647984298ca9d8f55c3b1e35;p=platal.git diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index 35d5aae..78d9fa4 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -1,6 +1,6 @@ changeTpl('core/table-editor.tpl'); + $page->coreTpl('table-editor.tpl'); $list = true; + if ($action == 'delete') { + S::assert_xsrf_token(); - if ($action == 'delete' && S::has_xsrf_token()) { if (!isset($this->delete_action)) { foreach ($this->jtables as $table => $j) XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id); XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id); - $page->trig("L'entrée ".$id." a été supprimée."); + $page->trigSuccess("L'entrée ".$id." a été supprimée."); } else if ($this->delete_action) { XDB::execute($this->delete_action, $id); if (isset($this->delete_message)) { - $page->trig($this->delete_message); + $page->trigSuccess($this->delete_message); } else { - $page->trig("L'entrée ".$id." a été supprimée."); + $page->trigSuccess("L'entrée ".$id." a été supprimée."); } } else { - $page->trig("Impossible de supprimer l'entrée."); + $page->trigError("Impossible de supprimer l'entrée."); } - } else if ($action == 'delete') { - $page->trig("Impossible de supprimer l'entrée, merci de réessayer."); } if ($action == 'edit') { $r = XDB::query("SELECT * FROM {$this->table} WHERE {$this->idfield} = {?} AND {$this->whereclause}",$id); @@ -240,7 +239,9 @@ class PLTableEditor } $list = false; } - if ($action == 'update' && S::has_xsrf_token()) { + if ($action == 'update') { + S::assert_xsrf_token(); + $values = ""; $cancel = false; foreach ($this->vars as $field => $descr) { @@ -270,7 +271,7 @@ class PLTableEditor $val = "'".addslashes($val)."'"; } else { $cancel = true; - $page->trig("Il manque le champ ".$field); + $page->trigError("Il manque le champ ".$field); } $values .= $val; } @@ -279,18 +280,16 @@ class PLTableEditor XDB::execute("UPDATE {$this->table} SET {$this->idfield} = {?} WHERE {$this->idfield} = {?} AND {$this->whereclause}", Post::v($this->idfield), $id); XDB::execute("REPLACE INTO {$this->table} VALUES ($values)"); if ($id !== false) - $page->trig("L'entrée ".$id." a été mise à jour."); + $page->trigSuccess("L'entrée ".$id." a été mise à jour."); else { - $page->trig("Une nouvelle entrée a été créée."); + $page->trigSuccess("Une nouvelle entrée a été créée."); $id = XDB::insertId(); } } else - $page->trig("Impossible de mettre à jour."); + $page->trigError("Impossible de mettre à jour."); if (!$this->auto_return) { return $this->apply($page, 'edit', $id); } - } else if ($action == 'update') { - $page->trig("Impossible de mettre à jour, merci de réessayer."); } if ($action == 'sort') { $this->sortfield = $id;