? log_modr8_1.diff
? log_modr8_2.diff
Index: modr8.install
===================================================================
RCS file: modr8.install
diff -N modr8.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modr8.install	13 Jan 2007 03:12:36 -0000
@@ -0,0 +1,95 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_install().
+ */
+function modr8_install() {
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      db_query("CREATE TABLE {modr8_log} (
+        modid int NOT NULL auto_increment,
+        nid int unsigned NOT NULL default '0',
+        uid int NOT NULL default '0',
+        author_uid int NOT NULL default '0',
+        action varchar(16) NOT NULL default '',
+        title varchar(128) NOT NULL default '',
+        message longtext NOT NULL,
+        teaser longtext NOT NULL,
+        timestamp int NOT NULL default '0',
+        PRIMARY KEY (modid),
+        KEY nid_time (nid, timestamp),
+        KEY action (action)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+      break;
+    case 'pgsql':
+      db_query("CREATE TABLE {modr8_log} (
+        modid serial,
+        nid int_unsigned NOT NULL default '0',
+        uid int NOT NULL default '0',
+        author_uid int NOT NULL default '0',
+        action varchar(16) NOT NULL default '',
+        title varchar(128) NOT NULL default '',
+        message text NOT NULL,
+        teaser text NOT NULL,
+        timestamp int NOT NULL default '0',
+        PRIMARY KEY (modid)
+      )");
+      db_query("CREATE INDEX {modr8_log}_nid_time ON {modr8_log} (nid, timestamp)");
+      db_query("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)");
+      break;
+  }
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function modr8_uninstall() {
+  db_query('DROP TABLE {modr8_log}');
+}
+
+
+/**
+ * Update table definitions.
+ */
+function modr8_update_1000() {
+  $ret = array();
+
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql("CREATE TABLE {modr8_log} (
+        modid int NOT NULL auto_increment,
+        nid int unsigned NOT NULL default '0',
+        uid int NOT NULL default '0',
+        author_uid int NOT NULL default '0',
+        action varchar(16) NOT NULL default '',
+        title varchar(128) NOT NULL default '',
+        message longtext NOT NULL,
+        teaser longtext NOT NULL,
+        timestamp int NOT NULL default '0',
+        PRIMARY KEY (modid),
+        KEY nid_time (nid, timestamp),
+        KEY action (action)
+      ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+      break;
+    case 'pgsql':
+      $ret[] = update_sql("CREATE TABLE {modr8_log} (
+        modid serial,
+        nid int_unsigned NOT NULL default '0',
+        uid int NOT NULL default '0',
+        author_uid int NOT NULL default '0',
+        action varchar(16) NOT NULL default '',
+        title varchar(128) NOT NULL default '',
+        message text NOT NULL,
+        teaser text NOT NULL,
+        timestamp int NOT NULL default '0',
+        PRIMARY KEY (modid)
+      )");
+      $ret[] = update_sql("CREATE INDEX {modr8_log}_nid_time ON {modr8_log} (nid, timestamp)");
+      $ret[] = update_sql("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)");
+      break;
+  }
+  return $ret;
+}
Index: modr8_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8_admin.inc,v
retrieving revision 1.7
diff -u -p -r1.7 modr8_admin.inc
--- modr8_admin.inc	6 Jan 2007 18:10:08 -0000	1.7
+++ modr8_admin.inc	13 Jan 2007 03:12:36 -0000
@@ -126,8 +126,12 @@ function modr8_form($result = NULL) {
       );
     }
     $form[$node->nid]['preview'] = array(
-      '#type' => 'markup',
-      '#value' => $teaser
+      '#type' => 'value',
+      '#value' => $teaser,
+    );
+    $form[$node->nid]['author_uid'] = array(
+      '#type' => 'value',
+      '#value' => $node->uid,
     );
     $form[$node->nid]['title'] = array(
       '#type' => 'value',
@@ -167,7 +171,7 @@ function theme_modr8_form(&$form) {
         'style' => 'vertical-align:top;'
       );
       $row[] = array(
-        'data' => drupal_render($form[$key]['preview']),
+        'data' => $form[$key]['preview']['#value'],
         'style' => 'vertical-align:top;',
       );
       $rows[] = $row;
@@ -184,30 +188,41 @@ function theme_modr8_form(&$form) {
  */
 function modr8_form_submit($form_id, $form_values) {
   foreach ($form_values as $nid => $values) {
+    $message = '';   
     switch ($values['ops']) {
       case 'approve':
         if(variable_get('modr8_send_approve', FALSE)){
-          modr8_usermail('approve', $nid, $values);
+          $message = modr8_usermail('approve', $nid, $values);
         }
         db_query('UPDATE {node} SET moderate = 0 WHERE nid = %d', $nid);
         drupal_set_message(t('The %type with title %title has been approved.', array('%title' => $values['title'], '%type' => $values['type'])));
         cache_clear_all();
+        modr8_log_action('approve', $nid, $values, $message);
         break;
       case 'delete':
         if(variable_get('modr8_send_deny', FALSE)){
-          modr8_usermail('deny', $nid, $values);
+          $message = modr8_usermail('deny', $nid, $values);
         }
         node_delete($nid);
         // drupal does its own message
+        modr8_log_action('delete', $nid, $values, $message);
         break;
       case 'nada':
         if(variable_get('modr8_send_noact', FALSE) && !empty($values['note'])){
-          modr8_usermail('nada', $nid, $values);
+          $message = modr8_usermail('nada', $nid, $values);
+          modr8_log_action('nada', $nid, $values, $message);
         }    
     }
   }
 }
 
+function modr8_log_action($op, $nid, $values, $message) {
+  global $user;
+  $actions = array('approve' => t('Approve'),'delete' => t('Delete'),'nada' => t('No action'));
+  
+  db_query("INSERT INTO {modr8_log} (nid, uid, author_uid, action, title, message, teaser, timestamp) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', %d)", $nid, $user->uid, $values['author_uid'], $actions[$op], $values['title'], $message, $values['preview'], time()); 
+}
+
 function modr8_usermail($op, $nid, $values){
   $node = node_load($nid);
   
@@ -254,14 +269,18 @@ function modr8_usermail($op, $nid, $valu
     // send the email
     if (drupal_mail('modr8_usermail',$account->mail, $subject, $message, $site_mail)) {
       drupal_set_message(t('%type message was sent to %username', array('%type' => $optype, '%username' => $account->name)));
+      $message = filter_filter('process', 2, -1, $message); // Return e-mail with HTML breaks added.
     }
     else {
-      drupal_set_message(t('There was a problem sending the %type message to %username', array('%type' => $optype, '%username' => $account->name)), 'error');
+      $message = t('There was a problem sending the %type message to %username', array('%type' => $optype, '%username' => $account->name));
+      drupal_set_message($message, 'error');
     }
   }
   else {
-    drupal_set_message(t('An error occurred when trying to load this content.')); // this probably won't ever get called
+    $message = t('An error occurred when trying to load this content.');
+    drupal_set_message($message); // this probably won't ever get called
   }
+  return $message;
 }
 
 function theme_modr8_note($note){
