? .cvsignore
? before.sql
? station_playlist_390120_1.patch
? archive/station_494616.patch
? archive/station_archive_views_inc.patch
? archive/station_playlist_260798.patch
? archive/views_working.patch
? schedule/views/.cvsignore
? schedule/views/station_schedule_handler_filter_program_scheduled.inc
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 20:06:11 -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', 'playlists'),
+      '#options' => array(
+        'playlists' => t('Existing playlists'),
+        'albums'    => t('Albums in the catalog'),
+        'both'      => 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' => 'playlists',
+    );
+  }
+
   return system_settings_form($form);
 }
Index: playlist/station_playlist.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/station_playlist.install,v
retrieving revision 1.13
diff -u -p -r1.13 station_playlist.install
--- playlist/station_playlist.install	29 Aug 2009 08:01:42 -0000	1.13
+++ playlist/station_playlist.install	28 Sep 2009 20:06:11 -0000
@@ -241,6 +241,7 @@ function station_playlist_uninstall() {
 
   drupal_uninstall_schema('station_playlist');
 
+  variable_del('station_playlist_track_autocomplete_source');
   variable_del('station_playlist_title_dateformat');
   variable_del('station_playlist_program_dateformat');
 }
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 20:06:11 -0000
@@ -411,17 +411,42 @@ function station_playlist_nodeapi(&$node
 }
 
 /**
- * Retrieve a pipe delimited string of autocomplete suggestions for playlist
- * items.
+ * Retrieve a list of autocomplete suggestions for playlist items.
+ *
+ * @param $field
+ *   The name of the field to match: 'artist', 'album', 'label'
+ * @param $string
+ *   The value to search for.
  */
 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);
-    while ($item = db_fetch_object($result)) {
-      $matches[$item->val] = check_plain($item->val);
+  if (in_array($field, array('artist', 'album', 'label'))) {
+    $sql = NULL;
+    $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', 'playlists')) {
+      case 'playlists':
+        $sql = $playlist_sql;
+        break;
+
+      case 'catalog':
+        $sql = $catalog_sql;
+        break;
+
+      case 'both':
+        $sql = $catalog_sql . ' UNION ' . $playlist_sql;
+        $args = array_merge($args, $args);
+        break;
+    }
+    if ($sql) {
+      $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();
 }
