? .git
? itunes-481072-7.patch
Index: itunes.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/itunes/itunes.admin.inc,v
retrieving revision 1.6
diff -u -p -r1.6 itunes.admin.inc
--- itunes.admin.inc	31 Jul 2009 22:45:06 -0000	1.6
+++ itunes.admin.inc	31 Jul 2009 22:58:17 -0000
@@ -11,6 +11,8 @@
  */
 function itunes_admin_settings() {
   $node_types = node_get_types();
+  $content_module_exists = module_exists('content');
+  $content_types = $content_module_exists ? content_types() : array();
 
   // Build a list of node types that iTunes could operate on.
   $options = array();
@@ -24,22 +26,23 @@ function itunes_admin_settings() {
     '#default_value' => variable_get('itunes_types', array('audio')),
   );
 
-  // If FileField is enabled then let them select the enclosure field.
-  if (module_exists('content') && module_exists('filefield')) {
-    $fields = variable_get('itunes_filefields', array());
-    $form['itunes_filefields'] = array(
+  // Allow selection of the feed item's enclosure source if FileField is
+  // enabled then let them select the enclosure field.
+  if ($content_module_exists && module_exists('filefield')) {
+    $fields = variable_get('itunes_enclosure_source', array());
+    $form['itunes_enclosure_source'] = array(
       '#tree' => TRUE,
     );
     // Build the node's filefield selector.
     foreach ($node_types as $type) {
-      $content = content_types($type->type);
+      $content = $content_types[$type->type];
       $options = array(NULL => t('- None -'));
       foreach ($content['fields'] as $field_name => $field) {
         if ($field['type'] == 'filefield') {
           $options[$field_name] = $field['widget']['label'];
         }
       }
-      $form['itunes_filefields'][$type->type] = array(
+      $form['itunes_enclosure_source'][$type->type] = array(
         '#type' => 'select',
         '#options' => $options,
         '#default_value' => empty($fields[$type->type]) ? NULL : $fields[$type->type],
@@ -48,19 +51,19 @@ function itunes_admin_settings() {
     }
   }
 
+  // Allow selection of the feed item's tag source if taxonomy is enabled.
   if (module_exists('taxonomy')) {
-    $vocabs = variable_get('itunes_vocabularies', array());
-    $form['itunes_vocabularies'] = array(
+    $vocabs = variable_get('itunes_keyword_source', array());
+    $form['itunes_keyword_source'] = array(
       '#tree' => TRUE,
     );
-    // Build the node's filefield selector.
     foreach ($node_types as $type) {
       $type_vocabs = taxonomy_get_vocabularies($type->type);
       $options = array(NULL => t('- None -'));
       foreach ($type_vocabs as $vid => $vocab) {
         $options[$vid] = $vocab->name;
       }
-      $form['itunes_vocabularies'][$type->type] = array(
+      $form['itunes_keyword_source'][$type->type] = array(
         '#type' => 'select',
         '#options' => $options,
         '#default_value' => empty($vocabs[$type->type]) ? NULL : $vocabs[$type->type],
@@ -69,6 +72,34 @@ function itunes_admin_settings() {
     }
   }
 
+  // Allow selection of the feed item's author source.
+  $author_source = variable_get('itunes_author_source', array());
+  $form['itunes_author_source'] = array(
+    '#tree' => TRUE,
+  );
+  foreach ($node_types as $type) {
+    $options = array(
+      NULL => t('- None -'),
+      'node_author' => t('Node author'),
+    );
+    if ($content_module_exists) {
+      $content = $content_types[$type->type];
+      foreach ($content['fields'] as $field_name => $field) {
+        if ($field['type'] == 'text' && $field['widget']['type'] == 'text_textfield') {
+          $options[$field_name] = $field['widget']['label'];
+        }
+        elseif ($field['type'] == 'userreference') {
+          $options[$field_name] = $field['widget']['label'];
+        }
+      }
+    }
+    $form['itunes_author_source'][$type->type] = array(
+      '#type' => 'select',
+      '#options' => $options,
+      '#default_value' => empty($author_source[$type->type]) ? NULL : $author_source[$type->type],
+    );
+  }
+
   $form = system_settings_form($form);
   $form['#validate'][] = 'itunes_admin_settings_validate';
   $form['#theme'] = 'itunes_admin_settings';
@@ -89,14 +120,15 @@ function theme_itunes_admin_settings($fo
   $has_vocabularies = FALSE;
   foreach (element_children($form['itunes_types']) as $key) {
     $row = array(drupal_render($form['itunes_types'][$key]));
-    if (isset($form['itunes_filefields'][$key])) {
-      $row[] = drupal_render($form['itunes_filefields'][$key]);
+    if (isset($form['itunes_enclosure_source'][$key])) {
+      $row[] = drupal_render($form['itunes_enclosure_source'][$key]);
       $has_filefields = TRUE;
     }
-    if (isset($form['itunes_vocabularies'][$key])) {
-      $row[] = drupal_render($form['itunes_vocabularies'][$key]);
+    if (isset($form['itunes_keyword_source'][$key])) {
+      $row[] = drupal_render($form['itunes_keyword_source'][$key]);
       $has_vocabularies = TRUE;
     }
+    $row[] = drupal_render($form['itunes_author_source'][$key]);
 
     $rows[] = $row;
   }
@@ -107,6 +139,7 @@ function theme_itunes_admin_settings($fo
   if ($has_vocabularies) {
     $header[] = t('Vocabulary for use as keywords');
   }
+  $header[] = t('Source for use as author');
 
   return theme('table', $header, $rows) . drupal_render($form);
 }
\ No newline at end of file
Index: itunes.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/itunes/itunes.install,v
retrieving revision 1.5
diff -u -p -r1.5 itunes.install
--- itunes.install	31 Jul 2009 22:45:06 -0000	1.5
+++ itunes.install	31 Jul 2009 22:58:17 -0000
@@ -26,8 +26,9 @@ function itunes_install() {
 function itunes_uninstall() {
   drupal_uninstall_schema('itunes');
   variable_del('itunes_types');
-  variable_del('itunes_filefields');
-  variable_del('itunes_vocabularies');
+  variable_del('itunes_enclosure_source');
+  variable_del('itunes_keyword_source');
+  variable_del('itunes_author_source');
 }
 
 /**
@@ -78,3 +79,21 @@ function itunes_schema() {
   return $schema;
 }
 
+/**
+ * Rename the item source variables.
+ */
+function itunes_update_6100() {
+  $ret = array();
+
+  if ($var = variable_get('itunes_filefields', array())) {
+    variable_set('itunes_enclosure_source', $var);
+    variable_del('itunes_filefields');
+  }
+
+  if ($var = variable_get('itunes_vocabularies', array())) {
+    variable_set('itunes_keyword_source', $var);
+    variable_del('itunes_vocabularies');
+  }
+
+  return $ret;
+}
Index: itunes.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/itunes/itunes.module,v
retrieving revision 1.9
diff -u -p -r1.9 itunes.module
--- itunes.module	31 Jul 2009 22:45:06 -0000	1.9
+++ itunes.module	31 Jul 2009 22:58:17 -0000
@@ -156,7 +156,9 @@ function itunes_nodeapi(&$node, $op, $ar
 
       case 'rss item':
         $ret = array();
-        $fields = variable_get('itunes_filefields', array());
+
+        // File enclosure.
+        $fields = variable_get('itunes_enclosure_source', array());
         if (!empty($fields[$node->type]) && !empty($node->{$fields[$node->type]}[0]['fid'])) {
           $file = (array) $node->{$fields[$node->type]}[0];
           $ret[] = array(
@@ -177,7 +179,8 @@ function itunes_nodeapi(&$node, $op, $ar
           }
         }
 
-        $vocabs = variable_get('itunes_vocabularies', array());
+        // Keyword tags.
+        $vocabs = variable_get('itunes_keyword_source', array());
         if (!empty($vocabs[$node->type])) {
           $keywords = array();
           foreach ($node->taxonomy as $tid => $term) {
@@ -194,12 +197,32 @@ function itunes_nodeapi(&$node, $op, $ar
           }
         }
 
-        $ret[] = array(
-          'namespace' => array('xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd'),
-          'key' => 'itunes:author',
-          'value' => $node->name,
-        );
+        // Author.
+        $author_source = variable_get('itunes_author_source', array());
+        if (!empty($author_source[$node->type])) {
+          if ($author_source[$node->type] == 'node_author') {
+            $author = $node->name;
+          }
+          else {
+            $author_field = $node->$author_source[$node->type];
+            if (!empty($author_field[0]['safe'])) {
+              $author = $author_field[0]['view'];
+            }
+            elseif (!empty($author_field[0]['view'])) {
+              foreach ($author_field as $authors) {
+                $authors_view[] = strip_tags(($authors['view']));
+              }
+              $author = implode($authors_view, ', ');
+            }
+          }
+          $ret[] = array(
+            'namespace' => array('xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd'),
+            'key' => 'itunes:author',
+            'value' => $author,
+          );
+        }
 
+        // Remaining elements.
         if (!empty($node->itunes)) {
           $ret[] = array(
             'namespace' => array('xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd'),
