From: Nicolas Boisselier Date: Mon, 23 Oct 2017 15:37:55 +0000 (+0100) Subject: lib/php/db/table.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e244e4360804cd8c7801535dc93694e25b9f2598;p=nb.git lib/php/db/table.php --- diff --git a/lib/php/db/table.php b/lib/php/db/table.php index e630a9a1..645e3b83 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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 '
'.NB_EOL; echo '
'.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('&','&',$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;