? .DS_Store
? media_mover-795184.patch
? media_mover-test.patch
Index: class_media_mover_step.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/Attic/class_media_mover_step.php,v
retrieving revision 1.1.2.17
diff -u -p -r1.1.2.17 class_media_mover_step.php
--- class_media_mover_step.php	20 Apr 2010 21:29:03 -0000	1.1.2.17
+++ class_media_mover_step.php	11 May 2010 05:12:59 -0000
@@ -29,6 +29,13 @@ class media_mover_step {
         $this->{$key} = $value;
       }
     }
+    // Get configuration data
+    if (isset($cid)) {
+      $configuration = db_fetch_object(db_query("SELECT * FROM {media_mover_step_map} WHERE cid = '%s' AND sid = '%s'", $cid, $sid));
+      foreach ($configuration as $key => $value) {
+        $this->{$key} = $value;
+      }
+    }
   }
 
 
@@ -243,7 +250,7 @@ class media_mover_step {
     if ($this->remove_prepare($instance)) {
       // Delete this single instance
       if ($instance) {
-        db_query("DELETE FROM {media_mover_step_map} WHERE sid = '%s', cid = '%s', step_order = %d", $this->sid, $this->cid, $this->step_order);
+        db_query("DELETE FROM {media_mover_step_map} WHERE sid = '%s' AND cid = '%s' AND step_order = %d", $this->sid, $this->cid, $this->step_order);
       }
       // Delete all instances
       else {
Index: media_mover_ui/media_mover_ui.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/media_mover_ui/Attic/media_mover_ui.module,v
retrieving revision 1.1.2.34
diff -u -p -r1.1.2.34 media_mover_ui.module
--- media_mover_ui/media_mover_ui.module	25 Apr 2010 18:27:18 -0000	1.1.2.34
+++ media_mover_ui/media_mover_ui.module	11 May 2010 05:13:00 -0000
@@ -404,7 +404,7 @@ function media_mover_ui_landing_page() {
         // Default configurations can not be edited
         // @TODO need to implement this
         $configuration->settings['default'] ? l(t('edit'), 'admin/build/media_mover/configuration/' . $configuration->cid . '/edit') : t('Default'),
-        l(t('Clone'), 'admin/build/media_mover/configuration/' . $configuration->cid . '/clonde'),
+        l(t('Clone'), 'admin/build/media_mover/configuration/' . $configuration->cid . '/clone'),
       );
       $rows[] = $row;
     }
@@ -564,7 +564,7 @@ function media_mover_ui_add_config_form(
   // Get the forms for the actions
   if ($configuration->steps) {
     foreach ($configuration->steps as $step) {
-      media_ui_config_form_step_form($form, $configuration, $step);
+      media_mover_ui_config_form_step_form($form, $configuration, $step);
     }
   }
 
@@ -721,7 +721,7 @@ function media_mover_ui_add_config_form_
 
 
 /**
- * Configuration form for an individual step
+ * Configuration form for an individual step in the "Add configuration" form
  *
  * @param $form
  *   Array, Drupal form array
@@ -730,7 +730,7 @@ function media_mover_ui_add_config_form_
  * @param $step
  *   Object, media mover step
  */
-function media_ui_config_form_step_form(&$form, $configuration, $step) {
+function media_mover_ui_config_form_step_form(&$form, $configuration, $step) {
   // Fieldset for the settings for this step. We have to figure out
   // if this fieldset should be displayed. We display it if it is the last step.
   $form['step_'. $step->step_order] = array(
@@ -818,6 +818,16 @@ function media_ui_config_form_step_form(
      '#value' => $step->step_action_choice,
     );
   }
+  
+  // Add delete button
+  if ($step->step_order != 1) { // Skip the harvest step. Should this be $step->harvest != 1?
+    $form['step_'. $step->step_order]['remove_'. $step->step_order] = array(
+      '#type' => 'submit',
+      '#value' => 'Remove',
+      '#name' => 'remove_'. $step->step_order,
+      '#submit' => array('media_mover_ui_config_form_remove_inline_step'),
+    );
+  }
 
 
 
@@ -825,33 +835,68 @@ function media_ui_config_form_step_form(
   $form['step_'. $step->step_order]['action'] = $function_form;
 }
 
+/**
+ * This is called by the edit configuration form to remove a specific step
+ * 
+ * @param $form
+ * @param $form_state
+ */
+function media_mover_ui_config_form_remove_step($form, &$form_state) {
+  $step = str_replace('remove_', '', $form_state['clicked_button']['#name']);
+  $sid = $form['step_'. $step]['remove_value_'. $step]['#value'];
+  $step_object = new media_mover_step();
+  $step_object->load($sid, $form_state['values']['cid']);
+  $step_object->remove();
+  media_mover_ui_clean_step_order($form_state['values']['cid']);
+}
+
+/**
+ * Re-orders steps in sequential order when a step is deleted
+ * 
+ * @param int $cid is a configuration id
+ */
+function media_mover_ui_clean_step_order($cid) {
+  $result = db_query("SELECT * FROM {media_mover_step_map} WHERE cid = '%s'", $cid);
+  $i = 1;
+  while ($row = db_fetch_array($result)) {
+    db_query("UPDATE {media_mover_step_map} SET step_order = '%d' WHERE cid = '%s' AND step_order = '%d'", $i, $row['cid'], $row['step_order']);
+    $i++;
+  }
+}
 
 /**
- * This is called by the configuration form to remove a specific action
+ * This is called by the add configuration form to remove a specific action
  * @TODO this needs overhaul
  * @param $form
  * @param $form_state
  */
-function media_mover_ui_config_form_remove_action($form, &$form_state) {
+function media_mover_ui_config_form_remove_inline_step($form, &$form_state) {
+  
   // get the step from the name of the button that was clicked
   $step = str_replace('remove_', '', $form_state['clicked_button']['#name']);
   // get a total count of the items in the configuration
-  $count = count($form_state['storage']['values']['steps']);
+  $count = count($form_state['storage']['configuration']->steps);
   // remove the requested item
-  unset($form_state['storage']['values']['steps'][$step]);
+  unset($form_state['storage']['configuration']->steps[$step]);
+  unset($form['step_'. $count]);
   // if there are more than one items in the form
   if ($count != $step ) {
     // now move all the additional steps
     while ($step <= $count) {
       // move the value one place
-      $form_state['storage']['values']['steps'][$step] = $form_state['storage']['values']['steps'][$step + 1];
+      $next = $step + 1;
+      $form_state['storage']['configuration']->steps[$step] = $form_state['storage']['configuration']->steps[$next];
+      $form_state['storage']['configuration']->steps[$step]->step_order = $step;
+      $form['step_'. $step] = $form['step_'. $next];
       $step++;
     }
     // unset the last item
-    unset($form_state['storage']['values']['steps'][$count]);
+    unset($form_state['storage']['configuration']->steps[$count]);
+    unset($form['step_'. $count]);
   }
   // rebuild the form
   $form_state['rebuild'] = TRUE;
+  $form_state['storage']['configuration']->step--;
 }
 
 
@@ -904,7 +949,6 @@ function media_mover_ui_config_edit_form
     '#title' => t('Describe your configuration'),
     '#description' => t('Enter a description for your configuration.'),
     '#default_value' => $configuration->description,
-    '#required' => TRUE,
   );
   $form['config']['enabled'] = array(
     '#type' => 'checkbox',
@@ -926,6 +970,13 @@ function media_mover_ui_config_edit_form
       '#collapsible' => TRUE,
       '#collapsed' => FALSE,
     );
+    
+    $form['step_'. $step_order]['remove_'. $step_order] = array(
+      '#type' => 'submit',
+      '#value' => 'Remove',
+      '#name' => 'remove_'. $step_order,
+      '#submit' => array('media_mover_ui_config_form_remove_step'),
+    );
 
     $function = $step->configuration;
     // Does the configuration function exist?
