You are here

function fb_app_fb_admin in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_app.admin.inc \fb_app_fb_admin()
  2. 6.2 fb_app.admin.inc \fb_app_fb_admin()

Implements hook_fb_admin().

File

./fb_app.admin.inc, line 13

Code

function fb_app_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) {

    // URLs for Facebook events we support.
    $return['uninstall_url'] = url(FB_APP_PATH_EVENT . '/' . $fb_app->label . "/" . FB_APP_EVENT_POST_REMOVE . '/', array(
      'absolute' => TRUE,
      'language' => NULL,
    ));
    $return['authorize_url'] = url(FB_APP_PATH_EVENT . '/' . $fb_app->label . "/" . FB_APP_EVENT_POST_AUTHORIZE . '/', array(
      'absolute' => TRUE,
      'language' => NULL,
    ));
  }
  elseif ($op == FB_ADMIN_OP_POST_SET_PROPERTIES) {

    // Application properties have been set or synced on facebook.  Ensure we store the application's proper namespace.
    try {
      $graph = fb_graph($data['fb_app']->id, array(
        'access_token' => fb_get_token($data['fb']),
      ));
      if (empty($graph['namespace'])) {

        // Avoid PHP notice when optional namespace is missing.
        $graph['namespace'] = '';
      }
      db_update('fb_app')
        ->fields(array(
        'canvas' => $graph['namespace'],
      ))
        ->condition('fba_id', $graph['id'], '=')
        ->execute();
    } catch (Exception $e) {
      fb_log_exception($e, t('Failed to learn application namespace from Facebook.'));
    }
  }
  elseif ($op == FB_ADMIN_OP_LIST_PROPERTIES) {
    $return[t('Application Name')] = 'name';
    $return[t('De-Authorize Callback URL')] = 'deauth_callback_url';
  }
  elseif ($op == FB_ADMIN_OP_LOCAL_LINKS && isset($fb_app->fba_id)) {

    // Path to edit this app.
    $return[t('edit')] = FB_PATH_ADMIN_APPS . '/' . $fb_app->label . '/fb_app';
  }
}