Index: modules/privatemsg/privatemsg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.61
diff -u -r1.61 privatemsg.module
--- modules/privatemsg/privatemsg.module	11 Aug 2006 22:51:40 -0000	1.61
+++ modules/privatemsg/privatemsg.module	2 Oct 2006 08:39:56 -0000
@@ -56,6 +56,11 @@
                      'callback' => 'privatemsg_page',
                      'access' => user_access('access private messages'),
                      'type' => $user->uid && (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1) ? MENU_DYNAMIC_ITEM : MENU_CALLBACK);
+    $items[] = array('path' => 'privatemsg/autocomplete',
+	                 'title' => t('privatemsg autocomplete'),
+                     'callback' => 'privatemsg_autocomplete',
+	                 'access' => user_access('access private messages'),
+	                 'type' => MENU_CALLBACK); 
   }
   return $items;
 }
@@ -196,6 +201,19 @@
   }
 }
 
+function privatemsg_autocomplete() {
+  $matches = array();
+  $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%%')", 0, 10);
+  while ($user = db_fetch_object($result)) {
+    $author = user_load(array('name' => $user->name));
+	if(isset($author->privatemsg_allow) ? $author->privatemsg_allow : 1) {
+      $matches[$user->name] = check_plain($user->name);
+	}
+  }
+  print drupal_to_js($matches);
+  exit();
+}
+
 function _privatemsg_mailalert() {
   global $locale;
   $initial_locale = $locale;
@@ -436,6 +454,7 @@
       '#type' => 'textfield',
       '#title' => t("To"),
       '#default_value' => $message->recipient,
+	  '#autocomplete_path' => 'privatemsg/autocomplete',
       '#size' => 50,
       '#maxlength' => 64
       );
