From 77c28206a14b5bee3f3091f10cffd531bce5649c Mon Sep 17 00:00:00 2001
From: yllar <yllar.pajus@gmail.com>
Date: Sat, 16 Dec 2006 13:25:16 -0500
Subject: [PATCH] updated ja and fr translations

---
 program/steps/addressbook/ldapsearchform.inc |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/program/steps/addressbook/ldapsearchform.inc b/program/steps/addressbook/ldapsearchform.inc
index f7d7cc9..a4e08dc 100644
--- a/program/steps/addressbook/ldapsearchform.inc
+++ b/program/steps/addressbook/ldapsearchform.inc
@@ -26,7 +26,7 @@
 function rcmail_ldap_public_search_form($attrib)
   {
   global $CONFIG, $JS_OBJECT_NAME, $OUTPUT; 
-  if (!$CONFIG['ldap_public'])
+  if (!isset($CONFIG['ldap_public']))
     {
     // no ldap servers to search
     show_message('noldapserver', 'warning');
@@ -78,27 +78,40 @@
       $search_fields = new select(array('name' => $field_name, 
                                         'id'   => $field_id));
 
-      $search_fields->add($server['search_fields'], $server['search_fields']);
+      $search_fields->add(array_keys($server['search_fields']), array_values($server['search_fields']));
       $out .= '<tr><td class="title"><label for="' . $field_id . '">' .
               rep_specialchars_output(rcube_label('ldappublicsearchfield')) . 
               "</label></td><td>" . $search_fields->show() . "</td></tr>\n";
+      
+      $attributes = array('name'  => '_ldap_public_search_type', 
+                          'id'    => 'rcmfd_ldap_public_search_type');
 
-      $search_type = new checkbox(array('name' => '_ldap_public_search_type',
-                                        'id' => 'rcmfd_ldap_public_search_type', 'value' => 0));
+      // if there's only one server, and it doesn't accept fuzzy searches,
+      // then check and disable the check box - thanks pieter
+      if ($server_count == 1 && !$server['fuzzy_search'])
+        {
+        $attributes['CHECKED'] = 'CHECKED'; 
+        $attributes['disabled'] = 'disabled'; 
+        }
+
+      $search_type = new checkbox($attributes);
 
       $out .= '<tr id="ldap_fuzzy_search"><td class="title"><label for="rcmfd_ldap_public_search_type">' .
               rep_specialchars_output(rcube_label('ldappublicsearchtype')) .
               "</label></td><td>" . $search_type->show() . "</td></tr>\n";
       }
+    
+    if ($server_count > 1)
+      {
+      // store the search fields in a js array for each server
+      $js = '';
+      foreach ($server['search_fields'] as $search_name => $search_value)
+        $js .= "['$search_name', '$search_value'], ";
 
-    // store the search fields in a js array for each server
-    $js = '';
-    foreach ($server['search_fields'] as $k => $search_field)
-      $js .= "'$search_field', ";
-
-    // store whether this server accepts fuzzy search as last item in array
-    $js .= $server['fuzzy_search'] ? "'fuzzy'" : "'exact'";
-    $OUTPUT->add_script("rcmail.set_env('{$server_names[$i]}_search_fields', new Array($js));");
+      // store whether this server accepts fuzzy search as last item in array
+      $js .= $server['fuzzy_search'] ? "'fuzzy'" : "'exact'";
+      $OUTPUT->add_script("rcmail.set_env('{$server_names[$i]}_search_fields', new Array($js));");
+      }
     }
 
   // add contact button label text
@@ -242,7 +255,7 @@
     $hiddenfields = new hiddenfield(array('name' => '_task', 'value' => $GLOBALS['_task']));
     $hiddenfields->add(array('name' => '_action', 'value' => 'ldappublicsearch'));
     
-    if ($_GET['_framed'] || $_POST['_framed'])
+    if ($_framed)
       $hiddenfields->add(array('name' => '_framed', 'value' => 1));
     
     $form_start .= !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';

--
Gitblit v1.9.1