summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fb.module15
-rw-r--r--fb_app.install2
-rw-r--r--fb_canvas.module21
-rw-r--r--fb_url_rewrite.inc34
4 files changed, 49 insertions, 23 deletions
diff --git a/fb.module b/fb.module
index 5be41ea..cc25342 100644
--- a/fb.module
+++ b/fb.module
@@ -134,7 +134,7 @@ function fb_custom_theme() {
global $_fb_app;
- // fb_settings.inc may have been included in settings.php. If not, included it now.
+ // fb_settings.inc may have been included in settings.php. If not, include it now.
if (!function_exists('fb_settings')) {
module_load_include('inc', 'fb', 'fb_settings');
// trigger test in fb_devel.module
@@ -298,6 +298,7 @@ function fb_init() {
'scope' => 'header',
'group' => JS_LIBRARY,
));
+
}
// Add Facebook javascript to all pages.
@@ -373,6 +374,7 @@ function fb_api_init($fb_app) {
'secret' => $fb_app->secret,
'cookie' => variable_get(FB_VAR_USE_COOKIE, TRUE),
));
+
// Facebook certs are not valid.
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = FALSE;
Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYHOST] = FALSE;
@@ -736,10 +738,15 @@ function fb_require_authorization($fb = NULL, $destination = NULL) {
$fbu = fb_facebook_user($fb);
if (!$fbu) {
$client_id = $fb->getAppId();
- $redirect_uri = $destination ? $destination : url(fb_scrub_urls($_REQUEST['q']), array('absolute' => TRUE, 'fb_canvas' => fb_is_canvas()));
+ $redirect_uri = $destination ? $destination : url(current_path(), array('absolute' => TRUE, 'fb_canvas' => fb_is_canvas()));
$url = "https://graph.facebook.com/oauth/authorize?client_id=$client_id&redirect_uri=$redirect_uri";
- drupal_goto($url);
+ if (fb_is_canvas() && module_exists('fb_canvas')) {
+ fb_canvas_redirect($url);
+ }
+ else {
+ header('Location: ' . $url); // drupal_goto is for internal redirects only.
+ }
}
else {
return $fbu;
@@ -996,7 +1003,7 @@ function fb_menu() {
// Admin pages overview.
$items[FB_PATH_ADMIN] = array(
- 'title' => 'Facebook Applications',
+ 'title' => 'Facebook Apps',
'description' => 'Facebook Applications',
'page callback' => 'fb_admin_page',
'access arguments' => array(FB_PERM_ADMINISTER),
diff --git a/fb_app.install b/fb_app.install
index 6150272..4b5b876 100644
--- a/fb_app.install
+++ b/fb_app.install
@@ -11,7 +11,7 @@
*/
function fb_app_install() {
// drupal_install_schema is called by Drupal
- drupal_set_message(st('Facebook Application module installed. Please grant yourself <a href="!perm">permissions</a> and then browse to <a href="!create">Admin >> Facebook Applications</a> to get started.', array('!perm' => url('admin/people/permissions'), '!create' => url('admin/structure/fb') /* FB_PATH_ADMIN */)));
+ drupal_set_message(st('Facebook Application module installed. Please grant yourself <a href="!perm">permissions</a> and then browse to <a href="!create">Admin >> Structure >> Facebook Apps</a> to get started.', array('!perm' => url('admin/people/permissions'), '!create' => url('admin/structure/fb') /* FB_PATH_ADMIN */)));
}
/**
diff --git a/fb_canvas.module b/fb_canvas.module
index 2b3f233..94cc5a1 100644
--- a/fb_canvas.module
+++ b/fb_canvas.module
@@ -71,6 +71,7 @@ function fb_canvas_fb($op, $data, &$return) {
}
}
if ($fb_app) {
+ //dpm($fb_app, __FUNCTION__);
$return = $fb_app;
}
}
@@ -292,11 +293,13 @@ function fb_canvas_fix_url($url, $fb_app) {
*
* @see fb_url_rewrite.inc
*/
+/* not needed D7
if (!function_exists('custom_url_rewrite_outbound')) {
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
fb_canvas_url_outbound_alter($path, $options, $original_path);
}
}
+*/
/**
* Implements hook_url_outbound_alter().
@@ -308,6 +311,11 @@ if (!function_exists('custom_url_rewrite_outbound')) {
* particular application.
*/
function fb_canvas_url_outbound_alter(&$path, &$options, $original_path) {
+ // use $options['fb_url_alter'] = FALSE to suppress any alteration.
+ if ($options['fb_url_alter'] === FALSE) {
+ return;
+ }
+
if (isset($options['fb_canvas']) && is_string($options['fb_canvas'])) {
$fb_app = fb_get_app(array('label' => $options['fb_canvas']));
}
@@ -316,11 +324,9 @@ function fb_canvas_url_outbound_alter(&$path, &$options, $original_path) {
}
if ($fb_app && isset($fb_app->canvas)) {
- if ((!isset($options['fb_url_alter']) || $options['fb_url_alter']) &&
- (isset($options['fb_canvas']) && $options['fb_canvas'])) {
+ if (isset($options['fb_canvas']) && $options['fb_canvas']) {
// Make a url starting with apps.facebook.com/...
- $options['external'] = TRUE;
- $options[FB_SETTINGS_CB] = FALSE; // prevent fb_url_rewrite.inc from altering.
+ $options[FB_SETTINGS_CB] = FALSE; // prevent fb_url_rewrite.inc from inserting 'fb_cb'.
$options['absolute'] = TRUE;
$options['base_url'] = 'http://apps.facebook.com/' . $fb_app->canvas;
}
@@ -377,9 +383,10 @@ function fb_canvas_adjust_html($output, $options = array()) {
if ($_fb) {
if (function_exists('fb_url_outbound_alter')) {
- $base_before_rewrite = '';
+ $base_rewrite = '';
$rewrite_options = array(FB_SETTINGS_CB_SESSION => FALSE, FB_SETTINGS_CB_TYPE => FALSE);
- $base = $base_path . fb_url_outbound_alter($base_before_rewrite, $rewrite_options, ''); // short URL with rewrite applied.
+ fb_url_outbound_alter($base_rewrite, $rewrite_options, '');
+ $base = $base_path . $base_rewrite; // short URL with rewrite applied.
}
else {
// If no url_alter, use normal base_path.
@@ -418,7 +425,7 @@ function fb_canvas_adjust_html($output, $options = array()) {
if (count($patterns)) {
$count = 0;
$return = preg_replace($patterns, $replacements, $output, -1, $count);
- //print ("fb_canvas_adjust_html replaced $count.\n\n"); // debug
+ //dpm("fb_canvas_adjust_html replaced $count.\n\n"); // debug
return $return;
}
else
diff --git a/fb_url_rewrite.inc b/fb_url_rewrite.inc
index 99a3bb0..bbb30f4 100644
--- a/fb_url_rewrite.inc
+++ b/fb_url_rewrite.inc
@@ -71,15 +71,18 @@ function _fb_settings_parse($key) {
/**
* Define custom_url_rewrite_inbound() if not defined already.
*/
+/* D7 should not need.
if (!function_exists('custom_url_rewrite_inbound')) {
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
fb_url_inbound_alter($result, $path, $path_language);
}
}
-
+*/
/**
* Define custom_url_rewrite_outbound() if not defined already.
*/
+/* D7 should not need.
+
if (!function_exists('custom_url_rewrite_outbound')) {
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
if (!isset($options['fb_url_alter']) || $options['fb_url_alter']) {
@@ -90,6 +93,7 @@ if (!function_exists('custom_url_rewrite_outbound')) {
}
}
}
+*/
/**
* Implements hook_url_outbound_alter().
@@ -100,20 +104,28 @@ if (!function_exists('custom_url_rewrite_outbound')) {
* link from a canvas page out to the server's URL.
*/
function fb_url_outbound_alter(&$path, &$options, $original_path) {
- if (!isset($options['fb_url_alter']) || $options['fb_url_alter']) {
- $pre = '';
+ if ($options['fb_url_alter'] === FALSE) {
+ return;
+ }
- // Prefix each known value to the URL
- foreach (_fb_settings_url_rewrite_prefixes() as $prefix) {
- if (!isset($options[$prefix]) || $options[$prefix] !== FALSE) {
- if ($value = fb_settings($prefix))
- $pre .= $prefix . '/' . $value . '/';
- }
+ // For most hooks, fb should come before fb_.... modules. But in this case we want fb_canvas to act first.
+ if (function_exists('fb_canvas_url_outbound_alter')) {
+ fb_canvas_url_outbound_alter($path, $options, $original_path);
+ }
+
+ $pre = '';
+
+ // Prefix each known value to the URL
+ foreach (_fb_settings_url_rewrite_prefixes() as $prefix) {
+ if (!isset($options[$prefix]) || $options[$prefix] !== FALSE) {
+ if ($value = fb_settings($prefix))
+ $pre .= $prefix . '/' . $value . '/';
}
- $path = $pre . $path;
}
+ $path = $pre . $path;
- return $path;
+ // Since we called fb_canvas_url_alter already, supress it from acting again.
+ $options['fb_url_alter'] = FALSE;
}
/**