]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorDevops <sys@15gifts.com>
Sat, 1 Apr 2017 14:51:41 +0000 (15:51 +0100)
committerDevops <sys@15gifts.com>
Sat, 1 Apr 2017 14:51:41 +0000 (15:51 +0100)
lib/php/page.php
www/dbq/dbq.php
www/dbq/html/default.js

index fac991d813b530e43172cd5bb3781e26b3d0947a..a5a48a46b74e6ec68791b833a3aa15b22df4aae8 100644 (file)
@@ -391,7 +391,7 @@ class Page extends nb {
       $doctype = '<?xml version="1.0" encoding="'.strtoupper(self::$charset).'"?>'.NB_EOL; //<?
     } elseif (self::$html5) {
       # See: http://www.w3.org/TR/html-markup/elements.html
-      $doctype = '<!DOCTYPE html>'; 
+      $doctype = '<!DOCTYPE html>'.NB_EOL
     } else {
       $doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'.NB_EOL;
     }
index 89a2bff94395216ef4d20802e9ef13aeee4dfa06..82b7b61ad36d98617cff3a79c4401842aa8f395c 100644 (file)
@@ -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)) );
index ddd23252247b9751f7772a635786801a37d3893f..4b193bb01b175775acf5ddf0a0e2602855442fd3 100644 (file)
@@ -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",''
       +'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)"'
         +' value="'+window._dbq['text.clear']+'"'
       +' />'
-      +( window._dbq['table.rw']
+      +( window._dbq['perm'] >= window._dbq['perms']['write']
         ? '&nbsp;<input type="button" class="add '+e.className+'"'
           +' onclick="window.location=\''+window._dbq['table.base']+'/add/\'"'
-          //+' onclick="window.location=\''+window._dbq['table.base']+'add/\'"'
-          //+' onclick="this.setAttribute(\'name\',\'add\'); this.form.submit()"'
           +' value="'+window._dbq['text.add']+'"/>'
         : ''
       )