You are here

function fb_admin_app_page in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 6.2 fb.admin.inc \fb_admin_app_page()
  2. 7.3 fb.admin.inc \fb_admin_app_page()
1 string reference to 'fb_admin_app_page'
fb_menu in ./fb.module
Implements hook_menu().

File

./fb.admin.inc, line 101
Admin pages and forms for Drupal for Facebook.

Code

function fb_admin_app_page($fb_app = NULL) {
  fb_get_app_data($fb_app);
  fb_admin_get_app_info($fb_app);
  $fb = fb_api_init($fb_app);

  // @TODO use an actual theme function and make render more appealing.
  // Hide a couple things...
  unset($fb_app->secret);
  unset($fb_app->data);

  // Warn user if values have changed since last edit.
  foreach (array(
    'namespace' => 'canvas',
    'name' => 'title',
  ) as $prop => $key) {
    if (isset($fb_app->{$prop}) && $fb_app->{$prop} != $fb_app->{$key}) {
      drupal_set_message(t("The property %prop has been changed to %value on facebook.  Go to the Edit tab, confirm values are correct and hit Save button to syncronize the local values.", array(
        '%prop' => $prop,
        '%value' => $fb_app->{$prop},
      )), 'error');
    }
  }
  $props_map = array(
    t('Name') => 'name',
    t('Label') => 'label',
    t('ID') => 'id',
    t('Secret') => 'secret',
  );
  $output = "<dl>\n";

  // Render props learned from facebook and stored in $fb_app object.
  $props_map = fb_invoke(FB_ADMIN_OP_LIST_PROPERTIES, array(
    'fb_app' => $fb_app,
  ), $props_map, FB_ADMIN_HOOK);
  foreach ($props_map as $name => $key) {
    if (isset($fb_app->{$key})) {
      $output .= "<dt>{$name}</dt><dd>{$fb_app->{$key}}</dd>\n";
    }
  }

  // This clause belongs in fb_tab.module.  But currently no hook for that tab to add a "property" that is not a true facebook property.
  if ($fb_app->page_tab_url && module_exists('fb_tab')) {

    // This app can be added to a page.  Provide a link to do so.
    $add_url = "http://www.facebook.com/dialog/pagetab?app_id={$fb_app->id}&next=" . url(FB_TAB_PATH_ADDED . '/' . $fb_app->label, array(
      'absolute' => TRUE,
      'language' => NULL,
    ));
    $output .= '<dt>' . t('Add to page link') . '</dt><dd>' . l($add_url, $add_url) . '</dd>';
  }

  // Render additional properties
  $output .= '<dt>' . t('Access Token') . '</dt><dd>' . fb_get_token($fb) . "</dd>\n";
  $output .= "</dl>\n";

  //$output .=  '<pre>' . print_r($fb_app, 1) . '</pre>'; // debug
  return $output;
}