You are here

function dialog_login_callback in Dialog 6

Menu callback for our ajax links.

1 string reference to 'dialog_login_callback'
dialog_example_menu in example/dialog_example.module
Implementation of hook_menu().

File

example/dialog_example.module, line 70

Code

function dialog_login_callback($type, $js) {
  switch ($type) {
    case 'login':
      $title = t('Login');
      $form_id = 'user_login';
      $msg = 'You are now logged in.';
      break;
    case 'register':
      $title = t('Register');
      $form_id = 'user_register';
      $msg = 'You are now registered.';
      break;
  }
  if ($js) {
    ctools_include('ajax');
    $form_state = array(
      'ajax' => TRUE,
      'title' => $title,
    );
    $output = dialog_form_wrapper($form_id, $form_state);
    if (empty($output)) {
      $output[] = dialog_command_display('Welcome', $msg);
      $output[] = ctools_ajax_command_redirect('user');
    }
    else {
      foreach ($output as $i => $command) {
        if ($command['command'] == 'dialog_display') {
          $output[$i]['options']['height'] = 'auto';
          $output[$i]['options']['width'] = 600;
          $output[$i]['options']['position'] = 'center';
          $output[$i]['options']['resizable'] = FALSE;
        }
      }
    }
    ctools_ajax_render($output);
  }
  else {
    return drupal_get_form($form_id);
  }
}