You are here

function fb_devel_info in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb_devel.module \fb_devel_info()
  2. 7.3 fb_devel.module \fb_devel_info()
1 string reference to 'fb_devel_info'
fb_devel_block in ./fb_devel.module

File

./fb_devel.module, line 336
Makes development with Drupal for Facebook much easier. Keep this module enabled until you're confident your app works perfectly.

Code

function fb_devel_info() {
  global $_fb, $_fb_app;
  global $user;
  global $base_url;
  global $base_path;
  $info = array();
  $label = fb_settings(FB_SETTINGS_CB);
  if ($_fb) {
    if ($_fb
      ->in_fb_canvas()) {
      $info['Page Status'] = t('Rendering FBML canvas page.');
    }
    elseif ($_fb
      ->in_frame()) {
      $info['Page Status'] = t('Rendering iframe.');
    }
    elseif ($label) {

      // Followed a link from within an iframe.
      $info['Page Status'] = t('Global fb instance is set (followed link in iframe, or handling a form).');
      $info['fb'] = $_fb;
    }
    else {
      if (fb_settings(FB_SETTINGS_TYPE) == FB_SETTINGS_TYPE_CANVAS) {
        $info['Page Status'] = t('Followed link in iframe canvas, or handling form.');
      }
      elseif (fb_settings(FB_SETTINGS_TYPE) == FB_SETTINGS_TYPE_CONNECT) {
        $info['Page Status'] = t('Connected via Facebook Connect');
      }
      elseif (!fb_settings(FB_SETTINGS_TYPE)) {
        $info['Page Status'] = t('Global fb instance is set.  Probably  facebook connect is enabled but user is not logged into facebook.');
      }
      else {
        $info['Page Status'] = t('Global fb instance is set, but page type unknown (%type).', array(
          '%type' => fb_settings(FB_SETTINGS_TYPE),
        ));
      }
    }
    $info['fb_facebook_user'] = fb_facebook_user();
    $fbu = fb_facebook_user();
    if (fb_api_check_session($_fb)) {
      try {

        // users_isAppUser() may be unreliable!
        $info['users_isAppUser'] = $_fb->api_client
          ->users_isAppUser();
        $info["users_isAppUser({$fbu})"] = $_fb->api_client
          ->users_isAppUser($fbu);
      } catch (Exception $e) {
        fb_log_exception($e, t('fb_devel unable to call users_isAppUser().'));
      }
    }
    else {
      $info['fb_api_check_session()'] = t('Returned FALSE');
    }
  }
  else {
    $info['Page Status'] = t('Not a canvas page.');
  }

  // Use theme_username() rather than theme('username') because we want link to local user, even when FBML is enabled
  $info['local user'] = theme_username($user);
  $info['fb_get_fbu'] = fb_get_fbu($user->uid);
  $info['base_url'] = $base_url;
  $info['base_path'] = $base_path;
  $info['url() returns'] = url();
  $info['$_REQUEST[q] is'] = isset($_REQUEST['q']) ? $_REQUEST['q'] : NULL;
  $info['arg(0) is'] = arg(0);
  $info['arg(1) is'] = arg(1);
  $info['session_id'] = session_id();
  $info['session_name'] = session_name();
  $info['request'] = $_REQUEST;
  $info['user'] = $GLOBALS['user'];
  $info['fb_app'] = $_fb_app;
  $info['session'] = $_SESSION;
  $info['cookies'] = $_COOKIE;
  if ($_fb) {
    $info['api_client'] = $_fb->api_client;
  }
  $form = array();
  foreach ($info as $key => $val) {
    if (is_string($val) || is_numeric($val) || !$val) {
      $form[] = array(
        '#value' => t($key) . ' = ' . $val,
        '#weight' => count($form),
        '#suffix' => '<br/>',
      );
    }
    else {
      $form[] = array(
        '#type' => 'fieldset',
        '#title' => t($key),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#weight' => count($form),
        'value' => array(
          '#prefix' => '<pre>',
          '#suffix' => '</pre>',
          '#type' => 'markup',
          '#value' => dprint_r($val, 1),
        ),
      );
    }
  }

  // It's not really a form, but we like collapsible fieldsets
  return $form;
}