From 3851b0a61b849d36cc34c32134e08d7261b0ecd7 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Tue, 30 Jan 2007 09:25:29 +0000 Subject: [PATCH] Better behaviour of table editor when editing a tip git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1431 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/pltableeditor.php | 15 ++++++++++++++- modules/events.php | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/classes/pltableeditor.php b/classes/pltableeditor.php index 430cc15..92de61d 100644 --- a/classes/pltableeditor.php +++ b/classes/pltableeditor.php @@ -43,6 +43,9 @@ class PLTableEditor { // null => delete effectively, false => no deletion, SQL var $delete_action; var $delete_message; + // Should "Save" button return to the list view + var $auto_return = true; + /* table editor for platal * $plname : the PLname of the page, ex: admin/payments * $table : the table to edit, ex: profile_medals @@ -126,6 +129,11 @@ class PLTableEditor { } return $entry; } + // set whether the save button show redirect to list view or edit view + function list_on_edit($var) + { + $this->auto_return = $var; + } // change display of a field function describe($name, $desc, $display) { $this->vars[$name]['desc'] = $desc; @@ -237,10 +245,15 @@ class PLTableEditor { XDB::execute("REPLACE INTO {$this->table} VALUES ($values)"); if ($id !== false) $page->trig("L'entrée ".$id." a été mise à jour."); - else + else { $page->trig("Une nouvelle entrée a été créée."); + $id = XDB::insertId(); + } } else $page->trig("Impossible de mette à jour."); + if (!$this->auto_return) { + return $this->apply($page, 'edit', $id); + } } if ($action == 'sort') { $this->sortfield = $id; diff --git a/modules/events.php b/modules/events.php index 3e0ff46..d32f930 100644 --- a/modules/events.php +++ b/modules/events.php @@ -247,8 +247,9 @@ class EventsModule extends PLModule $table_editor->describe('state', 'actif', true); $table_editor->describe('text', 'texte (html) de l\'astuce', false); $table_editor->describe('priorite', '0<=priorité<=255', true); + $table_editor->list_on_edit(false); $table_editor->apply($page, $action, $id); - if ($action == 'edit' && !is_null($id)) { + if (($action == 'edit' && !is_null($id)) || $action == 'update') { $page->changeTpl('events/admin_tips.tpl'); } } -- 2.1.4