You are here

function fancy_login_ajax_callback in Fancy Login 7.3

Same name and namespace in other branches
  1. 6.2 includes/fancy_login.pages.inc \fancy_login_ajax_callback()

Page callback function for fancy_login/ajax/%.

This function performs the AJAX callback for fancy_login.js which makes AJAX commands requesting different forms, and inserting them into the Fancy Login login block.

1 string reference to 'fancy_login_ajax_callback'
fancy_login_menu in ./fancy_login.module
Implements hook_menu().

File

includes/fancy_login.pages.inc, line 212
Holds various callbacks for the fancy login module.

Code

function fancy_login_ajax_callback($type) {
  switch ($type) {
    case "password":
      module_load_include('inc', 'user', 'user.pages');
      $form = drupal_get_form('fancy_login_user_pass');
      break;
    case "register":
      $form = drupal_get_form('fancy_login_user_register_form');
      break;
    case "login":
      $form = drupal_get_form('fancy_login_user_login_block');
      unset($form['#prefix'], $form['#suffix']);
      break;
  }
  $rendered_form = render($form);
  $scripts = drupal_add_js();
  if (!empty($scripts['settings'])) {
    $settings = '<script type="text/javascript">jQuery.extend(Drupal.settings, ';
    $settings .= drupal_json_encode(call_user_func_array('array_merge_recursive', $scripts['settings']['data']));
    $settings .= ');</script>';
  }
  $return = array(
    'content' => $rendered_form . $settings,
    'status' => TRUE,
    'type' => $type,
  );
  die(drupal_json_output($return));
}