You are here

function fb_admin_application_edit_form_submit in Drupal for Facebook 7.4

File

./fb.admin.inc, line 1009

Code

function fb_admin_application_edit_form_submit($form, &$form_state) {
  $fb_app = $form_state['values'];
  extract($form_state['fb']);

  // $graph
  try {
    if ($fb_app['data']['access_token']) {
      fb_token_save($fb_app['data']['access_token'], array(
        'fba' => $fb_app['fba'],
        'fbu' => $fb_app['fba'],
        'status' => FB_STATUS_FLAG_VALID | FB_STATUS_FLAG_APP,
      ));
    }
    fb_admin_app_save($fb_app);
    drupal_set_message(t('Saved facebook application setting for !app.', array(
      '!app' => l($graph['name'], $graph['link']),
    )));

    /*
    // Should we just go ahead and flush the cache here automatically?
    drupal_set_message(t('Recommended: <a href=!cache_url>clear cached data</a> after changing Facebook app settings.', array(
                           '!cache_url'=> url('admin/config/development/performance'),
                         )), 'warning');
    */
    if ($form_state['values']['make_default']) {

      // Make this the default app.
      variable_set(FB_VAR_DEFAULT_APP, $form_state['values']['fb_app_data']);
    }
    elseif ($form_state['values']['is_default']) {

      // The app is no longer default.
      variable_del(FB_VAR_DEFAULT_APP);
    }
  } catch (Exception $e) {
    fb_log_exception($e, t('Failed to save application settings.'));
  }
  $form_state['redirect'] = FB_PATH_ADMIN_APPS;
}