From: Devops Date: Sat, 1 Apr 2017 14:51:41 +0000 (+0100) Subject: www/dbq/dbq.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=11ae9fba07d1d33662d41f9c80e04da9f25b6bcc;p=nb.git www/dbq/dbq.php --- diff --git a/lib/php/page.php b/lib/php/page.php index fac991d8..a5a48a46 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -391,7 +391,7 @@ class Page extends nb { $doctype = ''.NB_EOL; //'; + $doctype = ''.NB_EOL; } else { $doctype = ''.NB_EOL; } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 89a2bff9..82b7b61a 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -13,6 +13,12 @@ class DbQ extends nb { const WRITE = 3; const VIEW = 1; public $perm = self::ADMIN; + public $perms = [ + 'admin' => self::ADMIN, + 'delete' => self::DELETE, + 'write' => self::WRITE, + 'view' => self::VIEW, + ]; public $title = 'Dbq'; public $sep_title = ' / '; @@ -134,7 +140,6 @@ class DbQ extends nb { $this->json = [ 'db.base' => ( empty($this->db) ? '' : $this->db->base ), 'table.base' => ( empty($this->table) ? '' : $this->table->base ), - 'table.rw' => $this->table_rw(), 'default.format' => $this->format_html, 'default.limit' => $this->default_limit, 'param.format' => $this->params['format'], @@ -145,6 +150,8 @@ class DbQ extends nb { 'param.deep' => $this->params_deep, 'text.add' => 'Add', 'text.clear' => 'Clear', + 'perm' => $this->perm, + 'perms' => $this->perms, ]; $this->page->js_code = 'window._dbq = '.json_encode($this->json); @@ -262,8 +269,6 @@ class DbQ extends nb { $opt = ($this->page->is('html') and $this->table_rw() - #and ($this->perm >= self::VIEW) - #and strpos('table view',$this->table->type()) !== false ) ? [ 'row_parse_pre' => function(&$r){ $GLOBALS['dbq_args'] = urlencode( join($this->param_args_sep,$this->table->fields_keys_values($r)) ); diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js index ddd23252..4b193bb0 100644 --- a/www/dbq/html/default.js +++ b/www/dbq/html/default.js @@ -124,16 +124,23 @@ document.addEventListener("DOMContentLoaded", function() { } }); + if ( window._dbq['perm'] < window._dbq['perms']['write']) { + document.querySelectorAll("form.edit").forEach(function(e) { + e.setAttribute('onsubmit','return false'); + }); + document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e) { + e.setAttribute('style','display:none'); + }); + } + document.querySelectorAll("form.menu input[type=submit]").forEach(function(e) { e.insertAdjacentHTML("afterend",'' +' ' - +( window._dbq['table.rw'] + +( window._dbq['perm'] >= window._dbq['perms']['write'] ? ' ' : '' )