Support data coming from non-canonical fields and ignoring fields when fetching data
authorJoey Schulze <joey@infodrom.org>
Thu, 4 Mar 2010 19:07:54 +0000 (20:07 +0100)
committerJoey Schulze <joey@infodrom.org>
Thu, 4 Mar 2010 19:07:54 +0000 (20:07 +0100)
ajax/ajax.php

index 5f2e3c9..74d75e1 100644 (file)
@@ -5,11 +5,15 @@ require_once('../init.php');
 function fetch($mask)
 {
   $fields = array("to_char(sys_edit,'DD.MM.YYYY HH24:mm') AS sys_edit", 'sys_user');
-  foreach ($mask['edit'] as $field => $info)
+  foreach ($mask['edit'] as $field => $info) {
+    if ($info['sql'] === false) continue;
     if ($info['type'] == 'date')
-      $fields[] = sprintf("to_char(%s,'DD.MM.YYYY') AS %s", $field, $field);
+      $fields[] = sprintf("to_char(%s,'DD.MM.YYYY') AS %s",
+                         empty($info['sql']) ? $field : $info['sql'],
+                         $field);
     elseif ($info['type'] != 'passwd')
-      $fields[] = $field;
+      $fields[] = empty($info['sql']) ? $field : $info['sql'] . ' AS ' . $field;
+  }
 
   $sql = sprintf('SELECT id,%s FROM %s WHERE id = %d',
                 implode(',', $fields),