summaryrefslogtreecommitdiff
path: root/modules/user/user.module
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2005-05-24 06:00:22 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2005-05-24 06:00:22 +0000
commit58bddf8abc2cb4c51b49a1ad1dc6c7eca411eb22 (patch)
tree21911a0ec62eca709567daf3ddaf9f467409ddf7 /modules/user/user.module
parent0de88f50baa5eed0eb90448d7964aa04c4fbc1de (diff)
downloadbrdo-58bddf8abc2cb4c51b49a1ad1dc6c7eca411eb22.tar.gz
brdo-58bddf8abc2cb4c51b49a1ad1dc6c7eca411eb22.tar.bz2
* cue Star Wars theme tune *
Return of the JavaScript! - #22519: form_autocomplete(): Ajax based autocompletion. Currently used for user names and folksonomy tags.
Diffstat (limited to 'modules/user/user.module')
-rw-r--r--modules/user/user.module16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 9e148d3bc..6bf23f3d6 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -641,6 +641,9 @@ function user_menu($may_cache) {
$items[] = array('path' => 'user', 'title' => t('user account'),
'callback' => 'user_page', 'access' => TRUE, 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'user/autocomplete', 'title' => t('user autocomplete'),
+ 'callback' => 'user_autocomplete', 'access' => $admin_access, 'type' => MENU_CALLBACK);
+
//registration and login pages.
$items[] = array('path' => 'user/login', 'title' => t('log in'),
'type' => MENU_DEFAULT_LOCAL_TASK);
@@ -1854,4 +1857,17 @@ function _user_forms(&$edit, $account, $category, $hook = 'form') {
return $output;
}
+/**
+ * Retrieve a pipe delimited string of autocomplete suggestions for existing users
+ */
+function user_autocomplete($string) {
+ $matches = array();
+ $result = db_query_range('SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER("%%%s%%")', $string, 0, 10);
+ while ($user = db_fetch_object($result)) {
+ $matches[$user->name] = check_plain($user->name);
+ }
+ print drupal_implode_autocomplete($matches);
+ exit();
+}
+
?>