You are here

function ctools_ajax_sample_login in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 ctools_ajax_sample/ctools_ajax_sample.module \ctools_ajax_sample_login()

A modal login callback.

1 string reference to 'ctools_ajax_sample_login'
ctools_ajax_sample_menu in ctools_ajax_sample/ctools_ajax_sample.module
Implementation of hook_menu()

File

ctools_ajax_sample/ctools_ajax_sample.module, line 197
Sample AJAX functionality so people can see some of the CTools AJAX features in use.

Code

function ctools_ajax_sample_login($js = NULL) {

  // Fall back if $js is not set.
  if (!$js) {
    return drupal_get_form('user_login');
  }
  ctools_include('modal');
  ctools_include('ajax');
  $form_state = array(
    'title' => t('Login'),
    'ajax' => TRUE,
  );
  $output = ctools_modal_form_wrapper('user_login', $form_state);
  if (empty($output)) {

    // empty $output signifies success, so we'll use it as our $commands
    // array.
    $output = array();
    $inplace = ctools_ajax_text_button(t('remain here'), 'ctools_ajax_sample/nojs/login/inplace', t('Go to your account'));
    $account = ctools_ajax_text_button(t('your account'), 'ctools_ajax_sample/nojs/login/user', t('Go to your account'));
    $output[] = ctools_modal_command_display(t('Login Success'), '<div class="modal-message">Login successful. You can now choose whether to ' . $inplace . ', or go to ' . $account . '.</div>');
  }
  ctools_ajax_render($output);
}