You are here

function fb_admin_all_apps in Drupal for Facebook 7.4

Helper builds an array of known apps, for use in forms.

4 calls to fb_admin_all_apps()
fb_admin_app_select_form in ./fb.admin.inc
fb_admin_long_lived_token in ./fb.admin.inc
fb_admin_token_generate_process in ./fb.admin.inc
fb_opengraph_form_alter in ./fb_opengraph.module

File

./fb.admin.inc, line 1209

Code

function fb_admin_all_apps() {
  $all_apps = array();

  // Include apps from the fb_app table.
  $result = db_query("SELECT * FROM {fb_application} WHERE status & :is_enabled", array(
    ':is_enabled' => FB_STATUS_APP_ENABLED,
  ));
  while ($row = $result
    ->fetchAssoc()) {
    $row['data'] = unserialize($row['sdata']);
    $all_apps[$row['fba']] = $row;
  }

  // Include apps from the fb_token table.
  $result = db_query("SELECT * FROM {fb_token} WHERE status & :is_app AND status & :is_valid", array(
    ':is_app' => FB_STATUS_FLAG_APP,
    ':is_valid' => FB_STATUS_FLAG_VALID,
  ));
  while ($row = $result
    ->fetchAssoc()) {
    if (empty($all_apps[$row['fba']])) {
      $all_apps[$row['fba']] = $row;
    }
    else {
      $all_apps[$row['fba']] = $all_apps[$row['fba']] + $row;

      // Add access_token to array.
    }
  }
  return $all_apps;
}