? array_wrap.patch
Index: uc_mailchimp.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_mailchimp/uc_mailchimp.module,v
retrieving revision 1.6.4.2
diff -u -p -r1.6.4.2 uc_mailchimp.module
--- uc_mailchimp.module	23 Feb 2010 11:02:00 -0000	1.6.4.2
+++ uc_mailchimp.module	23 Feb 2010 11:19:23 -0000
@@ -97,22 +97,26 @@ function uc_checkout_pane_mailchimp($op,
   switch ($op) {
   case 'view':
     $lists = _uc_mailchimp_call_api('lists');
-    foreach ($lists as $list) {
-      if (variable_get("uc_mailchimp_{$list['id']}_checkout_pane_enabled", 0)) {
-        $contents[$list['id']] = array(
-          '#type' => 'checkbox',
-          '#title' => t(variable_get("uc_mailchimp_{$list['id']}_checkout_pane_label", 'Subscribe To The '. $list['name'] .' Mailing List')),
-          '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_toggled", 1),
-        );
+    if (is_array($lists)) {
+      foreach ($lists as $list) {
+        if (variable_get("uc_mailchimp_{$list['id']}_checkout_pane_enabled", 0)) {
+          $contents[$list['id']] = array(
+            '#type' => 'checkbox',
+            '#title' => t(variable_get("uc_mailchimp_{$list['id']}_checkout_pane_label", 'Subscribe To The '. $list['name'] .' Mailing List')),
+            '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_toggled", 1),
+          );
+        }
       }
     }
     return array('description' => variable_get('uc_mailchimp_checkout_pane_desc', ''), 'contents' => $contents);
     break;
   case 'review':
     $lists = _uc_mailchimp_call_api('lists');
-    foreach ($arg1->uc_mailchimp as $list => $toggle) {
-      if ($toggle) {
-        $review[] = t(variable_get("uc_mailchimp_{$list}_checkout_pane_label", 'Subscribe To The '. $lists->$list['name'] .' Mailing List'));
+    if (is_array($arg1->uc_mailchimp)) {
+      foreach ($arg1->uc_mailchimp as $list => $toggle) {
+        if ($toggle) {
+          $review[] = t(variable_get("uc_mailchimp_{$list}_checkout_pane_label", 'Subscribe To The '. $lists->$list['name'] .' Mailing List'));
+        }
       }
     }
     return $review;
@@ -135,41 +139,43 @@ function uc_checkout_pane_mailchimp($op,
     );
 
     $lists = _uc_mailchimp_call_api('lists');
-    foreach ($lists as $list) {
-      $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"] = array(
-        '#type' => 'fieldset',
-        '#title' => t('@listname: List Settings', array('@listname' => $list['name'])),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-      );
-
-      $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list['id']}_checkout_pane_enabled"] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Enable this list on the Checkout Pane'),
-        '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_enabled", 0),
-        '#description' => t('Show a checkbox for subscribing to this list on the checkout pane.'),
-      );
-
-      $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list['id']}_checkout_pane_toggled"] = array(
-        '#type' => 'select',
-        '#title' => t('Default Value for subscription checkbox'),
-        '#options' => array(1 => t('Checked'), 0 => t('Unchecked')),
-        '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_toggled", 1),
-        '#description' => t('Show a checkbox for subscribing to this list on the checkout pane.'),
-      );
-
-      $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list['id']}_checkout_pane_label"] = array(
-        '#type' => 'textfield',
-        '#title' => t($list['name'] .' Checkbox label'),
-        '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_label", 'Subscribe To The '. $list['name'] .' Mailing List'),
-      );
-
-      $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list}_sub_message"] = array(
-        '#type' => 'textarea',
-        '#title' => t('Successful Subscription Message'),
-        '#default_value' => variable_get('uc_mailchimp_{$list}_sub_message', ''),
-        '#description' => t('Message displayed to users after checkout upon successfull subscription to list.')
-      );
+    if (is_array($lists)) {
+      foreach ($lists as $list) {
+        $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"] = array(
+          '#type' => 'fieldset',
+          '#title' => t('@listname: List Settings', array('@listname' => $list['name'])),
+          '#collapsible' => TRUE,
+          '#collapsed' => TRUE,
+        );
+
+        $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list['id']}_checkout_pane_enabled"] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Enable this list on the Checkout Pane'),
+          '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_enabled", 0),
+          '#description' => t('Show a checkbox for subscribing to this list on the checkout pane.'),
+        );
+
+        $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list['id']}_checkout_pane_toggled"] = array(
+          '#type' => 'select',
+          '#title' => t('Default Value for subscription checkbox'),
+          '#options' => array(1 => t('Checked'), 0 => t('Unchecked')),
+          '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_toggled", 1),
+          '#description' => t('Show a checkbox for subscribing to this list on the checkout pane.'),
+        );
+
+        $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list['id']}_checkout_pane_label"] = array(
+          '#type' => 'textfield',
+          '#title' => t($list['name'] .' Checkbox label'),
+          '#default_value' => variable_get("uc_mailchimp_{$list['id']}_checkout_pane_label", 'Subscribe To The '. $list['name'] .' Mailing List'),
+        );
+
+        $form['uc_mailchimp_cart']["uc_mailchimp_{$list['id']}"]["uc_mailchimp_{$list}_sub_message"] = array(
+          '#type' => 'textarea',
+          '#title' => t('Successful Subscription Message'),
+          '#default_value' => variable_get('uc_mailchimp_{$list}_sub_message', ''),
+          '#description' => t('Message displayed to users after checkout upon successfull subscription to list.')
+        );
+      }
     }
     return $form;
     break;
