summaryrefslogtreecommitdiff
path: root/modules/profile/profile.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/profile/profile.module')
-rw-r--r--modules/profile/profile.module19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 38d49ffad..720385e69 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -66,6 +66,11 @@ function profile_menu($may_cache) {
'title' => t('add field'),
'callback' => 'profile_field_form',
'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/settings/profile/autocomplete',
+ 'title' => t('profile category autocomplete'),
+ 'callback' => 'profile_admin_settings_autocomplete',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/settings/profile/edit',
'title' => t('edit field'),
'callback' => 'profile_field_form',
@@ -212,6 +217,7 @@ function profile_field_form($arg = NULL) {
$form['fields']['category'] = array('#type' => 'textfield',
'#title' => t('Category'),
'#default_value' => $edit['category'],
+ '#autocomplete_path' => 'admin/settings/profile/autocomplete',
'#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
'#required' => TRUE,
);
@@ -786,3 +792,16 @@ function _profile_field_types($type = NULL) {
function _profile_field_serialize($type = NULL) {
return $type == 'date';
}
+
+/**
+ * Retrieve a pipe delimited string of autocomplete suggestions for profile categories
+ */
+function profile_admin_settings_autocomplete($string) {
+ $matches = array();
+ $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%s%%')", $string, 0, 10);
+ while ($data = db_fetch_object($result)) {
+ $matches[$data->category] = check_plain($data->category);
+ }
+ print drupal_to_js($matches);
+ exit();
+}