Index: mailman_groups.module
===================================================================
--- mailman_groups.module	(Revision 3157)
+++ mailman_groups.module	(Arbeitskopie)
@@ -1,53 +1,33 @@
 <?php
 // $Id$
 
-/********************************************************
-
-Mailman Groups module for Drupal 6.x
-author: Andy Inman
-
-Commercial support is available from the author.
-contact: drupal(a)netgenius(d)co(d)uk
-
-*********************************************************/
-
-
-// --------- Debug support functions, can be removed when debug is finished ---------
-function _mailman_groups_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
-  return; ///////////////////////////////
-  //return drupal_set_message($message, $type, $repeat);
-}
-
-if (!function_exists('sprint_r')) {
-  function sprint_r($var) {
-    //return; ///////////////////////////////
-    ob_start();
-    print_r($var);
-    $ret = ob_get_contents();
-    ob_end_clean();
-    return $ret;
- }
-}
-// END --------- Debug support functions, can be removed when debug is finished ---------
-
+/**
+ * @file
+ * Mailman Groups module for Drupal 6.x
+ */
 
 // Check if a required function exists, display an error message if not.
 function _mailman_groups_checkfunc($func_name) {
-  if(is_callable($func_name))  return true;
+  if (is_callable($func_name)) {
+    return TRUE;
+  }
 
   $mod_name = 'Mailman Groups';
   $msg = sprintf(t('[%s] Required function %s() does not exist.'), $mod_name, $func_name);
   drupal_set_message($msg, 'error');
-  return false;
+  return FALSE;
 }
 
-// Process the groups/lists relationship data for all lists and return an array of lid=>true for all accessible lists
+/**
+ * Process the groups/lists relationship data for all lists and return an array
+ * of lid => TRUE for all accessible lists.
+ */
 function _mailman_groups_getlists() {
   $access = array();
 
   // Values used to check against the "hide" field.
-  $hide_by_member = is_callable('og_is_group_member')? 1 : 0;
-  $hide_by_domain = is_callable('og_abt_domain_group_in_domain')? 2 : 0;
+  $hide_by_member = is_callable('og_is_group_member') ? 1 : 0;
+  $hide_by_domain = is_callable('og_abt_domain_group_in_domain') ? 2 : 0;
 
   // Process group->list relationships...
   $result = db_query('SELECT * FROM {mailman_groups}');
@@ -55,27 +35,25 @@ function _mailman_groups_getlists() {
     // Extract ($gid, $lid, $hide)
     extract($link);
 
-    //$dbmsg = sprintf('Processing link gid[%d]/lid[%d]', $gid, $lid, sprint_r($link));
-    //_mailman_groups_set_message($dbmsg);
-
-    if ($access[$lid])
+    if ($access[$lid]) {
       continue;
-    elseif (!$hide)
-      $access[$lid] = true;
-    elseif ($hide == $hide_by_member  &&  og_is_group_member($gid))
-      $access[$lid] = true;
-    elseif ($hide == $hide_by_domain  &&  og_abt_domain_group_in_domain($gid))
-      $access[$lid] = true;
-    else {
-      //$dbmsg = sprintf('No access for gid[%d]/lid[%d] hide=%d (all=%d, include_admin=%d)', $gid, $lid, $hide, $all, $include_admin);
-      //_mailman_groups_set_message($dbmsg);
+    }
+    elseif (!$hide) {
+      $access[$lid] = TRUE;
+    }
+    elseif ($hide == $hide_by_member && og_is_group_member($gid)) {
+      $access[$lid] = TRUE;
+    }
+    elseif ($hide == $hide_by_domain && og_abt_domain_group_in_domain($gid)) {
+      $access[$lid] = TRUE;
     }
   }
   return $access;
 }
 
-
-// Get array of Mailing Lists (lid) for specified gid where 'sync' is set
+/**
+ * Get array of Mailing Lists (lid) for specified gid where 'sync' is set.
+ */
 function _mailman_groups_getsynclists($gid) {
   $lists = array();
 
@@ -88,24 +66,28 @@ function _mailman_groups_getsynclists($g
   return $lists;
 }
 
-// Get an array of all Groups (id and name).
-// This was not easy, based on scrutinizing OG module code.  It may not be the best approach!
-// Maybe better to call a higher-level function in OG module if there is one (I can't find it!)
-// To do: Options to get only groups (1) for which user is a member (2) for which user is owner.
+/**
+ * Get an array of all Groups (id and name).
+ *
+ * This was not easy, based on scrutinizing OG module code. It may not be the
+ * best approach! Maybe better to call a higher-level function in OG module if
+ * there is one (I can't find it!)
+ *
+ * @todo Options to get only groups (1) for which user is a member (2) for which user is owner.
+ */
 function _mailman_groups_get_groups() {
   $groups = array();
-  if (!_mailman_groups_checkfunc('og_is_group_type'))  return $groups;
+  if (!_mailman_groups_checkfunc('og_is_group_type')) {
+    return $groups;
+  }
 
   // Get a list of node types then test each one to see if it can be a Group.
   $node_types = node_get_types('names');
 
   // Loop through all node types, checking if it may define Groups...
-  foreach ($node_types as $type=>$name) {
+  foreach ($node_types as $type => $name) {
     $is_group = og_is_group_type($type);
 
-    //$dbmsg = sprintf('-> %s=>%s is %s group type', $type, $name, $is_group? '':'not');
-    //_mailman_groups_set_message($dbmsg);
-
     // If this node type is for Groups, fetch all nodes of this type, i.e. fetch Groups.
     if ($is_group) {
       $result = db_query("SELECT nid, title FROM {node} WHERE type = '$type'");
@@ -117,27 +99,29 @@ function _mailman_groups_get_groups() {
   return $groups;
 }
 
-// Integration with the og_abt_domain module...
-// Return an array of "domains" (taxonomy terms) for Group specified by $nid
-function _mailman_groups_domains($nid)  {
-
+/**
+ * Integration with the og_abt_domain module...
+ *
+ * Return an array of "domains" (taxonomy terms) for Group specified by $nid
+ */
+function _mailman_groups_domains($nid) {
   $domains = array();
-  
-  if (!is_callable('og_abt_domain_group_in_domain'))  return $domains;
-  if (!_mailman_groups_checkfunc('og_abt_domain_node_load'))  return $domains;
-  
+
+  if (!is_callable('og_abt_domain_group_in_domain')) {
+    return $domains;
+  }
+  if (!_mailman_groups_checkfunc('og_abt_domain_node_load')) {
+    return $domains;
+  }
+
   // Logic from og_abt_domain.module -- og_abt_domain_group_in_domain() function (line #65)
-  $vid = variable_get('og_abt_domain_vid', 0);
-  $node = og_abt_domain_node_load($nid);
+  $vid     = variable_get('og_abt_domain_vid', 0);
+  $node    = og_abt_domain_node_load($nid);
   $domains = taxonomy_node_get_terms_by_vocabulary($node, $vid);
   return $domains;
 }
 
-function _mailman_groups_update($lid, $gid, $hide = 1, $sync = 0)  {
-
-  //$dbmsg = sprintf('Update: %s->%s : %s', $lid, $gid, $sync);
-  //_mailman_groups_set_message($dbmsg);
-    
+function _mailman_groups_update($lid, $gid, $hide = 1, $sync = 0) {
   // Try to update the mailman_groups table.
   $query = 'UPDATE {mailman_groups} SET hide = %d, sync = %d WHERE lid = %d AND gid = %d';
   db_query($query, $hide, $sync, $lid, $gid);
@@ -145,214 +129,234 @@ function _mailman_groups_update($lid, $g
 
   // If no rows were updated, we need to add a new row.
   if ($rows == 0) {
-    //$dbmsg = sprintf('-->INSERT: %s->%s', $lid, $gid);
-    //_mailman_groups_set_message($dbmsg);
     $query = 'INSERT INTO {mailman_groups} (lid, gid, hide, sync) VALUES (%d, %d, %d, %d)';
     db_query($query, $lid, $gid, $hide, $sync);
   }
-  else {
-    //$dbmsg = sprintf('Done db update %s->%s, affected rows: %s, error: %s', $lid, $gid, $rows, db_error());
-    //_mailman_groups_set_message($dbmsg);
-  }
-  return;
 }
 
-// Delete an entry from the mailman_groups table.
-function _mailman_groups_unlink($lid, $gid)  {
+/**
+ * Delete an entry from the mailman_groups table.
+ */
+function _mailman_groups_unlink($lid, $gid) {
   $query = 'DELETE FROM {mailman_groups} WHERE lid = %d AND gid = %d';
   db_query($query, $lid, $gid);
-  //$rows = db_affected_rows();
-  return;
 }
 
-// Handle submits from the admin form....
-// When a new Linked Group is added.
-function _mailman_groups_submit_add($form, &$form_state)
-{
-  $lid = $form_state['values']['lid']; 
+/**
+ * Handle submits from the admin form when a new Linked Group is added.
+ */
+function _mailman_groups_submit_add($form, &$form_state) {
+  $lid  = $form_state['values']['lid'];
   $vars = &$form_state['values']['mailman_groups'];
-  $gid = $vars['gid'];
-  //$dbmsg = sprintf('*** Add lid:%d/gid:%d', $lid, $gid); _mailman_groups_set_message($dbmsg);
+  $gid  = $vars['gid'];
   _mailman_groups_update($lid, $gid);
 }
 
-// When a Linked Group is updated.  $n is an array index to the correct element.
-function _mailman_groups_submit_save($form, &$form_state, $n)
-{
-  $lid = $form_state['values']['lid']; 
-  $vars = &$form_state['values']['mailman_groups'][$n];
+/**
+ * When a Linked Group is updated.  $n is an array index to the correct element.
+ */
+function _mailman_groups_submit_save($form, &$form_state, $n) {
+  $lid   = $form_state['values']['lid'];
+  $vars  = &$form_state['values']['mailman_groups'][$n];
   $dbmsg = sprintf('gid: %d -- ', $gid) . sprint_r($vars);
   _mailman_groups_set_message($dbmsg);
   extract($vars);
-  $dbmsg = sprintf('*** Save lid:%d/gid:%d hide:%d sync:%d', $lid, $gid, $hide, $sync); _mailman_groups_set_message($dbmsg);
-  if ($unlink)
+  $dbmsg = sprintf('*** Save lid:%d/gid:%d hide:%d sync:%d', $lid, $gid, $hide, $sync);
+  _mailman_groups_set_message($dbmsg);
+  if ($unlink) {
     _mailman_groups_unlink($lid, $gid);
-  else
-    _mailman_groups_update($lid, $gid, $hide, $sync);
+  }
+  _mailman_groups_update($lid, $gid, $hide, $sync);
 }
 
-// Alter the Mailman Manager admin form - add a fieldset for 'Linked Groups' containing our form elements.
-// To do: Consider using our own form rather than modifying Mailman Manager's form.
-function _mailman_groups_alter_mailman_manager_admin_form(&$form, $form_state)  {
-  ////$dbmsg = 'mailing list admin form: ' . sprint_r($form);
-  ////_mailman_groups_set_message($dbmsg);
-
+/**
+ * Alter the Mailman Manager admin form - add a fieldset for 'Linked Groups'
+ * containing our form elements.
+ *
+ * @todo Consider using our own form rather than modifying Mailman Manager's form.
+ */
+function _mailman_groups_alter_mailman_manager_admin_form(&$form, $form_state) {
   // Create a fieldset for Linked Groups.
   $fset = &$form['mailman_groups'];
-  $fset = array('#title'=>t('Linked Groups'), '#type'=>'fieldset', '#collapsible'=>1, '#weight'=>0, '#tree'=>1);
+  $fset = array(
+    '#type' => 'fieldset',
+    '#title' => t('Linked Groups'),
+    '#collapsible' => TRUE,
+    '#weight' => 0,
+    '#tree' => TRUE,
+  );
 
   if (!$form['lid']) {
     // Adding a new List, can't do anything else right now.
     $desc = t('Linked Groups can be defined after this Mailing List has been added.');
-    $fset['text'] = array('#value'=>$desc);
+    $fset['text'] = array('#value' => $desc);
     return;
   }
-  
+
   // We have $form['lid'] so we are editing an existing List.
   $lid = $form['lid']['#value'];
 
   // Get array of all available groups (use it later to build a select-list.)
   $groups = _mailman_groups_get_groups();
 
-  //$dbmsg = sprint_r($groups); _mailman_groups_set_message($dbmsg);
-
   // Get (any) existing linked groups...
   $result = db_query("SELECT * FROM {mailman_groups} WHERE lid = $lid");
 
   $hide_opt[1] = t('Hidden if the User is not a member of the Group');
-  if (is_callable('og_abt_domain_group_in_domain'))
-  {
+  if (is_callable('og_abt_domain_group_in_domain')) {
     $hide_opt[2] = t('Hidden if the User does not have access to the Group due to domain-based restrictions');
   }
   $hide_opt[0] = t('Not hidden');
 
-  for($n = 0; $n < db_affected_rows(); $n++) {
+  for ($n = 0; $n < db_affected_rows(); $n++) {
     // Get $lid, $gid, $hide, $sync
     extract(db_fetch_array($result));
 
-    //$dbmsg = sprintf('group: %s, gid: %s', $gn, $gid);
-    //_mailman_groups_set_message($dbmsg);
-
     // Get the name of the Group.
     $group = t($groups[$gid]);
-    //$group = sprintf('%s [%d]', t($groups[$gid]), $gid);
     if (!$groups[$gid]) {
       // Looks like we found a link to a deleted Group, etc.
       $message = sprintf("Linked Group %d (gid: %d) was not found.", $n, $gid);
       drupal_set_message($message, 'warning');
-      $group = 'Group' . $gid;  
+      $group = 'Group'. $gid;
     }
 
     // Set up a fieldset for each linked Group...
     // Note: We must use #tree to keep the array structure in place for the #submit function.
     $gset = &$fset[$n];
-    $gset = array('#title'=>$group, '#type'=>'fieldset', '#collapsible'=>1, '#collapsed'=>1, '#tree'=>1);
+    $gset = array(
+      '#type' => 'fieldset',
+      '#title' => $group,
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#tree' => TRUE,
+    );
 
     // Store the $gid for later reference.
     $gset['gid'] = array('#type' => 'value', '#value' => $gid);
-    
+
     // Set checkbox for 'auto-subscribe'.
-    $title = t('Auto-subscribe');
-    $desc = t('If set, new members joining the Group will be automatically subscribed to this Mailing List.');
-    $gset['sync'] = array('#title'=>$title, '#description'=>$desc, '#type'=>'checkbox', '#default_value'=>$sync);
-    
+    $title        = t('Auto-subscribe');
+    $desc         = t('If set, new members joining the Group will be automatically subscribed to this Mailing List.');
+    $gset['sync'] = array(
+      '#type' => 'checkbox',
+      '#title' => $title,
+      '#description' => $desc,
+      '#default_value' => $sync,
+    );
+
     // Set radios for 'hide' options.
     $title = t('Mailing List visibility');
-    $gset['hide'] = array('#title'=>$title, '#type'=>'radios', '#default_value'=>$hide, '#options'=>$hide_opt);
+    $gset['hide'] = array('#title' => $title, '#type' => 'radios', '#default_value' => $hide, '#options' => $hide_opt);
 
     $title = t('Unlink this Group');
-    $gset['unlink'] = array('#title'=>$title, '#type'=>'checkbox');
+    $gset['unlink'] = array('#title' => $title, '#type' => 'checkbox');
 
     // Create a function to handle form submit.
-    $func = '_mailman_groups_submit_save';  $args = '$form, $form_state';
+    $func    = '_mailman_groups_submit_save';
+    $args    = '$form, $form_state';
     $subfunc = create_function($args, sprintf('return %s(%s, %d);', $func, $args, $n));
 
-    // NOTE: Due to an apparent Drupal FormAPI limitation (bug?), submit buttons need a unique #value otherwise the #submit value is "shared" among all buttons which have the same #value.
-    $title = $n? sprintf('%s [%d]', t('Save'), $n) : t('Save');
-    $gset['save'.$n] = array('#type'=>'submit', '#value'=>$title, '#submit'=>array($subfunc));
+    // NOTE: Due to an apparent Drupal FormAPI limitation (bug?), submit buttons
+    // need a unique #value otherwise the #submit value is "shared" among all
+    // buttons which have the same #value.
+    $title = $n ? sprintf('%s [%d]', t('Save'), $n) : t('Save');
+    $gset['save'. $n] = array('#type' => 'submit', '#value' => $title, '#submit' => array($subfunc));
 
     // Remove this Group from the list of Groups that can be added as links.
     unset($groups[$gid]);
   }
-  
-  // If there are groups which are not currently linked we can add them, so show the select list...
-  if(count($groups)) {
-    //$groups[0] = sprintf('(%s)', t('none'));
+
+  // If there are groups which are not currently linked we can add them, so show
+  // the select list...
+  if (count($groups)) {
     asort($groups);
 
-    //$title = t('Add Linked Group');
     $desc = t('Select a Group to link to this Mailing List.');
-    $fset['gid'] = array('#description'=>$desc, '#type'=>'select', '#options'=>$groups);
-    
+    $fset['gid'] = array('#description' => $desc, '#type' => 'select', '#options' => $groups);
+
     $title = t('Add Linked Group');
-    $fset['add_group'] = array('#type'=>'submit', '#value'=>$title, '#submit'=>array('_mailman_groups_submit_add'));
+    $fset['add_group'] = array('#type' => 'submit', '#value' => $title, '#submit' => array('_mailman_groups_submit_add'));
   }
   else {
     $msg = sprintf('(%s.)', t('There are no more Groups available to link to'));
-    $fset['msg'] = array('#value'=>$msg);
+    $fset['msg'] = array('#value' => $msg);
   }
 }
 
-// Trap the event of a user joining a Group, and subscribe to all linked Mailing Lists which have "sync" set.
-// NB: Subscribe is done as 'digest' - to do: make configurable.
-// To do: Investigate and consider using OG Hooks or "Actions".
-function _mailman_groups_alter_og_confirm_subscribe(&$form, $form_state)  {
+/**
+ * Trap the event of a user joining a Group, and subscribe to all linked
+ * Mailing Lists which have "sync" set.
+ *
+ * NB: Subscribe is done as 'digest' - to do: make configurable.
+ *
+ * @todo Investigate and consider using OG Hooks or "Actions".
+ */
+function _mailman_groups_alter_og_confirm_subscribe(&$form, $form_state) {
   // If the form is being posted, do our update.
   $post = $form_state['post'];
-  if ($post['confirm'])  { 
-
+  if ($post['confirm']) {
     // Get gid from the form and array of "sync" Lists for this gid.
     $gid = $form['gid']['#value'];
     $lists = _mailman_groups_getsynclists($gid);
 
-    //$dbmsg = sprintf('#Synced lists: %s', count($lists));
-    //_mailman_groups_set_message($dbmsg);
-
     // Loop through lists.
-    foreach($lists as $n=>$lid) {
+    foreach ($lists as $n => $lid) {
       global $user;
       // Need to get the corresponding list object and convert to array.
-      if (!_mailman_groups_checkfunc('mailman_manager_get_list'))  return;
+      if (!_mailman_groups_checkfunc('mailman_manager_get_list')) {
+        return;
+      }
       $list = get_object_vars(mailman_manager_get_list($lid));
       $msg = sprintf('Subscribing your email address %s to Group Mailing List <em>%s</em>.', $user->mail, $list['name']);
       drupal_set_message($msg);
 
       // Do the subscribe via User Mailman Register if available, otherwise use Mailman Manager function.
-      if (is_callable('_user_mailman_register_subscribe_update'))
-      {
-        _user_mailman_register_subscribe_update($user, $list, 3, 0, $user->mail, null);
+      if (is_callable('_user_mailman_register_subscribe_update')) {
+        _user_mailman_register_subscribe_update($user, $list, 3, 0, $user->mail, NULL);
       }
-      else
-      {
-        if (!_mailman_groups_checkfunc('_mailman_manager_subscribe'))  return;
+      else {
+        if (!_mailman_groups_checkfunc('_mailman_manager_subscribe')) {
+          return;
+        }
         _mailman_manager_subscribe($user, $lid, $user->mail, 'nodigest', '');
       }
-      //$dbmsg = sprintf('Autojoin list %s:%s, User: %s, mail: %s', $lid, $list['name'], $user->uid, $user->mail);
-      //_mailman_groups_set_message($dbmsg);
     }
-
-    //$dbmsg = sprintf('Confirmed join Group, gid: %s', $gid);
-    //_mailman_groups_set_message($dbmsg);
   }
 }
 
-// Check if current user is a member of the Group linked to list $lid
-// Because this may get called repeatedly for many lists, we cache the result on the first call.
+/**
+ * Check if current user is a member of the Group linked to list $lid.
+ *
+ * Because this may get called repeatedly for many lists, we cache the result
+ * on the first call.
+ */
 function _mailman_groups_access($lid) {
   static $list_access;
-  if (!isset($list_access)) $list_access = _mailman_groups_getlists();
+  if (!isset($list_access)) {
+    $list_access = _mailman_groups_getlists();
+  }
   return isset($list_access[$lid]);
 }
 
-// This gets called from _mailman_groups_alter_user_profile_form() via array_walk() for each element of the form.
-// Here we remove the fieldsets for any lists which should be hidden from this user.
-// If we return without modifying the form element, nothing changes.
+/**
+ * This gets called from _mailman_groups_alter_user_profile_form() via
+ * array_walk() for each element of the form. Here we remove the fieldsets
+ * for any lists which should be hidden from this user. If we return without
+ * modifying the form element, nothing changes.
+ *
+ * @see _mailman_groups_alter_user_profile_form()
+ */
 function _mailman_groups_hide_list_fieldset(&$element, $key) {
   // Pre-checks to make sure we're sane...
   // element should be of #type fieldset - mailman_manager.module line #127.
-  if ($element['#type'] != 'fieldset')  return;
+  if ($element['#type'] != 'fieldset') {
+    return;
+  }
   // key is expected to be in the format 'list'. trim($list['lid'] - mailman_manager.module line #126.
-  if (substr($key, 0, 4) != 'list')  return;
+  if (substr($key, 0, 4) != 'list') {
+    return;
+  }
 
   // Extract the lid value from $key.
   $lid = substr($key, 4);
@@ -360,64 +364,78 @@ function _mailman_groups_hide_list_field
 
   // Special case - if user is already subscribed, always keep the List visible (otherwise user can't unsubscribe easily!)
   global $user;
-  if (!_mailman_groups_checkfunc('_mailman_manager_get_subscriptions'))  return;
+  if (!_mailman_groups_checkfunc('_mailman_manager_get_subscriptions')) {
+    return;
+  }
   $sub = _mailman_manager_get_subscriptions($user->uid, $lid);
-  if ($sub['lstatus'] != 0) return;
-  
+  if ($sub['lstatus'] != 0) {
+    return;
+  }
+
   // Check if access is allowed via linked groups (membership and domain rules.)
-  if (_mailman_groups_access($lid)) return; 
+  if (_mailman_groups_access($lid)) {
+    return;
+  }
 
-  // If we get this far, none of the conditions which could allow access to this List have been met, so remove it from the form.
-  $element = null;
+  // If we get this far, none of the conditions which could allow access to this
+  // List have been met, so remove it from the form.
+  $element = NULL;
 }
 
-// Alter the user profile form. We need to deal with both the Mailing Lists" tab created by Mailman Manager and the "Mailing Lists register" tab created by User Mailman Register 
-// To do: This functionality would be better provided by direct communication with those modules, but that will require them to be updated accordingly. 
-function _mailman_groups_alter_user_profile_form(&$form, $form_state)  {
+/**
+ * Alter the user profile form. We need to deal with both the Mailing Lists" tab
+ * created by Mailman Manager and the "Mailing Lists register" tab created by
+ * User Mailman Register.
+ *
+ * @todo This functionality would be better provided by direct communication
+ * with those modules, but that will require them to be updated accordingly.
+ */
+function _mailman_groups_alter_user_profile_form(&$form, $form_state) {
   // This id is used by Mailman Manager (line #119).
   $mmid = 'mman';
   // This id is used by User Mailman Register.
   $umr = 'user_mailman_register';
   // See if we're dealing with one of the tabs we need to process, otherwise exit.
-  if (isset($form[$mmid]))  {
+  if (isset($form[$mmid])) {
     $element = &$form[$mmid];
-    // Remove the message shown by Mailman Manager (lines #175-182), e.g. 'Your current email address is not subscribed to 6 list(s).'
-    $form['lists']['subinfo']['#value'] = null;
+    // Remove the message shown by Mailman Manager (lines #175-182), e.g. 'Your
+    // current email address is not subscribed to 6 list(s).'
+    $form['lists']['subinfo']['#value'] = NULL;
   }
-  elseif (isset($form[$umr]))
+  elseif (isset($form[$umr])) {
     $element = &$form[$umr]['lists'];
-  else
+  }
+  else {
     return;
-
-  //$dbmsg = sprintf('element: %s', sprint_r($element));
-  //_mailman_groups_set_message($dbmsg);
+  }
 
   // Walk the array, disabling the fieldsets for lists which should not be visible.
   array_walk($element, '_mailman_groups_hide_list_fieldset');
 }
 
-// The User Registration form will show any Lists set for "anonymous" access, so we need to process that form too.
-function _mailman_groups_alter_user_register(&$form, $form_state)  {
-  return _mailman_groups_alter_user_profile_form(&$form, $form_state);
+/**
+ * The User Registration form will show any Lists set for "anonymous" access, so
+ * we need to process that form too.
+ */
+function _mailman_groups_alter_user_register(&$form, $form_state) {
+  return _mailman_groups_alter_user_profile_form($form, $form_state);
 }
 
-
-// Implement hook_form_alter to process several forms.
+/**
+ * Implement hook_form_alter to process several forms.
+ */
 function mailman_groups_form_alter(&$form, $form_state, $form_id) {
-  //$dbmsg = sprintf('form_alter, id: %s --- form: %s', $form_id, sprint_r($form));
-  //_mailman_groups_set_message($dbmsg);
-  ////$dbmsg = sprintf('form_alter %s', sprint_r($form_state));
-  ////_mailman_groups_set_message($dbmsg);
-
   // Define an array of form_ids for forms we want to modify.
   $forms = array('user_profile_form', 'user_register', 'mailman_manager_admin_form', 'og_confirm_subscribe');
   // If this is not one of the forms we want to process, quick exit.
-  if (!in_array($form_id, $forms))  return;
+  if (!in_array($form_id, $forms)) {
+    return;
+  }
 
   // Call the matching form alter function.
-  $alter = '_mailman_groups_alter_' . $form_id;
-  if (_mailman_groups_checkfunc($alter))  $alter($form, $form_state);
-  return;
+  $alter = '_mailman_groups_alter_'. $form_id;
+  if (_mailman_groups_checkfunc($alter)) {
+    $alter($form, $form_state);
+  }
 }
 
-// --- End --- Drupal docs advise NOT closing the PHP tags.
Index: mailman_groups.install
===================================================================
--- mailman_groups.install	(Revision 3157)
+++ mailman_groups.install	(Arbeitskopie)
@@ -11,7 +11,7 @@ function mailman_groups_schema() {
     // hide == 2 -- Hidden unless user has domain-based access to linked Group.
     'fields' => array('lid' => $uint, 'gid' => $uint, 'hide' => $uint, 'sync' => $uint),
     'primary key' => array('lid', 'gid'),
-    );
+  );
 
   return $schema;
 }
@@ -57,3 +57,4 @@ function mailman_groups_install() {
 function mailman_groups_update_1() {
 }
 */
+
