Index: openx.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openx/openx.admin.inc,v
retrieving revision 1.3.4.1
diff -u -r1.3.4.1 openx.admin.inc
--- openx.admin.inc	3 Jul 2009 01:52:07 -0000	1.3.4.1
+++ openx.admin.inc	11 Sep 2010 09:48:06 -0000
@@ -14,7 +14,7 @@
 /**
  * Module settings page form.
  */
-function _openx_settings() {
+function _openx_settings($form, &$form_state) {
   $form['blocks'] = array(
     '#description'  => t('<ul>
         <li>' . t('The zone ID can be found in the OpenX administration interface.') . '</li>
@@ -22,34 +22,58 @@
     </ul>'),
     '#title'        => t('OpenX blocks'),
     '#type'         => 'fieldset',
-  );
-  $zones_num = variable_get('openx_num_zones', 3);
-  $form['blocks']['openx_num_zones'] = array(
-    '#default_value'  => $zones_num,
-    '#description'    => t('How many OpenX zones (blocks) do you wish to display?'),
-    '#title'          => t('OpenX Zones'),
-    '#type'           => 'textfield',
-    '#size'           => 6,
+    '#prefix' => '<div id="zones-wrapper">',
+    '#suffix' => '</div>'
   );
 
   $form['blocks']['openx_zones'] = array(
     '#tree'         => TRUE,
     '#theme'        => 'openx_settings_zones',
   );
-  $zones = variable_get('openx_zones', array());
-  for ($index = 0; $index < $zones_num; $index++) {
+
+  if (empty($form_state['zones'])) {
+    $zones = variable_get('openx_zones', array());
+    if (empty($zones)) {
+      $form_state['zones'] = array_fill(0, 3, array('id' => '', 'name' => ''));
+    }
+    else {
+      $form_state['zones'] = $zones;
+    }
+  }
+
+  foreach ($form_state['zones'] as $index => $zone) {
+    $form['blocks']['openx_zones'][$index]['delete'] = array(
+      '#type' => 'submit',
+      '#value' => t('Delete'),
+      '#submit' => array('_openx_settings_delete_zone'),
+      '#ajax' => array(
+        'callback' => '_openx_settings_add_zone_callback',
+        'wrapper' => 'zones-wrapper',
+      ),
+      '#zone_id' => $index,
+      '#name' => 'delete-zone-' . $index,
+    );
     $form['blocks']['openx_zones'][$index]['id'] = array(
       '#type'           => 'textfield',
-      '#default_value'  => isset($zones[$index]['id']) ? $zones[$index]['id'] : '',
+      '#default_value'  => isset($form_state['zones'][$index]['id']) ? $form_state['zones'][$index]['id'] : '',
       '#size'           => 6,
     );
     $form['blocks']['openx_zones'][$index]['name'] = array(
       '#type'           => 'textfield',
-      '#default_value'  => isset($zones[$index]['name']) ? $zones[$index]['name'] : '',
-      '#size'           => 20,
+      '#default_value'  => isset($form_state['zones'][$index]['name']) ? $form_state['zones'][$index]['name'] : '',
     );
   }
 
+  $form['blocks']['add_zone'] = array(
+    '#type' => 'submit',
+    '#value' => t('Add zone'),
+    '#submit' => array('_openx_settings_add_zone'),
+    '#ajax' => array(
+      'callback' => '_openx_settings_add_zone_callback',
+      'wrapper' => 'zones-wrapper'
+    ),
+  );
+
   $form['adserver'] = array(
     '#collapsible'    => TRUE,
     '#collapsed'      => variable_get('openx_delivery_url', FALSE),
@@ -75,14 +99,32 @@
   return system_settings_form($form);
 }
 
+function _openx_settings_add_zone_callback($form, &$form_state) {
+  return $form['blocks'];
+}
+
+function _openx_settings_add_zone($form, &$form_state) {
+  $form_state['zones'][] = array('id' => '', 'name' => '');
+  $form_state['rebuild'] = TRUE;
+}
+
+function _openx_settings_delete_zone($form, &$form_state) {
+  unset($form_state['zones'][$form_state['clicked_button']['#zone_id']]);
+  if (count($form_state['zones']) < 3) {
+    $form_state['zones'][] = array('id' => '', 'name' => '');
+  }
+  $form_state['rebuild'] = TRUE;
+}
+
 /**
  * Theme the OpenX blocks list as a table
  */
-function theme_openx_settings_zones($form) {
-  $header = array(t('Index'), t('Zone ID'), t('Block name'));
+function theme_openx_settings_zones($variables) {
+  $form =& $variables['form'];
+  $header = array(t('Zone ID'), t('Block name'), '');
   foreach (element_children($form) as $zone) {
-    $rows[] = array($zone, drupal_render($form[$zone]['id']), drupal_render($form[$zone]['name']));
+    $rows[] = array(drupal_render($form[$zone]['id']), drupal_render($form[$zone]['name']), drupal_render($form[$zone]['delete']));
   }
 
-  return theme('table', $header, $rows);
+  return theme('table', array('header' => $header, 'rows' => $rows));
 }
Index: openx.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openx/openx.inc,v
retrieving revision 1.3.4.1
diff -u -r1.3.4.1 openx.inc
--- openx.inc	3 Jul 2009 01:52:07 -0000	1.3.4.1
+++ openx.inc	11 Sep 2010 09:48:06 -0000
@@ -33,7 +33,7 @@
   $url = $protocol . '://' . trim($server, '/') . '/spcjs.php';
 
   $zones = variable_get('openx_zones', array());
-  $spc_code = "<script type='text/javascript'><!--// <![CDATA[\n  var OA_zones = {\n";
+  $script = "  var OA_zones = {\n";
 
   $js_zones = array();
   foreach ($zones as $idx => $zone) {
@@ -41,10 +41,29 @@
       $js_zones[] = "    '" . $zone['name'] . "' : " . $zone['id'];
     }
   }
-  $spc_code .= implode(",\n", $js_zones);
-  $spc_code .= "  }\n// ]]> --></script>\n<script type='text/javascript' src='{$url}'></script>";
+  $script .= implode(",\n", $js_zones);
+  $script .= "\n  }";
 
-  drupal_add_html_head($spc_code);
+  $spc_code = array();
+  drupal_add_html_head(array(
+    '#type' => 'html_tag',
+    '#tag' => 'script',
+    '#attributes' => array(
+      'type' => 'text/javascript',
+    ),
+    '#value' => $script,
+    '#weight' => 1000,
+  ), 'openx_zones');
+  drupal_add_html_head(array(
+    '#type' => 'html_tag',
+    '#tag' => 'script',
+    '#attributes' => array(
+      'type' => 'text/javascript',
+      'src' => $url,
+    ),
+    '#value' => '',
+    '#weight' => 1001,
+  ), 'openx_script');
 }
 
 /**
Index: openx.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openx/openx.install,v
retrieving revision 1.3
diff -u -r1.3 openx.install
--- openx.install	11 Dec 2008 22:17:53 -0000	1.3
+++ openx.install	11 Sep 2010 09:48:06 -0000
@@ -12,12 +12,19 @@
  */
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  */
 function openx_uninstall() {
   // Delete global variables
   variable_del('openx_delivery_url');
   variable_del('openx_delivery_url_https');
-  variable_del('openx_num_zones');
   variable_del('openx_zone');
 }
+
+/**
+ * Remove unused variable.
+ */
+function openx_update_7000() {
+  variable_del('openx_num_zones');
+  return array();
+}
Index: openx.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/openx/openx.module,v
retrieving revision 1.5.4.1
diff -u -r1.5.4.1 openx.module
--- openx.module	3 Jul 2009 01:52:07 -0000	1.5.4.1
+++ openx.module	11 Sep 2010 09:48:06 -0000
@@ -12,18 +12,14 @@
  */
 
 /**
- * Implementation of hook_block_list().
+ * Implements hook_block_info().
  */
-function openx_block_list($delta = 0, $edit = array()) {
+function openx_block_info() {
   $zones = variable_get('openx_zones', array());
   foreach ($zones as $index => $zone) {
     if ($zone['id']) {
       $blocks[$index] = array(
         'info'    => t('OpenX Zone !id (!name)', array('!id' => $zone['id'], '!name' => (empty($zone['name']) ? t('untitled') : $zone['name']))),
-        'weight'  => 0,
-        'enabled' => 0,
-        'region'  => 'left',
-        'cache'   => BLOCK_NO_CACHE
       );
     }
   }
@@ -31,9 +27,9 @@
 }
 
 /**
- * Implementation of hook_block_view().
+ * Implements hook_block_view().
  */
-function openx_block_view($delta = 0, $edit = array()) {
+function openx_block_view($delta = '') {
   $block = array(
     'content' => openx_invoke($delta)
   );
@@ -41,7 +37,7 @@
 }
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function openx_help($section, $arg = NULL) {
   switch ($section) {
@@ -56,35 +52,37 @@
 }
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function openx_menu() {
-  $items['admin/settings/openx'] = array(
-    'access arguments'  => array('administer site configuration'),
-    'description'       => 'Configure OpenX AdServer integration behavior and appearance.',
-    'file'              => 'openx.admin.inc',
-    'page callback'     => 'drupal_get_form',
-    'page arguments'    => array('_openx_settings'),
-    'title'             => 'OpenX',
+  $items['admin/config/openx'] = array(
+    'title' => 'OpenX',
+    'position' => 'right',
+    'weight' => -10,
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('access administration pages'),
+    'file path' => drupal_get_path('module', 'system'),
+    'file' => 'system.admin.inc',
+  );
+  $items['admin/config/openx/settings'] = array(
+    'access arguments' => array('administer site configuration'),
+    'description' => 'Configure OpenX AdServer integration behavior and appearance.',
+    'file' => 'openx.admin.inc',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('_openx_settings'),
+    'title' => 'Settings',
   );
   return $items;
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function openx_theme() {
   return array(
     'openx_settings_zones' => array(
       'file'      => 'openx.admin.inc',
-      'arguments' => array('form')
-    ),
-    'openx_block' => array(
-      'file'      => 'openx.inc',
-      'arguments' => array('index')
-    ),
-    'openx_channel' => array(
-      'arguments' => array()
+      'render element' => 'form',
     ),
   );
 }
