From 0501b637a3177cce441166b5fcfe27c9bd9fbe0f Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Tue, 18 Jan 2011 13:00:57 -0500
Subject: [PATCH] Merge branch devel-addressbook (r4193:4382) back into trunk

---
 program/include/main.inc |   43 +++++++++++++++++++++++++++----------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 1ddb5f9..0815c25 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -799,7 +799,7 @@
 
       // format each col
       foreach ($a_show_cols as $col)
-        $table->add($col, Q($row_data[$col]));
+        $table->add($col, Q(is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col]));
         
       $c++;
     }
@@ -819,32 +819,43 @@
  * @return string HTML field definition
  */
 function rcmail_get_edit_field($col, $value, $attrib, $type='text')
-  {
-  $fname = '_'.$col;
-  $attrib['name'] = $fname;
+{
+  static $colcounts = array();
   
-  if ($type=='checkbox')
-    {
+  $fname = '_'.$col;
+  $attrib['name'] = $fname . ($attrib['array'] ? '[]' : '');
+  $attrib['class'] = trim($attrib['class'] . ' ff_' . $col);
+  
+  if ($type == 'checkbox') {
     $attrib['value'] = '1';
     $input = new html_checkbox($attrib);
-    }
-  else if ($type=='textarea')
-    {
+  }
+  else if ($type == 'textarea') {
     $attrib['cols'] = $attrib['size'];
     $input = new html_textarea($attrib);
-    }
-  else
+  }
+  else if ($type == 'select') {
+    $input = new html_select($attrib);
+    $input->add('---', '');
+    $input->add(array_values($attrib['options']), array_keys($attrib['options']));
+  }
+  else {
+    if ($attrib['type'] != 'text' && $attrib['type'] != 'hidden')
+        $attrib['type'] = 'text';
     $input = new html_inputfield($attrib);
+  }
 
   // use value from post
-  if (!empty($_POST[$fname]))
-    $value = get_input_value($fname, RCUBE_INPUT_POST,
-	    $type == 'textarea' && strpos($attrib['class'], 'mce_editor')!==false ? true : false);
+  if (isset($_POST[$fname])) {
+    $postvalue = get_input_value($fname, RCUBE_INPUT_POST,
+      $type == 'textarea' && strpos($attrib['class'], 'mce_editor')!==false ? true : false);
+    $value = $attrib['array'] ? $postvalue[intval($colcounts[$col]++)] : $postvalue;
+  }
 
   $out = $input->show($value);
-         
+
   return $out;
-  }
+}
 
 
 /**

--
Gitblit v1.9.1