Index: og2list.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og2list/og2list.module,v
retrieving revision 1.104
diff -u -p -r1.104 og2list.module
--- og2list.module	16 Nov 2006 11:13:08 -0000	1.104
+++ og2list.module	15 Mar 2007 18:56:21 -0000
@@ -38,7 +38,6 @@ function og2list_perm() {
  * Implementation of hook_menu.
  */
 function og2list_menu($may_cache) {
-
   $items = array();
 
   if ($may_cache) {
@@ -46,21 +45,31 @@ function og2list_menu($may_cache) {
 //                      '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);
@@ -85,8 +94,8 @@ function og2list_menu($may_cache) {
       }
     }
   }
-
   return $items;
+
 }
 
 
@@ -132,13 +141,14 @@ function og2list_cron() {
       if (count($mail->og_nids)) {
         $status = og2list_process_mail($mail);
         if ($status) {
+          db_query('INSERT INTO {og2list_incoming_backup} SELECT * FROM {og2list_incoming_content} WHERE mid = %d', $mail->mid); // my backup hack
           db_query('DELETE FROM {og2list_incoming_content} WHERE mid = %d', $mail->mid);
           db_query('DELETE FROM {og2list_incoming_groups} WHERE mid = %d', $mail->mid);
           db_query('DELETE FROM {og2list_attachment} WHERE mid = %d', $mail->mid);
         }
       }
     }
-    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 +186,7 @@ function og2list_lockfile() {
  * Implementation of hook_settings
  *
  */
-function og2list_settings() {
+function og2list_admin_settings() {
   $form['og2list_reserved_addresses'] = array(
     '#type' => 'textfield',
     '#title' => t('Reserved addresses'),
@@ -200,7 +210,7 @@ function og2list_settings() {
     '#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);
 }
 
 /**
@@ -252,6 +262,11 @@ function og2list_form_alter($form_id, &$
         '#options' => array(0 => t('web only'), 1 => t('individual mail'), OG2LIST_OUTGOING_DIGEST => t('digest')),
         '#description' => t('Do you want to receive mails from this group? You can chose between one mail per post or receive them batched once per day.'),
         '#weight' => 1);
+      if (!defined($form['op'])) {
+        // cover for og.module's hiding submit button if someone's got "always" or "never" set for subscription messages
+        // this needs to be refactored to a more sane workflow, in concert w/moshe most likely
+        $form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
+      }
       $form['op']['#weight'] = 10;
     }
     else {
@@ -259,7 +274,7 @@ function og2list_form_alter($form_id, &$
       $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 +300,7 @@ function og2list_link($type, $node = 0, 
        $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;
          }
        }
@@ -348,8 +363,8 @@ function og2list_nodeapi(&$node, $op, $a
           form_set_error('recipient', t('The chosen address is reserved.'));
         }
       }
-      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 > 0) {
+//          db_query("INSERT INTO {og2list_groups} (nid, recipient, status) VALUES (%d, '%s', 1)", $node->nid, $node->recipient);
       }
       break;
     case 'insert':
@@ -1197,16 +1212,13 @@ function og2list_test_cron() {
  * @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);
@@ -1257,14 +1269,14 @@ function og2list_listmail_form($gid) {
     '#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) {
