Index: flvmediaplayer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flvmediaplayer/flvmediaplayer.module,v
retrieving revision 1.14.2.52.2.48
diff -u -r1.14.2.52.2.48 flvmediaplayer.module
--- flvmediaplayer.module	22 Apr 2009 16:37:07 -0000	1.14.2.52.2.48
+++ flvmediaplayer.module	22 Apr 2009 20:17:12 -0000
@@ -137,7 +137,7 @@
       // is this node type enabled to have players displayed on it?
       if ($enabled_types[$node->type]) {
         // get the configuration values for this node
-        if ($node->flvmediaplayer_config = flvmediaplayer_configuration_values($node)) {
+        if ($node->flvmediaplayer_config = flvmediaplayer_node_configuration_values($node)) {
           // add player to node if it exists
           flvmediaplayer_insert_player($node, theme('flvmediaplayer_node_display', $node, null, null, $a3));
         }
@@ -188,7 +188,7 @@
 function flvmediaplayer_form_alter($form_id, &$form) {
   if (isset($form['#node']) && $form_id == $form['#node']->type. '_node_form' && variable_get('flvmp_'. $form['#node']->type .'_override', false)) {
     // get the configuration for this node
-    $config = flvmediaplayer_configuration_values($form['#node']);
+    $config = flvmediaplayer_node_configuration_values($form['#node']);
 
     $form['flvmediaplayer'] = array(
       '#type' => 'fieldset',
@@ -382,7 +382,7 @@
   static $control = false;
 
   // build a config to use. This handles overrides by nodes, profiles, and params
-  if (! $config = flvmediaplayer_configuration_values($node, $profile, $params) ) {
+  if (! $config = flvmediaplayer_node_configuration_values($node, $profile, $params) ) {
     return;
   }
 
@@ -462,7 +462,7 @@
  *   is this an embed request?
  * @return array
  */
-function flvmediaplayer_configuration_values($node = null, $profile_name = null, $params = array()) {
+function flvmediaplayer_node_configuration_values($node = null, $profile_name = null, $params = array()) {
   // check to see if this configuration allows override
   if (variable_get('flvmp_'. $node->type .'_override', false)) {
     // check to see if we have any data for this node
@@ -488,9 +488,23 @@
   if (count($params)) {
     $config = array_merge($config, $params);
   }
-  // @TODO do this before merging the params in, merge params AFTER
-  // Now take the configuration data and put it into a structured array
-  $data = array();
+
+  return flvmediaplayer_profile_configuration_values(null, $config);
+}
+
+
+/**
+ * Helper function to build configuration data from a profile with
+ * no node data
+ * @param $profile
+ *   string, profile name
+ * @return array
+ */
+function flvmediaplayer_profile_configuration_values($profile = false, $config = false) {
+	$data = array();
+	if (! $config) {
+	  $config = flvmediaplayer_profile_get_config($profile);
+	}
   // loop through all the form data and strip out form prefixes
   foreach ($config as $name => $value) {
     // get the params out
@@ -509,7 +523,7 @@
   // now add some data back in
   $data['name'] = $config['flvmp_name'];
   $data['pid'] = $config['flvmp_pid'];
-  // merge the values and return
+
   return $data;
 }
 
