You are here

function fb_tab_pages in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_tab.module \fb_tab_pages()

This page callback will show the user a list of pages they have authority to configure.

1 string reference to 'fb_tab_pages'
fb_tab_menu in ./fb_tab.module

File

./fb_tab.module, line 507
This module provides support for "Profile Tabs" that can be added to facebook pages (no longer allowed for user profiles).

Code

function fb_tab_pages() {
  if ($fbu = fb_facebook_user()) {

    // @TODO: broken on facebook's end??? this query used to work.
    $result = fb_fql_query($GLOBALS['_fb'], "SELECT page_id, name, pic_small, page_url, type FROM page WHERE has_added_app=1 AND page_id IN (SELECT page_id FROM page_admin WHERE uid={$fbu})");

    // FQL, no {curly_brackets}
    if (count($result)) {
      $output['pages'] = array(
        '#prefix' => '<ul>',
        '#suffix' => '</ul>',
      );
      foreach ($result as $data) {
        $output['pages'][$data['page_id']] = array(
          '#value' => l($data['name'], fb_tab_config_url($data['page_id'], array(
            'fb_canvas' => fb_is_canvas(),
          ))),
          '#prefix' => '<li>',
          '#suffix' => '</li>',
        );
      }
      $output['intro'] = array(
        '#value' => t('Select one of your pages to configure:'),
        '#prefix' => '<p>',
        '#suffix' => '</p>',
      );
    }
    else {
      $output['intro'] = array(
        '#value' => t('Found no pages to configure.'),
        '#prefix' => '<p>',
        '#suffix' => '</p>',
      );
    }
    return drupal_render($output);
  }
  else {
    fb_access_denied();
  }
}