--- ezmlm.module.old	2007-12-29 15:59:07.000000000 +0000
+++ ezmlm.module	2008-12-10 12:28:23.000000000 +0000
@@ -11,6 +11,64 @@
  */
 
 /**
+ * Implementation of hook_user().
+ * by mjs2020
+ * this adds the ability to subscribe to mailing lists
+ * during the registration process.
+ */
+function ezmlm_user($op, &$edit, &$account, $category = NULL) {
+  switch($op) {
+    case 'register':
+      if ( variable_get('ezmlm_register', 0) && variable_get('ezmlm_register_list', 0) ) {
+        $listsform = ezmlm_subscribe_form('REG');
+        unset($listsform['ezmlm_email'], $listsform['submit'], $listsform['subscribe'] );
+
+        $form['ezmlm'] = array(
+          "#type" => "fieldset",
+          "#title" => t("Mailing lists"),
+          "#description" => t("Please select the mailing lists you would like to subscribe to."),
+          '#collapsible' => FALSE,
+          "#tree" => FALSE,
+          "#parents" => array("ezmlm"),
+        );
+        $form['ezmlm']['ezmlm_subscribe'] = array();
+        foreach($listsform['ezmlm_subscribe'] as $key=>$ezmlm_list) {
+          $ezmlm_list['#parents'][0] = $key;
+          $ezmlm_list['#name'] = $key;
+          $form['ezmlm']['ezmlm_subscribe'][$key] = $ezmlm_list;
+        }
+        return $form;
+      }
+      break;
+    case 'insert':
+      if ( variable_get('ezmlm_register', 0) && variable_get('ezmlm_register_list', 0) ) {
+        $lists = _ezmlm_get_lists('REG');
+        $listct = _ezmlm_get_count('REG');
+        $arr = array();
+        // get the selected mailing list addresses
+        for($ct=1; $ct <= $listct; $ct++) {
+          if (isset($edit["ezmlm_list_$ct"])) {
+            $address = $edit["ezmlm_list_$ct"];
+            if ($address && in_array($address, $lists)) {
+              $arr[] = $address;
+            }
+          }
+        }
+        $email = trim($edit['mail']);
+        $ret = _ezmlm_subscribe_process($arr, $email);
+        if (is_array($ret)) {
+          $output = (t('Please check your mail at %mail to confirm registration of:', array('%mail' => $email)));
+          drupal_set_message($output ."<br>". implode('<br>', $ret));
+        }
+        else {
+          drupal_set_message($ret, 'error');
+        }
+      }
+      break;
+  }
+}
+
+/**
  * Implementation of hook_help().
  */
 function ezmlm_help($path, $arg) {
@@ -43,21 +101,21 @@
  */
 function ezmlm_menu() {
   $items['ezmlm/add'] = array(
-    'title' => ('mailing lists'),
+    'title' => 'Mailing lists',
     'page callback' => 'ezmlm_block',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
   $items['ezmlm'] = array(
-    'title' => ('Mailing lists'),
+    'title' => 'Mailing lists',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('ezmlm_subscribe_form'),
     'access arguments' => array('access content'),
     'type' => MENU_NORMAL_ITEM,
   );
   $items['admin/settings/ezmlm'] = array(
-    'title' => t('Ezmlm lists'),
-    'description' => t('Ezmlm mailing lists management.'),
+    'title' => 'Ezmlm lists',
+    'description' => 'Ezmlm mailing lists management.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('ezmlm_admin_settings'),
     'access arguments' => array('administer ezmlm'),
@@ -83,7 +141,7 @@
         switch ($delta) {
           case 0:
             $block = "";
-            if (strlen(trim(variable_get('ezmlmmailinglists', '')))) {
+            if (drupal_strlen(trim(variable_get('ezmlmmailinglists', '')))) {
               $block['subject'] = variable_get('ezmlm_block_title', t('Subscriptions'));
               $block['content'] .= _ezmlm_page();
             }
@@ -103,11 +161,11 @@
  * @return
  *  HTML form.
  */
-function ezmlm_subscribe_form() {
+function ezmlm_subscribe_form($type='DEFAULT') {
   global $user;
 
-  if (_ezmlm_get_count()) {
-    $lists = _ezmlm_get_lists();
+  if (_ezmlm_get_count($type)) {
+    $lists = _ezmlm_get_lists($type);
     $form['subscribe'] = array(
       '#type' => 'markup',
       '#value' => variable_get('ezmlm_title', t('Mailing lists')),
@@ -149,7 +207,7 @@
   $arr = array();
   $lists = _ezmlm_get_lists();
   $ct = 1;
-  foreach ($form_state['values'] as $key=>$address) {
+  foreach ($form_state['values'] AS $key => $address) {
     $address = trim($address);
     if( $key == "ezmlm_list_$ct" && $address && in_array($address, $lists)) {
        $arr[] = $address;
@@ -183,7 +241,7 @@
   $ret = _ezmlm_subscribe_process($arr, $email);
   if ( is_array($ret)) {
     $output = (t('Please check your mail at %mail to confirm registration of:', array('%mail' => $email)));
-    drupal_set_message($output . "<br>" . implode('<br>', $ret));
+    drupal_set_message($output ."<br />". implode('<br />', $ret));
   }
   else {
     drupal_set_message($ret, 'error');
@@ -230,8 +287,8 @@
  * Return current number of lists.
  * Use this instead of count(_ezmlm_get_lists()) because non-array counts as 1.
  */
-function _ezmlm_get_count() {
-  $lists = _ezmlm_get_lists();
+function _ezmlm_get_count($type='DEFAULT') {
+  $lists = _ezmlm_get_lists($type);
   if (!is_array($lists)) {
     return 0;
   }
@@ -243,6 +300,11 @@
 /**
  * Return array of current mailing lists.
  */
-function _ezmlm_get_lists() {
+function _ezmlm_get_lists($type='DEFAULT') {
+  if ($type=='DEFAULT') {
   return variable_get('ezmlmmailinglists', '');
 }
+  elseif ($type=='REG') {
+    return variable_get('ezmlm_register_list', '');
+  }
+}
--- ezmlm.admin.inc.old	2008-04-06 00:44:39.000000000 +0100
+++ ezmlm.admin.inc	2008-12-10 12:26:13.000000000 +0000
@@ -3,7 +3,10 @@
 // $Name: DRUPAL-6--1-0 $
 // for drupal 6.x
 
-
+/**
+ * @file
+ * administration functions for ezmlm
+ */
 
 /**
  * Menu callback; presents the settings form for ezmlm
@@ -50,7 +53,31 @@
         );
       }
     }
+
+    // registration
+    $form['ezmlm_reg'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Registration settings'),
+      '#description' => t('Allow new users to select mailing lists on registration'),
+      '#collapsible' => TRUE,
+    );
+    $form['ezmlm_reg']['ezmlm_register'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Display lists in registration form'),
+      '#default_value' => variable_get('ezmlm_register', 1),
+    );
+    if (is_array($lists)) {
+      $reglist = variable_get('ezmlm_register_list', '');
+      foreach ($lists as $list_text => $list_email) {
+        $form['ezmlm_reg']["reg_$list_text"] = array(
+          '#type' => 'checkbox',
+          '#title' => "$list_text ($list_email)" ,
+          '#default_value' => ((is_array($reglist) && in_array($list_email, $reglist)) ? 1 : 0),
+        );
+      }
+    }
   }
+
   $form['ezmlm_misc'] = array(
       '#type' => 'fieldset',
       '#title' => t('Various settings'),
@@ -85,11 +112,11 @@
  */
 function ezmlm_admin_settings_validate($form, &$form_state) {
 
-  if (strlen($form_state['values']['ezmlm_add_address'])) {
+  if (drupal_strlen($form_state['values']['ezmlm_add_address'])) {
     if ($error = user_validate_mail($form_state['values']['ezmlm_add_address'])) {
       form_set_error('ezmlm_add_address', $error);
     }
-    if (! strlen($form_state['values']['ezmlm_add_name'])) {
+    if (! drupal_strlen($form_state['values']['ezmlm_add_name'])) {
       form_set_error('ezmlm_add_name', t('You must fill in the Name field'));
     }
   }
@@ -128,15 +155,40 @@
   }
   // add list
   $lists = _ezmlm_get_lists();
-  if (!is_array($lists) || count($lists) < 1 ) {
+  $count = _ezmlm_get_count();
+  if (!is_array($lists) || $count < 1 ) {
     $lists = array();
     variable_del('ezmlmmailinglists');
   }
   $list_text = trim($form_state['values']['ezmlm_add_name']);
   $list_email = trim($form_state['values']['ezmlm_add_address']);
-  if (strlen($list_text) && strlen($list_email) ) {
+  if (drupal_strlen($list_text) && drupal_strlen($list_email) ) {
     $lists[$list_text] = $list_email;
     variable_set('ezmlmmailinglists', $lists);
     drupal_set_message( t('The mailing lists have been saved.'));
   }
+
+  // registration
+  if ($form_state['values']['ezmlm_register']) {
+    variable_set('ezmlm_register', 1);
+  }
+  else {
+    variable_set('ezmlm_register', 0);
+  }
+
+  if ( variable_get('ezmlm_register', 0) ) {
+    // reg list
+    if (is_array($lists) && $count > 0) {
+      variable_del('ezmlm_register_list');
+      $arr = array();
+      foreach ($lists as $list_text => $list_email) {
+        if ( isset($form_state['values']["reg_$list_text"]) && $form_state['values']["reg_$list_text"] == 1 ) {
+          $arr[$list_text] = $list_email;
+        }
+      }
+      if ( count($arr) ) {
+        variable_set('ezmlm_register_list', $arr);
+      }
+    }
+  }
 }
