private function fields_add_missing(&$fields,$row) {
+ $new = []; # we reconstruct the array to keep order
foreach (array_keys($row) as $name) {
- if (isset($fields[$name])) continue;
- #if (isset($fields[$name])) debug($fields[$name]->name);
- #if (!isset($fields[$name])) debug($name);
- #if (!isset($fields[$name])) debug($fields[$name]->type);
- $fields[$name] = new Field([
+ if (isset($fields[$name])) {
+ $new[$name] = $fields[$name];
+ continue;
+ }
+ $new[$name] = new Field([
'name' => $name,
'dyn' => true,
'table' => $this,
}
+ $fields = $new;
return $fields;
}
$html .= '<thead>'.NB_EOL;
// Columns names
-# NB 12.09.18 $html .= '<tr class="head">'.NB_EOL;
$html .= '<tr>'.NB_EOL;
if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
foreach ($fields as $name => $f) {
}
- # NB 08.10.24 public function ldap($table='',$attrs=[]) {
- # NB 08.10.24 $this->deniedUnless($this->perm >= self::ADMIN);
-# NB 08.10.24
- # NB 08.10.24 require_once(NB_ROOT.'/lib/php/ldap.php');
- # NB 08.10.24 #debug($GLOBALS['DBQ_LDAP']);
- # NB 08.10.24 $dn = join(',',$attrs);
- # NB 08.10.24 $ldap = new Ldap($GLOBALS['DBQ_LDAP']);
-# NB 08.10.24
- # NB 08.10.24 if ($table == 'add') {
- # NB 08.10.24 $this->deniedUnless($this->perm >= self::WRITE);
- # NB 08.10.24 $rows = (int)$ldap->add($dn,$_POST);
-# NB 08.10.24
- # NB 08.10.24 } elseif ($table == 'update') {
- # NB 08.10.24 $this->deniedUnless($this->perm >= self::WRITE);
- # NB 08.10.24 $rows = (int)$ldap->update($dn,$_POST);
-# NB 08.10.24
- # NB 08.10.24 } elseif ($table == 'rm') {
- # NB 08.10.24 $this->deniedUnless($this->perm >= self::DELETE);
- # NB 08.10.24 $rows = (int)$ldap->delete($dn,$_POST);
-# NB 08.10.24
- # NB 08.10.24 } else { // ls
- # NB 08.10.24 $this->deniedUnless($this->perm >= self::READ);
-# NB 08.10.24
- # NB 08.10.24 $filter = ($table ? $table : '');
-# NB 08.10.24
- # NB 08.10.24 if (!empty($table) and !strpos($table,'=')) {
- # NB 08.10.24 $filter = '';
- # NB 08.10.24 $attrs = explode(',',$table);
- # NB 08.10.24 }
-# NB 08.10.24
- # NB 08.10.24 $search = [
- # NB 08.10.24 'filter' => $filter,
- # NB 08.10.24 'attrs' => $attrs,
- # NB 08.10.24 ];
-# NB 08.10.24
- # NB 08.10.24 if (!$search['filter']) {
- # NB 08.10.24 if (1
- # NB 08.10.24 and !empty($GLOBALS['DBQ_LDAP']['user'])
- # NB 08.10.24 and preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)
- # NB 08.10.24 ) {
- # NB 08.10.24 $search['filter'] = $m[1];
- # NB 08.10.24 $search['base'] = $m[2];
- # NB 08.10.24 } else {
- # NB 08.10.24 $search['filter'] = 'cn='.Http::user();
- # NB 08.10.24 }
- # NB 08.10.24 $search['filter'] = '(&('.$search['filter'].')(userPassword=*))';
- # NB 08.10.24 }
- # NB 08.10.24 $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search);
-# NB 08.10.24
- # NB 08.10.24 if ($this->is_html
- # NB 08.10.24 or ($this->params['format'] == $this->format_cli)
- # NB 08.10.24 or ($this->params['format'] == 'csv')
- # NB 08.10.24 ) $rows = $this->array_fill_assoc($rows);
-# NB 08.10.24
- # NB 08.10.24 }
-# NB 08.10.24
- # NB 08.10.24 return $rows;
- # NB 08.10.24 }
-
public function page_table_ls($fields=null) {
$this->deniedUnless($this->perm >= self::READ);
$hidden = $this->form_hidden($r);
- $r = $this->ar_unshift($r,'view',''
+ $r = $this->ar_unshift($r,'Edit',''
+ # NB 28.05.26 $this->ar_unshift($r,'view',''
.'<form action="'.$this->table->base.'/vi'.'" method="post" class="vi">'
.'<a class="button select vi btn btn-sm btn-secondary" href="'.$this->table->base.'/vi'.'" onclick="parentNode.submit();return false;">Edit</a>'
.$hidden
# NB 03.02.18 if ($this->db->type == 'sqlite' and !is_writeable($this->db->host)) return;
$rm = $this->uri_add_referer($this->table->base.'/rm');
- $r['delete'] = ''
+ $r['Delete'] = ''
.'<form action="'.$rm.'" method="post" class="rm">'
.'<a class="button rm btn btn-sm btn-danger" href="'.$rm.'" onclick="parentNode.submit();return false;">Delete</a>'
.$hidden
}
private function ar_unshift( array & $array, $key, $val) {
+ $new = [];
+ $new[$key] = $val;
+ foreach ($array as $k=>$v) {
+ $new[$k] = $v;
+ }
+ return $new;
# NB 05.01.18: Escape html ??????? we use reverse
# NB 05.01.18 return $array + [ $key => $val ];
$array = array_reverse($array, 1);