diff -u b/modules/dialog_user/dialog_user.module b/modules/dialog_user/dialog_user.module
--- b/modules/dialog_user/dialog_user.module
+++ b/modules/dialog_user/dialog_user.module
@@ -40,7 +40,7 @@
$path = 'user/register';
break;
case 'password':
- // @TODO Why doesn't request new password work?
+ module_load_include('inc', 'user', 'user.pages');
$title = t('Request new password');
$form_id = 'user_pass';
$path = 'user/password';
@@ -53,14 +53,14 @@
dialog_display(TRUE);
$content = drupal_get_form($form_id);
// If the form has been submitted from within the dialog and it has passed
- // validation and has been submitted, the dialog_display() function will have
- // been updated to return false (see dialog_user_ajax_form_submit()).
- // This is desired because if form submission completed without error
- // we want to dismiss the dialog and refresh the page.
- // If dialog_display() returns true, we're either showing the form for the first time
- // or redrawing the form after a validation error.
+ // validation and has been submitted, the dialog_display() function will
+ // have been updated to return false (see dialog_user_ajax_form_submit()).
+ // This is desired because if form submission completed without error, we
+ // want to dismiss the dialog and refresh the page. If dialog_display()
+ // returns true, we're either showing the form for the first time or
+ // redrawing the form after a validation error.
if (dialog_display()) {
- $output[] = dialog_command_display($content, array('title' => $title));
+ $output[] = dialog_command_display($content, array('title' => $title, 'draggable' => false, 'resizable' => false));
}
elseif ($destination = $_GET['destination']) {
$output[] = dialog_command_redirect($destination);
@@ -79,19 +79,6 @@
* Implement hook_form_alter().
*/
function dialog_user_form_alter(&$form, &$form_state, $form_id) {
- // Make the user login block links dialog friendly.
- if ($form_id == 'user_login_block') {
- $items = array();
- if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
- $items[] = l(t('Create new account'), 'user/register/nojs', array('attributes' => array('title' => t('Create a new user account.'), 'class' => array('use-ajax', 'use-dialog'))));
- }
- $items[] = l(t('Request new password'), 'user/password/nojs', array('attributes' => array('title' => t('Request new password via e-mail.'), 'class' => array('use-ajax', 'use-dialog'))));
- $form['links']['#markup'] = theme('item_list', array('items' => $items));
- $form['links']['#attached']['library'] = array(
- array('dialog', 'dialog'),
- );
- }
-
$forms = array('user_register_form', 'user_pass', 'user_login');
if (in_array($form_id, $forms)) {
if (dialog_display() || isset($form_state['values']['dialog_display'])) {
@@ -99,10 +86,9 @@
$form['#prefix'] = '
';
$form['#suffix'] = '
';
- // Submit form via AJAX from within dialog.
- // Do this instead of using adding #ajax to the submit button
- // so that ajax call is made to the callback handler we defined rather
- // than system/ajax.
+ // Submit form via AJAX from within dialog. Do this instead of adding
+ // #ajax to the submit button, so that the ajax call is made to the
+ // callback handler we defined rather than system/ajax.
$form['actions']['submit']['#attributes'] = array (
'class' => array('use-ajax-submit')
);
@@ -114,21 +100,37 @@
}
/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function dialog_user_form_user_login_block_alter(&$form, &$form_state) {
+ // Make the user login block links dialog friendly.
+ $items = array();
+ if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
+ $items[] = l(t('Create new account'), 'user/register/nojs', array('attributes' => array('title' => t('Create a new user account.'), 'class' => array('use-ajax', 'use-dialog'))));
+ }
+ $items[] = l(t('Request new password'), 'user/password/nojs', array('attributes' => array('title' => t('Request new password via e-mail.'), 'class' => array('use-ajax', 'use-dialog'))));
+ $form['links']['#markup'] = theme('item_list', array('items' => $items));
+ $form['links']['#attached']['library'] = array(
+ array('dialog', 'dialog'),
+ );
+}
+
+/**
* Ajax submit handler for forms inside dialogs.
*/
function dialog_user_ajax_form_submit(&$form, &$form_state) {
- // Unset dialog_display static variable. It was set and is useful when
- // the form is first generated inside the dialog window. But at this stage
- // we no longer want to display a dialog. In fact we want to eventually dismiss it.
+ // Unset dialog_display static variable. It was set and is useful when the
+ // form is first generated inside the dialog window. But at this stage we no
+ // longer want to display a dialog. In fact we want to eventually dismiss it.
drupal_static_reset('dialog_display');
- // We also don't want to redirect the form needlessly. The rediected
- // page would have loaded in the dialog. We'll be dismissing that dialog.
- // If a destination was specified we will handle that with a dialog_command.
+ // We also don't want to redirect the form needlessly. The redirected page
+ // would have loaded in the dialog. We'll be dismissing that dialog. If a
+ // destination was specified we will handle that with a dialog_command.
$form_state['no_redirect'] = true;
}
/**
- * Implement hook_theme
+ * Implements hook_theme().
*/
function dialog_user_theme($existing, $type, $theme, $path){
return array(
@@ -140,7 +142,7 @@
}
/**
- * Override the links provided to link to login/register to post comments to make use of dialog
+ * Override the links provided to link to login/register to post comments to make use of dialog.
*/
function dialog_user_comment_post_forbidden($variables) {
$node = $variables['node'];
@@ -161,8 +163,8 @@
if ($authenticated_post_comments) {
// Ensure that dialog_library is available.
drupal_add_library('dialog','dialog');
- // We cannot use drupal_get_destination() because these links
- // sometimes appear on /node and taxonomy listing pages.
+ // We cannot use drupal_get_destination() because these links sometimes
+ // appear on /node and taxonomy listing pages.
if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_SEPARATE_PAGE) {
$destination = array('destination' => "comment/reply/$node->nid#comment-form");
}
@@ -185 +187 @@
-}
\ No newline at end of file
+}