Better behaviour of table editor when editing a tip
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 30 Jan 2007 09:25:29 +0000 (09:25 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 30 Jan 2007 09:25:29 +0000 (09:25 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1431 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/pltableeditor.php
modules/events.php

index 430cc15..92de61d 100644 (file)
@@ -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;
index 3e0ff46..d32f930 100644 (file)
@@ -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');
         }
     }