? mf_reg_10062010.patch
? modalframe_register.info
Index: README.txt
===================================================================
RCS file: README.txt
diff -N README.txt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ README.txt	7 Oct 2010 04:30:06 -0000
@@ -0,0 +1,157 @@
+// $Id: $
+
+CONTENTS OF THIS FILE
+---------------------
+
+* INTRODUCTION
+* INSTALLATION
+* CONFIGURATION
+* HOW IT WORKS
+* MODAL LOGIN
+* MODAL REGISTER
+* MISC THEMING
+* CREDITS
+
+
+INTRODUCTION
+------------
+
+This module enables the log in, register, and forgotten password forms to be
+rendered inside a modal frame using the Drupal Modal Frame API module
+(http://drupal.org/modalframe).
+
+INSTALLATION
+------------
+
+1. Download the module, place it in your modales directory, and enable it a
+admin/build/modules.
+
+2. There are two module dependencies:
+
+  * Modal Frame API (modalframe)
+
+  * JQuery UI (jquery_ui)
+
+3. Enable the Modal Frame Login/Register block at /admin/build/block
+
+4. Disable the Drupal core login block at /admin/build/block
+
+5. (Optional) copy modalframe_register.js to your theme directory and enable it
+via the THEMENAME.info file. Now you may customize the javascript.
+
+  * The easiest customization is to configure the time delay before a page
+reload after submitting a login with no destination, and the time delay before a
+redirect if your link includes a login destination. These are the first two
+variables at the top of the modalframe_register.js page.
+  
+  * Defaults are 3000ms.
+
+
+CONFIGURATION
+-------------
+
+There are no admin page configuration options, because I think we should instead
+configure this module in the template.php.
+
+By default, this module opens the login + forgotten password and the
+registration page in a modalframe. 
+
+The three pages this module dynamically generates are:
+
+* modal/login - a stripped-down login page with the login and forgotten password
+forms.
+
+* modal/register - a stripped-down user registration page.
+
+* modal/welcome - a return page for providing more information after submitting
+a registration form. And idea is to add the Facebook Connect button on this
+page, or more information about the user's pending membership. 
+
+
+HOW IT WORKS
+----------------
+
+The modal window is triggered by the login or register link that is displayed in
+the Modal Frame Login/Register block.
+
+<a class="modalframe-register" href="/modal/login?destination=node">Login</a>
+
+The class, modalframe-register, tells the JQuery to process the link and fire
+the link off into a modal frame. 
+
+The modal/register link is similar.
+
+
+MODAL LOGIN
+________________
+
+The modal frame window opens in a modal frame. When the submit button is
+pressed, the redirect uri (?destination=...) and a status message (page
+statusMessages) is sent back to the parent page. 
+
+The status message is displayed according to your Drupal installation's style
+for status messages in a DIV the module inserts above the $messages variable. If
+you don't print $messages in your page.tpl.php, the status message will not
+display.
+
+After a delay (default is 3000ms), the page either redirects to the desired
+redirect url, or reloads on the same page if no destination variable is sent
+with the log in link.
+
+To turn off the modal window just for the login link, add this to your
+template.php:
+
+function YOURTHEMENAME_modalframe_register_login_link(
+  $attributes = array(), 
+    $query = NULL,
+  ) {
+  $attributes['class'] = (
+    !empty($attributes['class']) ? $attributes['class'] : '');
+  return l(t('Login'), 'user/login', 
+    array(
+      'attributes' => $attributes, 
+      'query' => (!empty($query) ? $query : drupal_get_destination()))
+    );
+}
+
+MODAL REGISTER
+_________________
+
+By default, the registratin form is opened in a modal frame. After submitting,
+the module will return to the user the page modal/welcome while still inside the
+modal frame. 
+
+To disable the register link to modal window, add something like this to
+template.php:
+
+YOURTHEMENAME_modalframe_register_login_link(
+  $attributes = array(), 
+  $query = NULL) {
+  $attributes['class'] = (
+    !empty($attributes['class']) ? $attributes['class'] : ''
+    );
+  return l(t('Register'), 'user/register', array(
+    'attributes' => $attributes,)
+  );
+}
+
+
+MISC THEMING
+_________________
+
+All pages inside the modal frame this module creates are generated in the
+modalframe-page.tpl.php included with the modalframe module. This module's
+output is sent to that page via the $content variable. If you want to change the
+message after submitting registration, you can do so in that template after
+copying it to your theme directory and clearing your cache.
+
+
+CREDITS
+_________________
+
+This module was skillfully engineered by Joe Hyde at
+http://www.hydeinteractive.com/
+Drupal UID = jghyde
+Gig 'em Aggies!
+
+
Index: modalframe_register.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modalframe_contrib/modalframe_register/Attic/modalframe_register.js,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 modalframe_register.js
--- modalframe_register.js	17 Jul 2010 04:47:16 -0000	1.1.2.1
+++ modalframe_register.js	7 Oct 2010 04:30:06 -0000
@@ -1,5 +1,21 @@
 // $Id: modalframe_register.js,v 1.1.2.1 2010/07/17 04:47:16 markuspetrux Exp $
 
+/**
+ * Set this variable to determine the delay before 
+ * reloading the page after closing the modalframe (via submit)
+ * in ms.
+ */
+var reloadDelay = 3000;
+
+/**
+ * Set this variable to determine the delay before 
+ * redirecting to a new page after closing the modalframe (via submit)
+ * in ms.
+ */
+var redirectDelay = 3000;
+
+// end configuration options
+
 (function ($) {
 
 Drupal.modalFrameRegister = Drupal.modalFrameRegister || {};
@@ -24,20 +40,31 @@ Drupal.behaviors.modalFrameRegister = fu
 Drupal.modalFrameRegister.onClick = function() {
   // Define the onSubmit callback for the Modal Frame.
   var onSubmitCallback = function(args) {
-    if (args.redirect) {
-      // Redirect to specified destination.
-      setTimeout(function() { window.location = args.redirect; }, 1);
+    // Display status messages generated during submit processing.
+    if (args.statusMessages) {
+      $('#modalframe-register-messages').hide().html(args.statusMessages).show('slow');
     }
-    else {
-       // Refresh the page after closing the modal window.
-      location.reload();
+
+    if (args.destination) {
+      // Redirect to specified destination.
+      if (args.destination != 'same' && args.destination != 'noreload') {
+        // We are headed to a new destination... 
+        setTimeout(function() { redirector(args.destination); }, reloadDelay);
+      }
+      else if (args.destination == 'same') {
+        // We are staying on the same page, but need to reload it to see different stuff
+        setTimeout(function() { reloader(); }, redirectDelay);
+      }
+      else {
+        // Don't do jack. We don't want to reload or redirect.  
+      }
     }
   };
 
   // The URL of the same link will be opened within a modal frame.
   Drupal.modalFrame.open({
     url: $(this).attr('href'),
-    width: 500,
+    width: 900,
     height: 600,
     onSubmit: onSubmitCallback
   });
@@ -47,3 +74,11 @@ Drupal.modalFrameRegister.onClick = func
 };
 
 })(jQuery);
+
+function redirector(reDirect){
+  window.location = reDirect;
+}
+
+function reloader() {
+  location.reload(); 
+}
Index: modalframe_register.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modalframe_contrib/modalframe_register/Attic/modalframe_register.module,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 modalframe_register.module
--- modalframe_register.module	17 Jul 2010 04:47:16 -0000	1.1.2.1
+++ modalframe_register.module	7 Oct 2010 04:30:06 -0000
@@ -5,6 +5,14 @@
  * @file
  * Opens Login and Register forms in a modal window.
  */
+ 
+/**
+ * Implementation of hook_registry_alter()
+ *
+ */
+function modalframe_register_theme_registry_alter(&$theme_registry) {
+  $theme_registry['status_messages']['function'] = 'modalframe_register_theme_status_messages'; 
+}
 
 /**
  * Implementation of hook_theme().
@@ -43,13 +51,13 @@ function modalframe_register_menu() {
   $items['modal/register'] = array(
     'title' => 'Register',
     'page callback' => 'modalframe_register_page_register_form',
-    'access callback' => 'user_register_access',
+    'access callback' => 'user_is_anonymous',
     'type' => MENU_CALLBACK,
   );
-  $items['modal/register/welcome'] = array(
+  $items['modal/welcome'] = array(
     'title' => 'Registration details',
     'page callback' => 'modalframe_register_page_welcome',
-    'access callback' => 'user_is_logged_in',
+    'access callback' => 'user_is_anonymous',
     'type' => MENU_CALLBACK,
   );
   return $items;
@@ -59,7 +67,7 @@ function modalframe_register_menu() {
  * Implementation of hook_init().
  */
 function modalframe_register_init() {
-  if ($_GET['q'] == 'modal/register' || $_GET['q'] == 'modal/login' || $_GET['q'] == 'modal/register/welcome') {
+  if ($_GET['q'] == 'modal/register' || $_GET['q'] == 'modal/login' || $_GET['q'] == 'modal/welcome') {
     modalframe_child_js();
   }
 }
@@ -88,37 +96,77 @@ function modalframe_register_block($op =
  * Implementation of hook_form_alter().
  */
 function modalframe_register_form_alter(&$form, $form_state, $form_id) {
-  // Append our submit handler. This is required if we want a chance to
-  // close the modal frame dialog.
-  $form['#submit'][] = 'modalframe_register_form_submit';
-  if ($form_id == 'user_register') {
-    $form['#redirect'] = 'modal/register/welcome';
+ 	// Append our submit handler. This is required if we want a chance to
+ 	// close the modal frame dialog.
+ 	switch ($form_id) {
+    case 'user_login':
+        $form['#submit'][] = 'modalframe_register_form_submit';
+        break;
+    case 'user_register':
+        $form['#redirect'] = 'modal/welcome';
+        break;
+    case 'user_pass':
+        $form['#submit'][] = 'modalframe_register_form_submit';
+        break;
   }
-}
+} 
 
 /**
  * Submit handler for our node edit form example.
  */
 function modalframe_register_form_submit($form, &$form_state) {
-  if ($form_state['values']['op'] == t('Log in')) {
-    modalframe_close_dialog(array(
-      'message' => t('Processing the form...'),
-    ));
+  // $_GET['destination'] is set in the modalframe_register block
+  // To add a redirect destination, preprocess the theme_link
+  // and add '?destination=/path/to/redirect' to the end of the link
+  if (isset($_GET['destination'])) {
+    // Check to see if there is a destination.
+    // Then set it to be sent to the js handler 
+    // upon closing the modal frame.
+    $destination = $_GET['destination'];
+  }
+  else {
+    // If there is no destination set (that is, the '?destination= ...) 
+    // then we are staying on the same page.
+    // Since we are logging in, we need to reload the page
+    // sending 'same' to the submit handler reloads the page
+    // after closing the modal window.
+    $destination = 'same';
   }
+  switch ($form_state['values']['op']) {
+    case t('Log in'):
+      $close = array(
+        'destination' => $destination,
+        'statusMessages' => '<span id="login-message">' . t('You are logging in... ') . '</span>',   
+      );
+      break;
+    case t('E-mail new password'):
+      unset($_GET['destination'], $destination);
+      $close = array(
+        'destination' => 'noreload',
+        'statusMessages' => t('Your password reset information has been sent to your E-mail.'),   
+      );
+      break;
+  }
+  modalframe_close_dialog($close);
 }
 
 /**
- * Menu callback; login form in child window.
- */
+* Menu callback; login form in child window.
+*/
 function modalframe_register_page_login_form() {
+  // Add the Drupal core collapse javascript
+  drupal_add_js('misc/collapse.js');
   // Send the Modal Frame javascript for child windows to the page.
   modalframe_child_js();
   // Get the forms from the user module.
   module_load_include('inc', 'user', 'user.pages');
   // Render the page contents.
   $output = drupal_get_form('user_login');
-  $output .= '<div><h3>'. t('Forgot your password?') .'</h3></div>';
-  $output .= drupal_get_form('user_pass');
+  //$output .= '<script type="text/javascript" src="/misc/collapse.js"></script>';
+  $output .= '<fieldset class="collapsible collapsed">';
+  $output .= '<legend>' . t('Forgot your password?') . '</legend>';
+  $output .= '<div class="fieldset-wrapper">' . drupal_get_form('user_pass') . '</div>';
+  $output .= '</fieldset>';
   return $output;
 }
 
@@ -127,7 +175,7 @@ function modalframe_register_page_login_
  */
 function modalframe_register_page_register_form() {
   // Send the Modal Frame javascript for child windows to the page.
-  modalframe_child_js();
+ // modalframe_child_js();
   // Render the page contents.
   module_load_include('inc', 'user', 'user.pages');
   return drupal_get_form('user_register');
@@ -138,9 +186,8 @@ function modalframe_register_page_regist
  */
 function modalframe_register_page_welcome() {
   // Send the Modal Frame javascript for child windows to the page.
-  modalframe_child_js();
   // Render the page contents.
-  return t('Thank You! Your registration is accepted. Please check your email for further instructions to instantly activate your account.');
+  return t('Thank You for joining');
 }
 
 /**
@@ -177,6 +224,32 @@ function theme_modalframe_register_login
 }
 
 /**
+ * Add the status message empty DIV to the $messages var
+ * so that it will always print on the page.
+ * This is an override of theme_status_messages() to prepend
+ * a hidden, empty DIV to the $messages variable.
+ */
+function modalframe_register_theme_status_messages($display = NULL) {
+  $output = '<div id="modalframe-register-messages" class="messages status" style="display: none;"></div>';
+  foreach (drupal_get_messages($display) as $type => $messages) {
+    $output .= "<div class=\"messages $type\">\n";
+    if (count($messages) > 1) {
+      $output .= " <ul>\n";
+      foreach ($messages as $message) {
+        $output .= '  <li>'. $message ."</li>\n";
+      }
+      $output .= " </ul>\n";
+    }
+    else {
+      $output .= $messages[0];
+    }
+    $output .= "</div>\n";
+  }
+  return $output;
+}
+
+
+/**
  * Theme the user login link.
  */
 function theme_modalframe_register_login_link($attributes = array(), $query = NULL) {
@@ -189,7 +262,7 @@ function theme_modalframe_register_login
  */
 function theme_modalframe_register_register_link($attributes = array(), $query = NULL) {
   $attributes['class'] = (!empty($attributes['class']) ? $attributes['class'] .' modalframe-register' : 'modalframe-register');
-  return l(t('Register'), 'modal/register', array('attributes' => $attributes, 'query' => (!empty($query) ? $query : drupal_get_destination())));
+  return l(t('Register'), 'modal/register', array('attributes' => $attributes,));
 }
 
 /**
