Index: google_admanager.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_admanager/google_admanager.install,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 google_admanager.install
--- google_admanager.install	31 Oct 2009 08:03:45 -0000	1.2.2.1
+++ google_admanager.install	5 Nov 2009 16:06:14 -0000
@@ -18,4 +18,26 @@
   $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'google_admanager'");
 
   return $ret;
+}
+
+function google_admanager_update_6101() {
+  $ret = array();
+  
+  $ad_slots = variable_get('google_admanager_ad_slots', '');
+  $ad_slots = explode("\n", str_replace("\r", '', trim($ad_slots)));
+  if (is_array($ad_slots)) {
+    $result = db_query("SELECT bid, delta FROM {blocks} WHERE module = 'google_admanager'");
+    while ($block = db_fetch_object($result)) {
+      if (isset($ad_slots[$block->delta])) {
+        //updating block with new delta based on the block name
+        $ret[] = update_sql("UPDATE {blocks} SET delta = '%s' WHERE bid = %d", $ad_slots[$block->delta], $block->bid);
+      }
+      else {
+        //removing the block which does not exist anymore
+        $ret[] = update_sql("DELETE FROM {blocks} WHERE bid = %d", $block->bid);
+      }
+    }
+  }
+  
+  return $ret;  
 }
\ No newline at end of file
Index: google_admanager.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_admanager/google_admanager.module,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 google_admanager.module
--- google_admanager.module	31 Oct 2009 17:25:55 -0000	1.5.2.2
+++ google_admanager.module	6 Nov 2009 23:56:47 -0000
@@ -12,10 +12,10 @@
   $id = variable_get('google_admanager_account', '');
   if (!empty($id)) {
     $ad_slots = variable_get('google_admanager_ad_slots', '');
-    $ad_slots = explode ("\n", str_replace("\r", '', trim($ad_slots)));
+    $ad_slots = drupal_map_assoc(explode("\n", str_replace("\r", '', trim($ad_slots))));
     if ($op == 'list') {
       foreach($ad_slots as $ad_slot) {
-        $blocks[] = array(
+        $blocks[$ad_slot] = array(
           'info' => 'Ad Slot: ' . $ad_slot,
         );
       }
@@ -94,6 +94,26 @@
 }
 
 /**
+ * Implementation of hook_admin_settings_form_validate()
+ */
+function google_admanager_admin_settings_form_submit($form, &$form_state) {
+  $ad_slots = explode("\n", str_replace("\r", '', trim($form_state['values']['google_admanager_ad_slots'])));
+  $ad_slots = drupal_map_assoc(explode("\n", str_replace("\r", '', trim($ad_slots))));
+  
+  $result = db_query("SELECT bid, delta FROM {blocks} WHERE module = 'google_admanager'");
+  while ($block = db_fetch_object($result)) {
+    //remove the block when it is not in the list anymore
+    if (!isset($ad_slots[$block->delta])) {
+      $ret[] = update_sql("DELETE FROM {blocks} WHERE bid = %d", $block->bid);
+    }
+  }
+  
+  // Storing the variables, not sure whether this is already done by core
+  variable_set('google_admanager_ad_slots', trim($form_state['values']['google_admanager_ad_slots']));
+  variable_get('google_admanager_account', trim($form_state['values']['google_admanager_account']));
+}
+
+/**
  * Implemention of hook_theme()
  */ 
 function google_admanager_theme() {

