You are here

function fb_admin_page in Drupal for Facebook 6.3

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

Drupal page callback.

1 string reference to 'fb_admin_page'
fb_menu in ./fb.module
Implements hook_menu().

File

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

Code

function fb_admin_page() {
  $apps = fb_get_all_apps();
  $output = '';

  // Avoid PHP notice.
  if (count($apps)) {
    $header = array(
      t('Label'),
      t('Name'),
      t('Canvas'),
      t('Local Operations'),
      t('Remote Settings'),
    );
    $protocol = fb_protocol();
    foreach ($apps as $fb_app) {

      // Get properties from facebook.
      fb_admin_get_app_info($fb_app);
      $row = array();

      // Title.
      $row[] = $fb_app->label . ($fb_app->status ? '' : ' ' . t('(<em>not enabled</em>)'));

      // New apps no longer have about pages.
      $name = isset($fb_app->name) ? $fb_app->name : $fb_app->label;
      $row[] = $name;

      // Canvas Page.
      if (isset($fb_app->namespace) && $fb_app->namespace != $fb_app->canvas) {
        drupal_set_message(t('Canvas page for %label is out of sync!  Facebook believes it is %fbcanvas, while our database believes %canvas.  Edit and save the application to remedy this.', array(
          '%label' => $fb_app->label,
          '%fbcanvas' => $fb_app->namespace,
          '%canvas' => $fb_app->canvas,
        )), 'error');
      }
      if ($fb_app->canvas) {
        $row[] = l($fb_app->canvas, $protocol . '://apps.facebook.com/' . $fb_app->canvas);
      }
      else {
        $row[] = t('n/a');
      }

      // Local Ops
      $local_links = fb_invoke(FB_ADMIN_OP_LOCAL_LINKS, array(
        'fb_app' => $fb_app,
      ), array(
        t('view') => FB_PATH_ADMIN_APPS . '/' . $fb_app->label,
        t('sync props') => FB_PATH_ADMIN_APPS . '/' . $fb_app->label . '/fb/set_props',
      ), FB_ADMIN_HOOK);
      $links = array();
      foreach ($local_links as $title => $href) {
        $links[] = array(
          'title' => $title,
          'href' => $href,
        );
      }
      $row[] = theme('links', $links);

      // Remote Settings
      $row[] = l($fb_app->id, 'https://www.facebook.com/developers/editapp.php?app_id=' . $fb_app->id);
      $rows[] = $row;
    }
    $output .= theme('table', $header, $rows);
  }
  else {
    if (!module_exists('fb_app')) {
      $output = t('Enable the <em>Facebook Apps</em> module (fb_app.module) to manage an application.');
    }
    else {
      $output = t('Click <a href="!url">Add Application</a> to get started.', array(
        '!url' => url('admin/build/fb/fb_app_create'),
      ));
    }
  }
  return $output;
}