]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db/types/ldap.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 7 Feb 2018 18:26:29 +0000 (18:26 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 7 Feb 2018 18:26:29 +0000 (18:26 +0000)
lib/php/db/field.php
lib/php/db/table.php
lib/php/db/types/ldap.php
www/dbq/dbq.php

index e71dfba971d93572c547086ada0450c130de0c89..84805a2fdfd8beedbc279b8052480d0d19166bfb 100644 (file)
@@ -70,12 +70,12 @@ class field extends nb {
 
   public function html_type() {
     # See: http://www.w3schools.com/html/html_form_input_types.asp
-    if (strpos($this->name,'password') !== false) return 'password" autocomplete="off';
+    if (stripos($this->name,'password') !== false) return 'password" autocomplete="off';
     if ($this->numeric() !== false) return 'number" step="any';
     if ($this->autoincrement) return 'text" readonly="readonly';
     return 'text';
     # Html5 only
-    if (strpos($this->name,'email') !== false) return 'email'; # no safari
+    if (stripos($this->name,'mail') !== false) return 'email'; # no safari
     if (strpos($this->name,'color') !== false) return 'color'; # no safari, no ie
     # NOT READY
     if (strpos($this->type,'datetime') !== false) return 'datetime';
@@ -129,6 +129,7 @@ class field extends nb {
        $html .= $this->htmlYesNo($value);
 
        } else {
+                               if ($tag == 'textarea' and $this->html_type() != 'text') $tag = 'input';
        $html .= '<'.$tag
                .' name="'.$this->preffix.$this->name.$suff.'"'
        # NB 06.02.18         .' id="'.$this->name.'"'
index 60645c541999adf355eb46339779872c3862e935..1ae96a42ba363a558791c33ba24ba559573b6870 100644 (file)
@@ -877,6 +877,11 @@ Class Table extends nb {
 # NB 06.02.18          $this->add_fields($fields);
 # NB 06.02.18  }
 
+       public function replace_fields($fields) {
+               $this->fields = [];
+               return $this->add_fields($fields);
+       }
+
        public function add_fields($fields) {
                foreach ($fields as $k => $v) {
                        $key = false;
@@ -1149,7 +1154,14 @@ Class Table extends nb {
                        } else {
                                $fct = function() use($st) { if ($st->execute()) return $st->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT); };
                        }
-       }
+
+               } # < nosql
+
+               # Check fields_only exists
+               if (!empty($this->fields_only)) foreach ($this->fields_only as $f) {
+                       if (!$this->field($f)) $this->bye("Unknown field ".$f);
+               }
+
                if (!empty($opt['query'])) return $st;
                #
                # Use the module out when format unknow
index 81f9d71aa93a922055b6e3d6bfde3d2308481a8d..a56eb28c89ad9b9440474df8e45c1158afdc3d1e 100644 (file)
@@ -22,6 +22,8 @@ $DB_TYPES['ldap'] = [
        #'prepare' => function($sql) { return $this->ldap->prepare($sql); },
        'rows_prepare' => function($table,$sql) {
                $fields = (empty($table->fields_only) ? array_keys($table->fields()) : $table->fields_only);
+               $table->replace_fields($fields);
+               #debug(array_keys($table->fields()));
                #foreach (array_keys($table->fields) as $k) { if (!in_array($k,$fields)) unset($table->fields[$k]); }
                $table->db()->ldap->prepare($sql,['attrs'=>$fields]); return $table->db()->ldap;
        },
index 39d06b712d6d831267b72a1c82a0e3d7451e7117..fdd64913b4ad527609c1f560ee8c395b485e888a 100644 (file)
@@ -237,12 +237,7 @@ class DbQ extends nb {
                $this->deniedUnless($this->perm >= self::READ);
 
                $fields_only = (string)$args === '' ? [] : explode(',',$args);
-               if (!empty($fields_only)) {
-                       foreach ($fields_only as $f) {
-                               if (!$this->table->field($f)) $this->error("Unknown field ".$f);
-                       }
-                       $this->table->fields_only = $fields_only;
-               }
+               if (!empty($fields_only)) $this->table->fields_only = $fields_only;
 
                $this->page($this,'table_rows');
        }