Index: og2list.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/og2list/og2list.module,v
retrieving revision 1.105
diff -u -r1.105 og2list.module
--- og2list.module	5 Jan 2007 22:42:36 -0000	1.105
+++ og2list.module	6 May 2007 16:42:26 -0000
@@ -42,25 +42,31 @@
   $items = array();
 
   if ($may_cache) {
-//     $items[] = array('path' => 'admin/og2list',
-//                      'title' => t('og2list'),
-//                      'callback' => 'og2list_admin',
-//                      'access' => user_access('administer og2list'));
     $access = user_access('post comments');
     $items[] = array('path' => 'comment/edit',
       'title' => t('edit comment'),
       'callback' => 'og2list_comment_edit',
       'access' => $access,
       'type' => MENU_CALLBACK);
+    
+    $items[] = array(
+      'path' => 'admin/og/og2list',
+      'title' => t('Organic Groups List Manager'),
+      'description' => t('Configure Og2List settings'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => 'og2list_admin_settings',
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_NORMAL_ITEM, // optional
+    );
   }
   else {
     if (arg(0) == 'node' && is_numeric(arg(1))) {
       $node = node_load(arg(1));
       if (og_is_group_type($node->type) && isset($node->og2list_ml)) {
         $items[] = array('path' => 'node/'. arg(1). '/listmail',
-          'title' => t('mailing list'),
+          'title' => t('Mailing List'),
           'callback' => 'og2list_listmail',
-          'callback arguments' => array(arg(1)),
+          'callback arguments' => array($node),
           'access' => node_access('update', $node),
           'type' => MENU_LOCAL_TASK,
           'weight' => 7);
@@ -138,7 +144,7 @@
         }
       }
     }
-    if (module_exist('mailcommand')) {
+    if (module_exists('mailcommand')) {
       $result = db_query_range('SELECT c.* FROM {og2list_incoming_groups} g INNER JOIN {og2list_incoming_content} c ON g.mid = c.mid WHERE g.oid = 0 ORDER BY c.mid ASC', 0, 10);
       while ($mail = db_fetch_object($result)) {
         $status = mailcommand_process_mail($mail);
@@ -176,7 +182,7 @@
  * Implementation of hook_settings
  *
  */
-function og2list_settings() {
+function og2list_admin_settings() {
   $form['og2list_reserved_addresses'] = array(
     '#type' => 'textfield',
     '#title' => t('Reserved addresses'),
@@ -200,7 +206,7 @@
     '#options' => array('pre' => t('Before message'), 'post' => t('After message')),
     '#description' => t('Where adverts should be placed. To actually put adverts into your mail, you will need a module that implements the og2list_ad hook.'),
     );
-  return $form;
+  return system_settings_form($form);
 }
 
 /**
@@ -259,7 +265,7 @@
       $form['not_defined'] = array(
         '#type' => 'item',
         '#title' => t('Mail address'),
-        '#value' => message_na(),
+        '#value' => t('n/a'),
         '#description' => t('No mailing list has been created for this group.'),
         '#weight' => 2);
     }
@@ -285,7 +291,7 @@
        $groups = array_intersect($node->og_groups, array_keys($user->og_groups));
        foreach ($groups as $gid) {
          if ($user->og_groups[$gid]['is_admin'] == 1) {
-           $links[] = l(t('edit'), "comment/edit/$comment->cid");
+ 		   $links['og2list_comment_edit'] = array('title' => t('edit'), 'href' => 'comment/edit/'.$comment->cid);
            break;
          }
        }
@@ -351,8 +357,12 @@
       break;
     case 'insert':
       if (og_is_group_type($node->type)) {
-        if (isset($node->recipient) && strlen($node->recipient)) {
-          db_query("INSERT INTO {og2list_groups} (nid, recipient, status) VALUES (%d, '%s', 1)", $node->nid, $node->recipient);
+        if (isset($node->recipient) && strlen($node->recipient) && $node->nid) {
+         $count =  db_num_rows(db_query("SELECT nid FROM {og2list_groups} WHERE nid = %d",$node->nid));
+    	 if ($count && $count > 0) { // old row exists, delete it.
+    	 	db_query("DELETE FROM {og2list_groups} where nid = %d",$node->nid);	
+    	 }
+         db_query("INSERT INTO {og2list_groups} (nid, recipient, status) VALUES (%d, '%s', 1)", $node->nid, $node->recipient);
         }
       }
       else {
@@ -560,7 +570,7 @@
             // if a single list is moderated, it applies to all OGs.
             $node->status = 0;
           }
-          $node->taxonomy[] = og_forum_get_forum($oid);
+          $node->taxonomy[] = _og2list_og_forum_get_forum($oid);
         }
         // The first matching groups "owns" the post.
         $node->tid = $node->taxonomy[0];
@@ -1194,16 +1204,14 @@
  * @param $gid
  *   the nid of a group.
  */
-function og2list_listmail($gid) {
-  $node = node_load($gid);
+function og2list_listmail($node) {
   drupal_set_title(t('Mailing list options for %group', array('%group' => $node->title)));
 
-  return og2list_listmail_form($gid);
+  return drupal_get_form('og2list_listmail_form', $node);
 }
 
-function og2list_listmail_form($gid) {
+function og2list_listmail_form($node) {
   $edit = $_POST['edit'];
-  $node = node_load($gid);
   $count = db_result(db_query('SELECT COUNT(mid) FROM {og2list_outgoing_recipients} WHERE nid = %d AND status = %d', $node->nid, OG2LIST_OUTGOING_POSTPONED));
 
   $status = isset($edit['og2list_ml_status']) ? $edit['og2list_ml_status'] : (isset($node->og2list_ml_status) ? $node->og2list_ml_status : 0);
@@ -1254,14 +1262,14 @@
     '#default_value' => $node->og2list_subject_prefix,
     '#description' => t('Chose a string that will be put in front of the subject of all outgoing mails. The string will be stripped from incoming mails.'),
     );
-  $form['nid'] = array('#type' => 'hidden', '#value' => $gid);
+  $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
 
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Update settings'),
     );
 
-  return drupal_get_form('og2list_listmail_form', $form);
+  return $form;
 }
 
 function og2list_listmail_form_submit($form_id, $form_values) {
@@ -1454,3 +1462,18 @@
 
   return $output;
 }
+
+
+/* From Drupal 4.7 og_forum module.   This function is not present in the 5.x
+ * version of og_forum.
+ * 
+ * @param $group_id
+ *   Organic group ID
+ * @return
+ *   Forum's term ID
+ */
+function _og2list_og_forum_get_forum($group_id) {
+  // Grab most recent term created for group; this will be the forum as
+  // opposed to the forum container.
+  return db_result(db_query_range('SELECT tid FROM {og_term} WHERE nid = %d ORDER BY tid DESC', $group_id, 0, 1));
+}
Index: modules/og2list/og2list.info
===================================================================
RCS file: modules/og2list/og2list.info
diff -N modules/og2list/og2list.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/og2list/og2list.info	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,6 @@
+; $Id$
+name =  og2list
+description = Turns each Group Forum into a mailing list
+package = "Organic groups"
+dependencies = og og_forum
+version = "5.x-0.1"
