Index: audio_feeds.feeds.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/feeds/audio_feeds.feeds.inc,v
retrieving revision 1.1
diff -u -F^function -r1.1 audio_feeds.feeds.inc
--- audio_feeds.feeds.inc	25 Sep 2008 23:18:08 -0000	1.1
+++ audio_feeds.feeds.inc	4 Jun 2009 16:58:56 -0000
@@ -1,11 +1,11 @@
 <?php
 // $Id: audio_feeds.feeds.inc,v 1.1 2008/09/25 23:18:08 drewish Exp $
+
 /**
  * @file
  * This file provides various XML feeds for audio media.
  */
 
-
 /**
  * Menu Callback to generate M3U feed
  */
@@ -16,30 +16,27 @@ function audio_feeds_m3u($node) {
   $metadata = array('title' => $node->title);
 
   // prepare feed items
-  $children = $node->audio_attach;
-  foreach ($children as $child) {
-    $audio = node_load($child);
-    if (node_access('view', $audio)) {
-      $items[] = array(
-        'title' => $audio->audio_tags['title'],
-        'author' => $audio->audio_tags['artist'],
-        'duration' => $audio->audio_file['playtime'],
-        'enclosure' => array('url' => $audio->url_play),
-      );
-    }
+  $children = audio_feeds_children($node);
+  foreach ($children as $audio) {
+    $items[] = array(
+      'title' => $audio->audio_tags['title'],
+      'author' => $audio->audio_tags['artist'],
+      'duration' => $audio->audio_file['playtime'],
+      'enclosure' => array('url' => $audio->url_play),
+    );
   }
   audio_feeds_generate_m3u($items, $metadata);
 }
 
 /**
-  * Return XML for M3U feed
-  */
+ * Return XML for M3U feed
+ */
 function audio_feeds_generate_m3u($items = array(), $metadata = array()) {
   $output = "#EXTM3U\r\n";
   foreach ($items as $item) {
-      $title = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
-      $output .= "#EXTINF:". check_plain($item['duration']) .",". check_plain($title) ."\r\n";
-      $output .= check_plain($item['enclosure']['url']) ."\r\n";
+    $title = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
+    $output .= "#EXTINF:". check_plain($item['duration']) .",". check_plain($title) ."\r\n";
+    $output .= check_plain($item['enclosure']['url']) ."\r\n";
   }
   drupal_set_header("Pragma: no-cache"); // HTTP/1.0
   drupal_set_header("Cache-Control: private"); // HTTP/1.1
@@ -60,33 +57,30 @@ function audio_feeds_pls($node) {
   $metadata = array('title' => $node->title);
 
   // prepare feed items
-  $children = $node->audio_attach;
-  foreach ($children as $child) {
-    $audio = node_load($child);
-    if (node_access('view', $audio)) {
-      $items[] = array(
-        'title' => $audio->audio_tags['title'],
-        'author' => $audio->audio_tags['artist'],
-        'duration' => $audio->audio_file['playtime'],
-        'enclosure' => array('url' => $audio->url_play),
-      );
-    }
+  $children = audio_feeds_children($node);
+  foreach ($children as $audio) {
+    $items[] = array(
+      'title' => $audio->audio_tags['title'],
+      'author' => $audio->audio_tags['artist'],
+      'duration' => $audio->audio_file['playtime'],
+      'enclosure' => array('url' => $audio->url_play),
+    );
   }
   audio_feeds_generate_pls($items, $metadata);
 }
 
 /**
-  * Return XML for PLS feed
-  */
+ * Return XML for PLS feed
+ */
 function audio_feeds_generate_pls($items = array(), $metadata = array()) {
   $output = "[playlist]\r\n";
   $i = 1;
   foreach ($items as $item) {
-      $title = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
-      $output .= "File$i=". check_plain($item['enclosure']['url']) ."\r\n";
-      $output .= "Title$i=". check_plain($title) ."\r\n";
-      $output .= "Length$i=". check_plain($item['duration']) ."\r\n";
-      $i++;
+    $title = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
+    $output .= "File$i=". check_plain($item['enclosure']['url']) ."\r\n";
+    $output .= "Title$i=". check_plain($title) ."\r\n";
+    $output .= "Length$i=". check_plain($item['duration']) ."\r\n";
+    $i++;
   }
   $output .= "NumberOfEntries=". count($items) ."\r\n";
   $output .= "Version=2\r\n";
@@ -104,7 +98,7 @@ function audio_feeds_generate_pls($items
  */
 function audio_feeds_xspf($node) {
   global $base_url;
-  $children = $node->audio_attach;
+  $children = audio_feeds_children($node);
 
   // prepare feed metadata
   $metadata = array(
@@ -117,28 +111,25 @@ function audio_feeds_xspf($node) {
 
   // prepare feed items
   $items = array();
-  foreach ($children as $child) {
-    $audio = node_load($child);
-    if (node_access('view', $audio)) {
-      // use the first image uploaded as the included image
-      $image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
-      $items[] = array(
-        'title' => $audio->audio_tags['title'],
-        'author' => $audio->audio_tags['artist'],
-        'album' => $audio->audio_tags['album'],
-        'duration' => $audio->audio_file['playtime'],
-        'link' => url('node/'. $audio->nid, array('absolute' => TRUE)),
-        'image' => array('url' => $base_url .'/'. $image['filepath']),
-        'enclosure' => array('url' => $audio->url_play),
-      );
-    }
+  foreach ($children as $audio) {
+    // use the first image uploaded as the included image
+    $image = is_array($audio->audio_images) ? current($audio->audio_images) : '';
+    $items[] = array(
+      'title' => $audio->audio_tags['title'],
+      'author' => $audio->audio_tags['artist'],
+      'album' => $audio->audio_tags['album'],
+      'duration' => $audio->audio_file['playtime'],
+      'link' => url('node/'. $audio->nid, array('absolute' => TRUE)),
+      'image' => array('url' => $base_url .'/'. $image['filepath']),
+      'enclosure' => array('url' => $audio->url_play),
+    );
   }
   audio_feeds_generate_xspf($items, $metadata);
 }
 
 /**
-  * Return XML for XSPF feed
-  */
+ * Return XML for XSPF feed
+ */
 function audio_feeds_generate_xspf($items = array(), $metadata = array()) {
   $output = '<?xml version="1.0" encoding="UTF-8"?>';
   $output .= '<playlist version="1" xmlns="http://xspf.org/ns/0/">';
@@ -150,17 +141,17 @@ function audio_feeds_generate_xspf($item
   $output .= "<license>". check_plain($metadata['copyright']) ."</license>";
   $output .= '<trackList>';
   foreach ($items as $item) {
-      $output .= '<track>';
-      $output .= "<location>". check_plain($item['enclosure']['url']) ."</location>";
-      $output .= "<creator>". check_plain($item['author']) ."</creator>";
-      $output .= "<album>". check_plain($item['album']) ."</album>";
-      $output .= "<title>". check_plain($item['title']) ."</title>";
-      $annotation = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
-      $output .= "<annotation>". check_plain($annotation) ."</annotation>";
-      $output .= "<duration>". check_plain($item['duration']) ."</duration>";
-      $output .= "<image>". check_plain($item['image']['url']) ."</image>";
-      $output .= "<info>". check_plain($item['link']) ."</info>";
-      $output .= '</track>';
+    $output .= '<track>';
+    $output .= "<location>". check_plain($item['enclosure']['url']) ."</location>";
+    $output .= "<creator>". check_plain($item['author']) ."</creator>";
+    $output .= "<album>". check_plain($item['album']) ."</album>";
+    $output .= "<title>". check_plain($item['title']) ."</title>";
+    $annotation = $item['author'] ? $item['author'] ." - ". $item['title'] : $item['title'];
+    $output .= "<annotation>". check_plain($annotation) ."</annotation>";
+    $output .= "<duration>". check_plain($item['duration']) ."</duration>";
+    $output .= "<image>". check_plain($item['image']['url']) ."</image>";
+    $output .= "<info>". check_plain($item['link']) ."</info>";
+    $output .= '</track>';
   }
   $output .= '  </trackList>';
   $output .= '</playlist>';
@@ -173,3 +164,32 @@ function audio_feeds_generate_xspf($item
   print $output;
   exit();
 }
+
+/**
+ * Get the attached audio nodes.
+ *
+ * @param object $node
+ *   The node whose audio nodes are to be retrieved.
+ * @return
+ *   An array containing all the audio nodes attached to a given node.
+ */
+function audio_feeds_children($node) {
+  $children = array();
+  
+  // Find all nodereferences.
+  $fields = content_fields(NULL, $node->type);
+  foreach ($fields as $field_name => $field) {
+    // Audio attach relies on nodereference fields.
+    if ($field['type'] == 'nodereference' && is_array($node->{$field_name})) {
+      foreach ($node->{$field_name} as $item) {
+        // Keep only those references that are actually accessible and
+        // downloadable audio nodes.
+        if (($child = node_load($item['nid'])) && node_access('view', $child) && _audio_allow_download($child)) {
+          $children[] = $child;
+        }
+      }
+    }
+  }
+  
+  return $children;
+}
\ No newline at end of file
Index: audio_feeds.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/feeds/audio_feeds.info,v
retrieving revision 1.4
diff -u -F^function -r1.4 audio_feeds.info
--- audio_feeds.info	2 Oct 2008 07:12:34 -0000	1.4
+++ audio_feeds.info	4 Jun 2009 16:58:56 -0000
@@ -1,6 +1,6 @@
 ; $Id: audio_feeds.info,v 1.4 2008/10/02 07:12:34 drewish Exp $
 name = Audio Feeds
-description = Provide XSPF, PLS, and M3U audio XML feeds.
+description = Provide XSPF, M3U, and PLS feeds for attached audio nodes.
 package = "Audio"
-;WAITING ON UPDATE: core = 6.x
+core = 6.x
 dependencies[] = audio
Index: audio_feeds.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/audio/contrib/feeds/audio_feeds.module,v
retrieving revision 1.6
diff -u -F^function -r1.6 audio_feeds.module
--- audio_feeds.module	25 Sep 2008 23:18:08 -0000	1.6
+++ audio_feeds.module	4 Jun 2009 16:58:56 -0000
@@ -1,8 +1,9 @@
 <?php
 // $Id: audio_feeds.module,v 1.6 2008/09/25 23:18:08 drewish Exp $
+
 /**
  * @file
- * This module provides XSPF, M3U, and PLS feeds for a list of audio files.
+ * This module provides XSPF, M3U, and PLS feeds for attached audio nodes.
  */
 
 /**
@@ -30,7 +31,7 @@ function audio_feeds_form_alter(&$form, 
           '#title' => t('Audio Feeds'),
           '#default_value' => variable_get('audio_feeds_attach_'. $type, 0),
           '#options' => array(t('Disabled'), t('Enabled')),
-          '#description' => t('Should users be allowed to create XSPF, M3U, and PLS feeds of attached audio files?'),
+          '#description' => t('Provide XSPF, M3U, and PLS feeds for attached audio nodes.'),
         );
       }
       break;
@@ -45,34 +46,32 @@ function audio_feeds_link($type, $node =
   global $user;
   $links = array();
 
-  if (variable_get('audio_feeds_attach_'. $node->type, 0) && count($node->audio_attach) > 0) {
-    // Add audio playlist feed links
+  if (variable_get('audio_feeds_attach_'. $node->type, 0)) {
+    // Add audio playlist feed links.
     $feed_links = variable_get('audio_feeds_feed_links', array('m3u', 'pls', 'xspf', 'popup'));
     foreach ($feed_links as $key => $type) {
       switch ((string)$type) {
         case 'm3u':
           $links['audio_feeds_m3u_link'] = array(
-             'title' => t('M3U'),
-             'href' => "node/$node->nid/m3u",
-             'attributes' => array('title' => t('Stream M3U feed')),
+            'title' => t('M3U'),
+            'href' => "node/$node->nid/m3u",
+            'attributes' => array('title' => t('Stream M3U feed')),
           );
           break;
         case 'pls':
           $links['audio_feeds_pls_link'] = array(
-             'title' => t('PLS'),
-             'href' => "node/$node->nid/pls",
-             'attributes' => array('title' => t('Stream PLS feed')),
+            'title' => t('PLS'),
+            'href' => "node/$node->nid/pls",
+            'attributes' => array('title' => t('Stream PLS feed')),
           );
           break;
         case 'xspf':
           $links['audio_feeds_xspf_link'] = array(
-             'title' => t('XSPF'),
-             'href' => "node/$node->nid/xspf",
-             'attributes' => array('title' => t('Shareable XSPF feed')),
+            'title' => t('XSPF'),
+            'href' => "node/$node->nid/xspf",
+            'attributes' => array('title' => t('Shareable XSPF feed')),
           );
           break;
-        default:
-          break;
       }
     }
   }
@@ -84,14 +83,14 @@ function audio_feeds_link($type, $node =
  * Implementation of hook_menu().
  */
 function audio_feeds_menu() {
-  // FIXME: This snippet isn't preserved by this new menu code:
-  // if (variable_get('audio_feeds_attach_'. $node->type, 0)) {
   $items = array();
 
   $items['node/%node/xspf'] = array(
     'title' => 'XSPF',
     'page callback' => 'audio_feeds_xspf',
     'page arguments' => array(1),
+    'access callback' => 'audio_feeds_access',
+    'access arguments' => array(1),
     'file' => 'audio_feeds.feeds.inc',
     'type' => MENU_CALLBACK,
   );
@@ -99,6 +98,8 @@ function audio_feeds_menu() {
     'title' => 'M3U',
     'page callback' => 'audio_feeds_m3u',
     'page arguments' => array(1),
+    'access callback' => 'audio_feeds_access',
+    'access arguments' => array(1),
     'file' => 'audio_feeds.feeds.inc',
     'type' => MENU_CALLBACK,
   );
@@ -106,9 +107,18 @@ function audio_feeds_menu() {
     'title' => 'PLS',
     'page callback' => 'audio_feeds_pls',
     'page arguments' => array(1),
+    'access callback' => 'audio_feeds_access',
+    'access arguments' => array(1),
     'file' => 'audio_feeds.feeds.inc',
     'type' => MENU_CALLBACK,
   );
 
   return $items;
 }
+
+/**
+ * Menu access callback.
+ */
+function audio_feeds_access($node) {
+  return variable_get('audio_feeds_attach_'. $node->type, 0);
+}
