Index: multistep.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/multistep/multistep.module,v
retrieving revision 1.1.2.2.2.24
diff -u -r1.1.2.2.2.24 multistep.module
--- multistep.module	15 Oct 2009 15:53:01 -0000	1.1.2.2.2.24
+++ multistep.module	15 Oct 2009 18:11:21 -0000
@@ -341,6 +341,10 @@
     unset($_REQUEST['destination']);
     drupal_goto($_REQUEST['q'], array('redirect' => $dest));
   }
+  // We need to remove #redirect to prevent redirection to the profile main page
+  if (module_exists('content_profile') && is_content_profile($type)) {
+    unset($form['#redirect']);
+  }
   $step = _multistep_get_current_step($type);
   // This hides extra fields for steps they don't belong in.
   $content_type = content_types($type);
@@ -410,7 +414,7 @@
   // Allow user with "toggle multistep" permissions to toggle between multistep or entire form.
   $form['buttons']['all'] = array(
     '#type' => 'item',
-    '#value' => l('View ' . ($step == 0 ? 'multistep' : 'entire') . ' form', arg(0) . '/' . arg(1) . '/' . arg(2) . ($step == 0 ? '/1' : '/0')),
+    '#value' => l('View ' . ($step == 0 ? 'multistep' : 'entire') . ' form', arg(0) . '/' . arg(1) . '/' . (module_exists('content_profile') && is_content_profile($type) ? 'profile/' . arg(3) : arg(2)) . ($step == 0 ? '/1' : '/0')),
     '#weight' => 16,
     '#access' => user_access('toggle multistep'),
   );
@@ -500,13 +504,24 @@
   }
   // If there are steps left, go to the next (or previous) one.
   if ($goto_step <= variable_get('multistep_steps_' .$type, 0)) {
-    $form_state['redirect'] = array('node/' . $nid . '/edit/' . $goto_step, (isset($_REQUEST['redirect']) ? array('redirect' => $_REQUEST['redirect']) : array()));
+    // Handle redirects for content_profile
+    if (module_exists('content_profile') && is_content_profile($type)) {
+      global $user;
+      $form_state['redirect'] = 'user/' . $user->uid . '/profile/' . $type . '/' . $goto_step;
+    }
+    else {
+      $form_state['redirect'] = array('node/' . $nid . '/edit/' . $goto_step, (isset($_REQUEST['redirect']) ? array('redirect' => $_REQUEST['redirect']) : array()));
+    }
   }
   else {
     // If this was the last step, then exit the form. If there was a destination parameter, honor it now.
     if (isset($_REQUEST['redirect'])) {
       $form_state['redirect'] = $_REQUEST['redirect'];
     }
+    elseif (module_exists('content_profile') && is_content_profile($type)) {
+      global $user;
+      $form_state['redirect'] = 'user/' . $user->uid;
+    }
     else {
       $form_state['redirect'] = 'node/'. $nid;
     }
@@ -620,6 +635,23 @@
   && arg(3) <= variable_get('multistep_steps_' . $type, 0)) {
     $step = arg(3);
   }
+  // Get the step if it's a content profile
+  elseif (module_exists('content_profile')
+  && is_content_profile($type)
+  && arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'profile'
+  && arg(3) == $type
+  && is_numeric(arg(4)) && arg(4) >=1
+  && arg(4) <= variable_get('multistep_steps_' . $type, 0)) {
+    $step = arg(4);
+  }
+  elseif (module_exists('content_profile')
+  && is_content_profile($type)
+  && arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'profile'
+  && arg(3) == $type
+  && is_numeric(arg(4)) && arg(4) == 0
+  && user_access('toggle multistep')) {
+    $step = 0;
+  }
   // Revert back if user does not have permissions to switch display.
   if ($step == 0 && !user_access('toggle multistep')
   && variable_get('multistep_default_' . $type, 'multistep') == 'multistep') {
