You are here

function _fb_canvas_make_form_action_local in Drupal for Facebook 5.2

Same name and namespace in other branches
  1. 5 fb_canvas.module \_fb_canvas_make_form_action_local()
  2. 6.2 fb_canvas.module \_fb_canvas_make_form_action_local()
1 call to _fb_canvas_make_form_action_local()
fb_canvas_form_alter in ./fb_canvas.module
Implementation of hook_form_alter.

File

./fb_canvas.module, line 330
This module provides some app-specific navigation to facebook apps.

Code

function _fb_canvas_make_form_action_local($action) {

  // If action is fully qualified, do not change it
  if (strpos($action, ':')) {
    return $action;
  }

  // I'm not sure where the problem is, but sometimes actions have two question marks.  I.e.
  // /htdocs/?app=foo&q=user/login?destination=comment/reply/1%2523comment-form
  // Here we replace 3rd (or more) '?' with '&'.
  $parts = explode('?', $action);
  if (count($parts) > 2) {
    $action = array_shift($parts) . '?' . array_shift($parts);
    $action .= '&' . implode('&', $parts);
  }

  //drupal_set_message("form action now " . "http://".$_SERVER['HTTP_HOST']. $action); // debug
  return "http://" . $_SERVER['HTTP_HOST'] . $action;
}