]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 25 Jan 2018 02:51:16 +0000 (02:51 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 25 Jan 2018 02:51:16 +0000 (02:51 +0000)
lib/php/ldap.php
www/dbq/dbq.php

index 632b3f493c59fd1d44fcb9434685f8ad98b70ac3..491284ffd49cdfc38760fb070662498d30ecaa23 100644 (file)
@@ -193,15 +193,15 @@ class Ldap {
 
        public function add($dn,$data) {
                $conn = $this->conn();
-               return ldap_add($conn, $dn, $data); # or self::bye("Unable to add entry to ldap server");
+               return ldap_add($conn, $dn, $data);
        }
 
        public function update($dn,$data) {
-               return ldap_mod_add($this->conn(), $dn, $data); # or self::bye("Unable to add entry to ldap server");
+               return ldap_mod_add($this->conn(), $dn, $data);
        }
 
        public function delete($dn) {
-               return ldap_delete($this->conn(), $dn); # or self::bye("Unable to add entry to ldap server");
+               return ldap_delete($this->conn(), $dn);
        }
 
 }
index c6faf4c855a4a2f1836870613f4eea4d4eda54ab..8dbf539ef2975bfb99768afa1a42266d5a6f361c 100644 (file)
@@ -176,53 +176,55 @@ class DbQ extends nb {
                #debug($GLOBALS['DBQ_LDAP']);
                $ldap = new Ldap($GLOBALS['DBQ_LDAP']);
 
-       if ($this->params['table'] == 'add') {
-               debug($this->params);
-               $rows = (int)$ldap->add($this->params['action'],$_POST);
-               bye($_POST);
-               $this->page($rows);
+               if ($this->params['table'] == 'add') {
+                       #debug($this->params);
+                       $rows = (int)$ldap->add($this->params['action'],$_POST);
+                       #bye($_POST);
+                       $this->page($rows);
 
-       } elseif ($this->params['table'] == 'update') {
-               $rows = (int)$ldap->update($this->params['action'],$_POST);
-               $this->page($rows);
+               } elseif ($this->params['table'] == 'update') {
+                       $rows = (int)$ldap->update($this->params['action'],$_POST);
+                       $this->page($rows);
 
-       } elseif ($this->params['table'] == 'rm') {
-               $rows = (int)$ldap->delete($this->params['action'],$_POST);
-               $this->page($rows);
+               } elseif ($this->params['table'] == 'rm') {
+                       $rows = (int)$ldap->delete($this->params['action'],$_POST);
+                       $this->page($rows);
 
-       }
+               } else {
 
-               $filter = ($this->params['table'] ? $this->params['table'] : '');
-               $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []);
+                       $filter = ($this->params['table'] ? $this->params['table'] : '');
+                       $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []);
 
-               if (!empty($this->params['table']) and !strpos($this->params['table'],'=')) {
-                       $filter = '';
-                       $attrs = explode(',',$this->params['table']);
-               }
+                       if (!empty($this->params['table']) and !strpos($this->params['table'],'=')) {
+                               $filter = '';
+                               $attrs = explode(',',$this->params['table']);
+                       }
 
-               $search = [
-                       'filter' => $filter,
-                       'attrs' => $attrs,
-               ];
+                       $search = [
+                               'filter' => $filter,
+                               'attrs' => $attrs,
+                       ];
 
-               if (!$search['filter']) {
-                       if (preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)) {
-                               $search['filter'] = $m[1];
-                               $search['base'] = $m[2];
-                       } else {
-                               $search['filter'] = 'cn='.Http::user();
+                       if (!$search['filter']) {
+                               if (preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)) {
+                                       $search['filter'] = $m[1];
+                                       $search['base'] = $m[2];
+                               } else {
+                                       $search['filter'] = 'cn='.Http::user();
+                               }
                        }
-               }
-               $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search);
+                       $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search);
+
+                       #echo $rows[0]['jpegPhoto']; exit;
+                       #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ];
+                       if ($this->is_html
+                                       or ($this->params['format'] == $this->format_cli)
+                                       or ($this->params['format'] == 'csv')
+                       ) $rows = $this->array_fill_assoc($rows);
 
-               #echo $rows[0]['jpegPhoto']; exit;
-               #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ];
-               if ($this->is_html
-                               or ($this->params['format'] == $this->format_cli)
-                               or ($this->params['format'] == 'csv')
-               ) $rows = $this->array_fill_assoc($rows);
+                       $this->page($rows);
+               }
 
-               $this->page($rows);
        }
 
        public function page_table_ls($args=null) {