]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/table.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 23 Oct 2017 15:37:55 +0000 (16:37 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 23 Oct 2017 15:37:55 +0000 (16:37 +0100)
lib/php/db/table.php

index e630a9a1599f7bdd2b491f71ac882e9f11fbe302..645e3b83a13398b928b16c28ce458bedc7b3925d 100644 (file)
@@ -534,22 +534,26 @@ Class Table extends nb {
     $st = $this->db()->conn->prepare($sql);
     $st->execute();
 
+    // Params
     $form_hidden = '';
     $url_params = [
       'referer' => (!empty($_SERVER['HTTP_REFERER']) ? urlencode($_SERVER['HTTP_REFERER']) : ''),
     ];
     if ($this->show_hidden_params and !empty(self::$params)) {
+      $ignore = ['limit'];
+
       $form_hidden = ''
-        .self::form_hidden([],array_merge($this->params2hash(self::$params),[
+        .self::form_hidden($ignore,array_merge($this->params2hash(self::$params),[
           'action' => ($add ? 'insert' : 'update'),
           'referer' => (!empty($_SERVER['HTTP_REFERER']) ? urlencode($_SERVER['HTTP_REFERER']) : ''),
         ]))
       ;
 
-      foreach (self::$params as $p) {
+      foreach (array_diff(self::$params,$ignore) as $p) {
         if (!($v = self::p($p))) continue;
         $url_params[$p] = $v;
       }
+
       $url_params['action'] = ($add ? 'insert' : 'update');
 
     } else {
@@ -558,7 +562,7 @@ Class Table extends nb {
     }
 
     #debug($form_hidden);
-    if (false and $url_params) {
+    if ($_SERVER['SERVER_NAME'] == 'rent' and $url_params) {
       $flat = [];
       foreach ($url_params as $k=>$v) {
         if ((string)$v === '') continue;
@@ -569,6 +573,7 @@ Class Table extends nb {
       $form_hidden = '';
     }
 
+    // Form
     echo '<form class="db edit form-table" method="post" action="'.$form_action.'">'.NB_EOL;
     echo '<div class="fields">'.NB_EOL;
     $count = 0;
@@ -1801,9 +1806,6 @@ Class Table extends nb {
   }
 
   public function action($action=null) {
-    #if (empty($action)) return;
-    #if ($action === null) $action = $this->p('action');
-    #debug($action);
 
     if ($action == 'table.fields') {
       $rows = $this->fields_rows();
@@ -1818,29 +1820,25 @@ Class Table extends nb {
       return $this->out($this->info());
 
     } elseif ($action == 'table.delete') {
-# NB 10.12.16       if (!$this->delete($this->p(),$e) and !isset($e['rowCount'])) bye($e);
       if (!$this->delete($_POST,$e) and !isset($e['rowCount'])) bye($e);
       $this->db()->print_header('Location',$this->url_referer(str_replace('&amp;','&',$this->url_list())));
       $this->out($e);
       return true;
 
     } elseif ($action == 'table.replace') {
-# NB 10.12.16       if (!$this->replace($this->p(),$e) and !isset($e['rowCount'])) bye($e);
       if (!$this->replace($_POST,$e) and !isset($e['rowCount'])) bye($e);
       $this->db()->print_header('Location',$this->url_referer());
       $this->out($e);
       return true;
 
     } elseif ($action == 'table.insert') {
-# NB 10.12.16       if (!$this->insert($this->p(),$e)) bye();
       if (!$this->insert($_POST,$e)) bye();
       $this->db()->print_header('Location',$this->url_referer());
       $this->out($e);
       return true;
 
     } elseif ($action == 'table.update') {
-# NB 10.12.16       if (!$this->update($this->p(),$e)) bye($e);
-      if (!$this->update($_POST,$e)) bye($e);
+      if ($this->update($_POST,$e) === false) bye($e);
       $this->db()->print_header('Location',$this->url_referer());
       $this->out($e);
       return true;