You are here

function fb_canvas_fb_admin in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 6.2 fb_canvas.admin.inc \fb_canvas_fb_admin()
  2. 7.3 fb_canvas.admin.inc \fb_canvas_fb_admin()

Implementation of hook_fb_admin().

File

./fb_canvas.admin.inc, line 12
Admin pages and forms for canvas apps.

Code

function fb_canvas_fb_admin($op, $data, &$return) {
  $fb = isset($data['fb']) ? $data['fb'] : NULL;
  $fb_app = isset($data['fb_app']) ? $data['fb_app'] : NULL;
  if ($op == FB_ADMIN_OP_SET_PROPERTIES) {

    // Compute properties which we can set automatically.
    if (function_exists('fb_url_inbound_alter')) {
      $callback_url = url('', array(
        'absolute' => TRUE,
        'language' => FALSE,
      )) . FB_SETTINGS_CB . '/' . $fb_app->id . '/';
    }
    else {

      // Paving the way to make URL alters optional.
      $callback_url = url('', array(
        'absolute' => TRUE,
      ));
    }
    $return['canvas_url'] = $callback_url;
    if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) >= FB_SECURE_URLS_SOMETIMES) {
      $return['secure_canvas_url'] = str_replace('http://', 'https://', $callback_url);
    }
    if (variable_get(FB_VAR_SECURE_URLS, FB_SECURE_URLS_SOMETIMES) <= FB_SECURE_URLS_SOMETIMES) {

      // Make canvas_url HTTP, even if we administer drupal via HTTPS.
      $return['canvas_url'] = str_replace('https://', 'http://', $return['canvas_url']);
    }
  }
  elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) {
    $return[t('Canvas URL')] = 'canvas_url';
    $return[t('Secure Canvas URL')] = 'secure_canvas_url';
  }
}