Index: fb_canvas.info
===================================================================
--- fb_canvas.info	(revision 1.1)
+++ fb_canvas.info	(6.x working copy)
@@ -1,5 +1,8 @@
 name=Facebook Application Canvas Pages
 description=Support for Facebook Canvas Pages
 package = Facebook
-dependencies = fb fb_app
+dependencies[] = fb
+dependencies[] = fb_app
+core = 6.x
 
+version = "6.x-1.x-dev"
Index: fb_canvas.module
===================================================================
--- fb_canvas.module	(revision 1.6)
+++ fb_canvas.module	(6.x working copy)
@@ -71,7 +71,7 @@
         $token = uniqid('fb_');
         $cid = session_id() . "_$token";
         watchdog('fb', "Storing cached form page $cid, then redirecting");
-        cache_set($cid, 'cache_page', $output, time() + (60 * 5), drupal_get_headers()); // (60 * 5) == 5 minutes
+        cache_set($cid, $output, 'cache_page', time() + (60 * 5), drupal_get_headers()); // (60 * 5) == 5 minutes
         
         $dest = 'http://apps.facebook.com/' . $fb_app->canvas . "/fb/form_cache/$cid";
         // $fb->redirect($url); // Does not work!
@@ -100,7 +100,7 @@
 /**
  * Implementation of hook_form_alter.
  */
-function fb_canvas_form_alter($form_id, &$form) {
+function fb_canvas_form_alter(&$form, &$form_state, $form_id) {
   // Add our settings to the fb_app edit form.
   if (is_array($form['fb_app_data'])) {
     $node = $form['#node'];
@@ -142,26 +142,27 @@
     
     // Allow primary links to be different on facebook versus the rest of the
     // site.  Code from menu_configure() in menu.module.
-    $root_menus = menu_get_root_menus();
-    
-    $primary_options = $root_menus;
-    $primary_options[0] = t('<use sitewide setting>');
-    $secondary_options = $root_menus;
-    $secondary_options[0] = t('<use sitewide setting>');
-    
-    $form['fb_app_data']['fb_canvas']['primary_links'] =
-      array('#type' => 'select',
-            '#title' => t('Menu containing primary links'),
-            '#description' => t('Your application can have primary links different from those used elsewhere on your site.'),
-            '#default_value' => $fb_canvas_data['primary_links'],
-            '#options' => $primary_options,
+    $primary = variable_get('menu_primary_links_source', 'primary-links');
+    $primary_options = array_merge($menu_options, array('' => t('<use sitewide setting>')));
+    $form['fb_app_data']['fb_canvas']['menu_primary_links_source'] = 
+      array(
+        '#type' => 'select',
+        '#title' => t('Source for the primary links'),
+        '#default_value' => $fb_canvas_data['primary_links'],
+        '#options' => $primary_options,
+        '#tree' => FALSE,
+        '#description' => t('Your application can have primary links different from those used elsewhere on your site.'),
       );
-    $form['fb_app_data']['fb_canvas']['secondary_links'] = 
-      array('#type' => 'select',
-            '#title' => t('Menu containing secondary links'),
-            '#default_value' => $fb_canvas_data['secondary_links'],
-            '#options' => $secondary_options,
-            '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'),
+
+    $secondary_options = array_merge($menu_options, array('' => t('<use sitewide setting>')));
+    $form['fb_app_data']['fb_canvas']["menu_secondary_links_source"] = 
+      array(
+        '#type' => 'select',
+        '#title' => t('Source for the secondary links'),
+        '#default_value' => $fb_canvas_data['secondary_links'],
+        '#options' => $secondary_options,
+        '#tree' => FALSE,
+        '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'),
       );
 
 
@@ -203,7 +204,7 @@
     
     // We need to make sure the action goes to our domain and not apps.facebook.com
     if ($form['#action'] == '') {
-      $form['#action'] = $_GET['q'];
+      $form['#action'] = $_GET['q']; //TODO: somewhere the canvas is getting prepended to form action urls. form submit doesn't work
     }
     $form['#action'] = _fb_canvas_make_form_action_local($form['#action']);
     // Let's hope no subsequent hook_form_alters mess with #action.
@@ -222,8 +223,8 @@
       $output = theme('dl', 
                       array(t('Canvas page') => "http://apps.facebook.com/$fb_app->canvas",
                             t('Callback URL') => t("%clean_url<br /> (or %advanced_url only if your theme is designed to support PAGE_TYPE.)<br/>Make sure you have enabled clean URLs, and include the trailing '/'.",
-                                                   array("%clean_url" => url('', NULL, NULL, TRUE) . FB_SETTINGS_APP_NID . '/' . $node->nid .'/',
-                                                         "%advanced_url" => url('', NULL, NULL, TRUE) . FB_SETTINGS_APP_NID . '/' . $node->nid . '/' . FB_SETTINGS_PAGE_TYPE . '/PAGE_TYPE/',
+                                                   array("%clean_url" => url('', array('absolute' => TRUE)) . FB_SETTINGS_APP_NID . '/' . $node->nid . '/',
+                                                         "%advanced_url" => url('', array('absolute' => TRUE)) . FB_SETTINGS_APP_NID . '/' . $node->nid . '/'. FB_SETTINGS_PAGE_TYPE . '/PAGE_TYPE/',
                                                    )
                             ),
                       ));
@@ -353,7 +354,15 @@
 	if (fb_canvas_is_fbml()) {
       //dpm($output, "before fb_canvas_process");
       // We're producing FBML for a canvas page
+
+      /*
+      TODO: $output['logo'] is not being processed properly by these
+      patterns. fb_canvas_process() returns '/sites/all/themes/fb_fbml/logo.png'
+      and Facebook complains "Relative URLs not allowed here"
       
+      LOGO is turned off in theme settings for now.
+      */
+
 	  // Change links to use canvas on Facebook
 	  $patterns[] = "|=\"{$base}|";
 	  $replacements[] = "=\"/{$fb_app->canvas}/";
@@ -409,4 +418,3 @@
   else
 	return $output;
 }
-?>
\ No newline at end of file
