? .cache
? .settings
? media-377050.patch
? resource/media-resource-d6-permissions.patch
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media/Attic/README.txt,v
retrieving revision 1.2.2.6
diff -u -p -r1.2.2.6 README.txt
--- README.txt	27 Jan 2009 17:21:48 -0000	1.2.2.6
+++ README.txt	24 Feb 2009 17:18:27 -0000
@@ -20,9 +20,13 @@ INSTALLATION
 
 CONFIGURATION
 -------------------------------------------------------
- 1. Go to admin > content > media
- 2. Configure settings per content type. Each field in a node can have options
-    for what resources and formatters are available to it.
+ 1. Grant "administer resources" permission to users that will be uploading or 
+    browsing resources
+ 2. Go to admin > content > media > global
+ 3. Global and Default Media Settings, which would normally be enabled everywhere
+    (will only be available for users with the administer resources permission 
+    and in content types with appropriate fields).
+ 4. Configure settings per content type if needed.
 
 
 DEVELOPERS
Index: media.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media/media.module,v
retrieving revision 1.8.2.30
diff -u -p -r1.8.2.30 media.module
--- media.module	19 Feb 2009 19:24:35 -0000	1.8.2.30
+++ media.module	24 Feb 2009 17:18:28 -0000
@@ -27,14 +27,14 @@ define('MEDIA_TYPES_DEFAULT', '*');
  *
  */
 function media_menu() {
-  // ajax formatter
+  // AJAX formatter
   $items['media/ahah'] = array(
     'page callback' => 'media_ahah_formatter_load',
     'access arguments' => array('access content'),
     'file' => 'media_ahah.inc',
   );
 
-  // media configuration
+  // Media configuration parent path.
   $items['admin/content/media'] = array(
     'title' => 'Media',
     'description' => 'Configure your site\'s Media settings.',
@@ -42,26 +42,47 @@ function media_menu() {
     'access arguments' => array('administer media'),
     'file' => 'media_admin.inc',
   );
-
-  // build pages for each content type
+  
+  // Default settings, for content types that do not have their own.
+  $items['admin/content/media/global'] = array(
+    'title' => 'Global and Default Media Settings',
+    'description' => 'Configure Global Media settings, including default content type settings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('media_admin_settings','global'),
+    'access arguments' => array('administer media'),
+    'file' => 'media_admin.inc',
+    'weight' => 3,
+  );
+  
+  // Top-level page for content types, split off because it gets crowded.
+  $items['admin/content/media/types'] = array(
+    'title' => 'Content Type Settings',
+    'description' => 'Configure Media settings that are specific to a content type',
+    'page callback' => 'media_admin_settings',
+    'page arguments' => array('media_admin_settings','types'),
+    'access arguments' => array('administer media'),
+    'file' => 'media_admin.inc',
+  );
+  
+  // Build pages for each content type.
   $content_types = node_get_types();
   if ($content_types) {
     foreach ($content_types as $content_type) {
-      $items['admin/content/media/'. $content_type->type] = array(
+      $items['admin/content/media/types/'. $content_type->type] = array(
         'title' => $content_type->name,
         'description' => 'Configure Media settings for '. $content_type->name,
         'page callback' => 'drupal_get_form',
         'page arguments' => array('media_admin_settings', $content_type->type),
         'access arguments' => array('administer media'),
         'file' => 'media_admin.inc',
+        'type' => MENU_CALLBACK,
       );
     }
   }
-
+  
   return $items;
 }
 
-
 /**
  * Implementation of hook_form_alter().
  * @param $form
@@ -74,8 +95,14 @@ function media_form_alter(&$form, $form_
 
   // Add the media browser on the node add/edit screen.
   if (strstr($form_id, 'node_form') ) {
-    // Is the media browser enabled on this node type?
-    if (variable_get('media_'. $form['type']['#value'] .'_enabled', NULL)) {
+    // Is the media browser enabled on this node type? Type-specific options override the default.
+    if (variable_get('media_'. $form['type']['#value'] .'_override', null)) {
+      $enabled = variable_get('media_'. $form['type']['#value'] .'_enabled', NULL);
+    }
+    else {
+      $enabled = variable_get('media_global_enabled', 1);
+    }
+    if ($enabled) {
       // Get the fields we need to enable on this module.
       $fields = media_active_fields_for_node_type($form['type']['#value']);
       foreach ($fields as $field => $registration_ids) {
@@ -445,10 +472,41 @@ function media_active_fields_for_node_ty
       ),
     );
   }
+  
+  // Need to know if the type-specific or global settings are going to be used.
+  // At least one of them is enabled at this point.
+  $type_override = variable_get('media_'. $type_name .'_override', false);
+
   $items = array();
   // extract the fields for this node type
   foreach ((array)$type['fields'] as $field_name => $field) {
-    $items[] = variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $function, array());
+    // Ignore the content-type specific per-field setting unless the override is set
+    $fields_enabled = false;
+    if ($type_override) {
+      $fields_enabled = variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $function,false);
+    }
+    else {
+      //@TODO: Right now, if it's using the default it will be enabled for all fields.
+      // Eventually it will probably be better to allow per-field controls at a global level as well.
+      // However, this line will probably just work once the actual variables exist.
+      $fields_enabled = variable_get('media_global_'. $field['field_name'] .'_'. $function,'default');
+      // Handle the default special, because we want the default to be on for all fields but don't know what the fields are yet.
+      if ($fields_enabled === 'default') {
+        $fields_enabled = array();
+        foreach (media_registration_kinds() as $kind) {
+          // get all the kinds that match this field
+          if ($registrations = media_get_fields($field['type'], $kind)) {
+            foreach ($registrations as $id => $registration) {
+              $compound_id = $field['field_name'] .'--'. $id;
+              $fields_enabled[$compound_id] = $compound_id;
+            }
+          }
+        }
+      }
+    }
+    if (!empty($fields_enabled)) {
+      $items[] = $fields_enabled;
+    }
   }
 
   $data = array();
Index: media_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media/Attic/media_admin.inc,v
retrieving revision 1.1.2.10
diff -u -p -r1.1.2.10 media_admin.inc
--- media_admin.inc	27 Jan 2009 20:02:44 -0000	1.1.2.10
+++ media_admin.inc	24 Feb 2009 17:18:28 -0000
@@ -14,19 +14,38 @@
  * @return unknown
  */
 function media_admin_settings($form = array(), $type_name = null) {
-  // Default page - no content type selected.
-  if (!$type_name) {
+  // Default page - list global and content type sub-menus.
+  if (empty($type_name)) {
+    $items = array(
+      l('Global and Default Media Settings', 'admin/content/media/global'),
+      l('Content Type Settings', 'admin/content/media/types'),
+    );
+    return theme('item_list', $items, t('Configure your site\'s Media settings.'));
+  }
+  // Base content type page - list mode.
+  if ($type_name == 'types') {
     // get all the content types
     $types = node_get_types();
     $content_types = array();
     if ($types) {
       foreach ($types as $content_type) {
-        $content_types[] = l($content_type->name, 'admin/content/media/'. $content_type->type);
+        $content_types[] = l($content_type->name, 'admin/content/media/types/'. $content_type->type);
       }
     }
-    return theme('item_list', $content_types, t('Media module settings'));
+    return theme('item_list', $content_types, t('Configure Media settings that are specific to a content type'));
   }
+  // Remaining options (global and specific type) return a form
   $form = array();
+  // Global settings are currently just defaults for content types
+  if ($type_name == 'global') {
+    $form['media_global_enabled'] = array(
+      '#title' => t('Media resource browser'),
+      '#type' => 'checkbox',
+      '#description' => t('Enable or Disable the Media resource browser for all types, unless specifically set for a given type.'),
+      '#default_value' => variable_get('media_global_enabled', 1),
+    );
+    return system_settings_form($form);
+  }
   // Specific content type settings.
   // Do we have cck installed?
   if (module_exists('content')) {
@@ -36,10 +55,16 @@ function media_admin_settings($form = ar
     // Get the specific content type.
     $type = (array) node_get_types('type', $type_name);
   }
-
+  
   // Master settings.
+  $form['media_'. $type_name .'_override'] = array(
+    '#title' => t($type["name"] . ' overrides default values'),
+    '#type' => 'checkbox',
+    '#description' => t('Override the default settings for this content type.  The options below will only be used if this box is checked.'),
+    '#default_value' => variable_get('media_'. $type_name .'_override', null),
+  );
   $form['media_'. $type_name .'_enabled'] = array(
-    '#title' => t('Media resource browser'),
+    '#title' => t('Enable Media resource browser'),
     '#type' => 'checkbox',
     '#description' => t('Enable the Media resource browser for this node type.'),
     '#default_value' => variable_get('media_'. $type_name .'_enabled', null),
