Fixes message when adding a new entry with tableeditor. Closes #1022.
authorPascal Corpet <pascal.corpet@m4x.org>
Sat, 5 Jun 2010 12:52:15 +0000 (14:52 +0200)
committerPascal Corpet <pascal.corpet@m4x.org>
Sat, 5 Jun 2010 12:52:31 +0000 (14:52 +0200)
Signed-off-by: Pascal Corpet <pascal.corpet@m4x.org>
ChangeLog
classes/pltableeditor.php

index c3ea104..c69eaad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ VERSION 1.0.3                                                         XX XX XXXX
 
 New:
 
+Bug:
+    * #1022: Fixes message when adding a new entry with tableeditor         -Car
+
 ================================================================================
 VERSION 1.0.2                                                         13 11 2009
 
index efab475..43fc7b2 100644 (file)
@@ -233,8 +233,6 @@ class PLTableEditor
         }
         if ($action == 'new') {
             if (!$this->idfield_editable) {
-                $r = XDB::query("SELECT MAX({$this->idfield})+1 FROM {$this->table}");
-                $page->assign('id', $r->fetchOneCell());
                 $page->assign('entry', $this->prepare_new());
             }
             $list = false;
@@ -279,9 +277,9 @@ class PLTableEditor
                 if ($this->idfield_editable && ($id != Post::v($this->idfield)) && $action != 'new')
                     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)
+                if ($id !== false && $id !== null) {
                     $page->trigSuccess("L'entrée ".$id." a été mise à jour.");
-                else {
+                else {
                     $page->trigSuccess("Une nouvelle entrée a été créée.");
                     $id = XDB::insertId();
                 }