--- site_user_list.module	2007-06-22 16:57:42.000000000 +0000
+++ site_user_list_search.module	2008-04-17 12:59:34.000000000 +0000
@@ -252,6 +252,11 @@ function site_user_list_admin_settings_f
     '#title' => t('Show the search form'),
     '#default_value' => variable_get('site_user_list_s_show', 1),
   );
+  $form['display_elements_fs']['search_form']['site_user_list_s_collapsed'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Collapse the search form'),
+    '#default_value' => variable_get('site_user_list_s_collapsed', 1),
+  );
   $form['display_elements_fs']['search_form']['site_user_list_s_weight'] = array(
     '#type' => 'weight',
     '#title' => t('Weight of the search form'),
@@ -356,6 +361,7 @@ function site_user_list_admin_settings_f
   variable_set('site_user_list_d_weight', $data['site_user_list_d_weight']);
 
   variable_set('site_user_list_s_show', $data['site_user_list_s_show']);
+  variable_set('site_user_list_s_collapsed', $data['site_user_list_s_collapsed']);
   variable_set('site_user_list_s_weight', $data['site_user_list_s_weight']);
   variable_set('site_user_list_s_before', $data['site_user_list_s_before']);
   variable_set('site_user_list_s_after', $data['site_user_list_s_after']);
@@ -995,17 +1001,10 @@ function site_user_list_form() {
       '#title' => t('Search Options'),
       '#weight' => variable_get('site_user_list_s_weight', -1),
       '#collapsible' => true,
-      '#collapsed' => true,
+      '#collapsed' => (variable_get('site_user_list_s_collapsed', 1) ? true:false),
       '#tree' => true,
       '#attributes' => array('id' => 'site-user-list-search-options'),
     );
-    $form['s']['_initial_text'] = array(
-      '#type' => 'markup',
-      '#value' => t('Display users where:'),
-      '#weight' => -1000,
-      '#prefix' => '<p>',
-      '#suffix' => '</p>',
-    );
     
     // get the additional search forms using the hook we've defined
     // the hook should return an array like:
@@ -1021,6 +1020,7 @@ function site_user_list_form() {
       }
     }
 
+    site_user_list_add_quicksearch($form, $_REQUEST['s']);
     $form['s'][] = array(
       '#type' => 'submit',
       '#value' => t('Find Users'),
@@ -1076,6 +1076,15 @@ function site_user_list_form() {
   return $form;
 }
 
+function site_user_list_add_quicksearch(&$form, $search = array()){
+  $default_what = $search['general']['what'];
+  
+  $form['s']['general']['what'] = array(
+    '#type' => 'textfield',
+    '#prefix' => '<p>' . t('Search all user information:') . '</p>',
+    '#default_value' => $default_what
+  );
+}
 /**
  * the rebuild page
  * shouldn't really be used much
@@ -1346,60 +1355,68 @@ function profile_site_user_list_search_f
   }
   
   $default_which = $search['profile']['which'];
-  $default_what = $search['profile']['what'];
-  if (!isset($default_what)) { $default_what = ''; }
+  $collapsed = count($default_which)? false:true;
   
   $ret['profile'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Contact Information'),
+    '#title' => t('Advanced Contact Information'),
     '#collapsible' => true,
-    '#collapsed' => ((isset($default_what) and ($default_what != '')) ? false
-                                                                      : true),
+    '#collapsed' => $collapsed,
     '#attributes' => array('class' => 'site-user-list-checkboxes-form'),
     '#tree' => true,
     '#weight' => -100,
   );
+  
   $ret['profile']['which'] = array(
     '#type' => 'checkboxes',
     '#options' => $fields,
     '#prefix' => '<p>' . t('Any of:') . '</p>',
     '#default_value' => $default_which,
   );
-  $ret['profile']['what'] = array(
-    '#type' => 'textfield',
-    '#prefix' => '<p>' . t('Contains:') . '</p>',
-    '#default_value' => $default_what,
-  );
   
   return $ret;
 }
 
 // provide restrictions
 function profile_site_user_list_restrict($search = array()) {
-  if ($search['profile']) {
-    $which = $search['profile']['which'];
-    $what = $search['profile']['what'];
-    
-    if (count($which) and ($what != '')) {
-      $or_clauses = array();
-      $column_headings = array();
-      foreach ($which as $col) {
-        $res = db_fetch_array(db_query("SELECT search_column, column_header FROM {site_user_list_fields} WHERE field_identifier = '%s'", $col));
+  $which = $search['profile']['which'];
+  $what = $search['general']['what'];
+  
+  if($what !== '' && !count($which)){
+    $profile_fields = array(
+      '@uid',
+      '@name',
+      '@mail',
+    );
+    $profile_fields_query = db_query("SELECT name FROM {profile_fields} ORDER BY category, weight, fid");
+    while($r = db_fetch_array($profile_fields_query)) {
+      $profile_fields[] = '@' . $r['name'];
+    }
+    
+    $which = $profile_fields;
+  }
+  
+  if (count($which) and ($what != '')) {
+    
+    $or_clauses = array();
+    $column_headings = array();
+    foreach ($which as $col) {
+      $res = db_fetch_array(db_query("SELECT search_column, column_header FROM {site_user_list_fields} WHERE field_identifier = '%s'", $col));
+      if($res !== FALSE){
         $or_clauses[] = "(cd." . site_user_list_escape_column($res['search_column']) . " like '%%" . db_escape_string($what) . "%%')";
-        $column_headings[] = '"' . $res['column_header'] . '"';
+        $column_headings[] = '"' . $res['column_header'] . '"';  
       }
-      
-      if (count($or_clauses)) {
-        $or_clause = implode(" or ", $or_clauses);
-        if (count($or_clauses) > 1) {
-          $or_clause = '(' . $or_clause . ')';
-        }
-        
-        $description = "Any of the fields " . implode(" or ", $column_headings) . " contains the text \"" . $what . "\"";
-        
-        
-        return array('profile' => array('where' => array($or_clause), 'description' => array($description)));
+    }
+    
+    if (count($or_clauses)) {
+      $or_clause = implode(" or ", $or_clauses);
+      if (count($or_clauses) > 1) {
+        $or_clause = '(' . $or_clause . ')';
       }
+      
+      $description = "Any of the fields " . implode(" or ", $column_headings) . " contains the text \"" . $what . "\"";
+      
+      return array('profile' => array('where' => array($or_clause), 'description' => array($description)));
     }
   }
 }
