Index: playlist/station_playlist.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/station_playlist.admin.inc,v
retrieving revision 1.2
diff -u -p -r1.2 station_playlist.admin.inc
--- playlist/station_playlist.admin.inc	4 Jun 2009 16:05:04 -0000	1.2
+++ playlist/station_playlist.admin.inc	28 Sep 2009 16:05:53 -0000
@@ -21,5 +21,30 @@ function station_playlist_admin_settings
     '#default_value' => variable_get('station_playlist_program_dateformat', 'F j, Y'),
     '#description' => t("The playlist's date is also displayed on the the program node. This setting lets you control how it is formatted."),
   );
+  $form['tracks'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Tracks'),
+    '#tree' => FALSE,
+  );
+  if (module_exists('station_catalog')) {
+    $form['tracks']['station_playlist_track_autocomplete_source'] = array(
+      '#type' => 'radios',
+      '#title' => t('Auto-complete source'),
+      '#default_value' => variable_get('station_playlist_track_autocomplete_source', 0),
+      '#options' => array(
+        0 => t('Existing playlists'),
+        1 => t('Albums in the catalog'),
+        2 => t('Both'),
+      ),
+      '#description' => t("When adding playlists the track listings use auto-completing to save typing and provide suggestions. What data source should be used to provide these suggestions?"),
+    );
+  }
+  else {
+    $form['tracks']['station_playlist_track_autocomplete_source'] = array(
+      '#type' => 'value',
+      '#value' => 0,
+    );
+  }
+
   return system_settings_form($form);
 }
Index: playlist/station_playlist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/station_playlist.module,v
retrieving revision 1.23
diff -u -p -r1.23 station_playlist.module
--- playlist/station_playlist.module	27 Sep 2009 06:12:25 -0000	1.23
+++ playlist/station_playlist.module	28 Sep 2009 16:05:53 -0000
@@ -416,12 +416,31 @@ function station_playlist_nodeapi(&$node
  */
 function station_playlist_autocomplete($field = '', $string = '') {
   $matches = array();
-  if (in_array($field, array('artist', 'title', 'album', 'label'))) {
-    $result = db_query_range('SELECT DISTINCT %s AS val FROM {station_playlist_track} WHERE LOWER(%s) LIKE LOWER("%s%%") ORDER BY val', $field, $field, $string, 0, 10);
+  if (in_array($field, array('artist', 'album', 'label'))) {
+    $catalog_sql  = 'SELECT DISTINCT %s AS val FROM {station_catalog}        WHERE LOWER(%s) LIKE LOWER("%s%%")';
+    $playlist_sql = 'SELECT DISTINCT %s AS val FROM {station_playlist_track} WHERE LOWER(%s) LIKE LOWER("%s%%")';
+    $args = array($field, $field, $string);
+    switch (variable_get('station_playlist_track_autocomplete_source', 0)) {
+      // Catalog
+      case 0:
+        $sql = $playlist_sql;
+        break;
+      // Playlists
+      case 1:
+        $sql = $catalog_sql;
+        break;
+      // Both
+      case 2:
+        $sql = $catalog_sql . ' UNION ' . $playlist_sql;
+        $args = array_merge($args, $args);
+        break;
+    }
+    $result = db_query_range($sql . ' ORDER BY val', $args, 0, 10);
     while ($item = db_fetch_object($result)) {
       $matches[$item->val] = check_plain($item->val);
     }
   }
+
   print drupal_to_js($matches);
   exit();
 }
