? 6x-modr8-1.patch
? 6x-modr8-198584-21.patch
? modr8_9.patch
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/README.txt,v
retrieving revision 1.5
diff -u -p -r1.5 README.txt
--- README.txt	16 Aug 2007 02:54:53 -0000	1.5
+++ README.txt	3 Mar 2008 02:55:45 -0000
@@ -1,6 +1,6 @@
-$Id: README.txt,v 1.5 2007/08/16 02:54:53 pwolanin Exp $
+$Id: README.txt,v 1.3.2.2 2007/08/16 02:58:04 pwolanin Exp $
 
-Modr8 module for Drupal 5.x.
+Modr8 module for Drupal 6.x.
 
 The moderation of content was removed from core in 5.x.  This module adds back 
 that capability and also prevents posts that are in moderation from showing
@@ -46,4 +46,4 @@ not to users with just the "moderate con
 This module was originally written for Drupal 4.7.x by Jeff Robbins 
 (jjeff@drupal).  Upgrade to 5.x and 5.x maintenance by Peter Wolanin 
 (pwolanin@drupal) with help from Angela Byron (webchick@drupal).
-
+Initial upgrade to 6.x by Croitor Alexander (Placinta@drupal)
Index: modr8.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.info,v
retrieving revision 1.1
diff -u -p -r1.1 modr8.info
--- modr8.info	31 Oct 2006 03:31:14 -0000	1.1
+++ modr8.info	3 Mar 2008 02:55:45 -0000
@@ -1,3 +1,4 @@
 ; $Id: modr8.info,v 1.1 2006/10/31 03:31:14 pwolanin Exp $
 name = Modr8
 description = Easy, dedicated moderation of content
+core = 6.x
\ No newline at end of file
Index: modr8.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.install,v
retrieving revision 1.2
diff -u -p -r1.2 modr8.install
--- modr8.install	20 Jan 2007 15:26:38 -0000	1.2
+++ modr8.install	3 Mar 2008 02:55:45 -0000
@@ -1,95 +1,72 @@
 <?php
-// $Id: modr8.install,v 1.2 2007/01/20 15:26:38 pwolanin Exp $
+// $Id: modr8.install,v 1.1.2.3 2007/01/20 15:25:59 pwolanin Exp $
+
+/**
+ * Implementation of hook_schema().
+ */
+function modr8_schema() {
+  $schema['modr8_log'] = array(
+    'fields' => array(
+      'modid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'author_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'action' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''),
+      'title' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'message' => array('type' => 'text', 'size' => 'big',  'not null' => TRUE),
+      'teaser' => array('type' => 'text', 'size' => 'big',  'not null' => TRUE),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'nid_time' => array('nid', 'modid'),
+      'action' => array('action')
+    ),
+    'primary key' => array('modid'),
+  );
+
+  return $schema;
+}
 
 /**
  * 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, modid),
-        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, modid)");
-      db_query("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)");
-      break;
-  }
+  // Create tables.
+  drupal_install_schema('modr8');
 }
 
 /**
  * Implementation of hook_uninstall().
  */
 function modr8_uninstall() {
-  db_query('DROP TABLE {modr8_log}');
+  // Remove tables.
+  drupal_uninstall_schema('modr8');
 }
 
-
 /**
  * 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, modid),
-        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, modid)");
-      $ret[] = update_sql("CREATE INDEX {modr8_log}_act_idx ON {modr8_log} (action)");
-      break;
-  }
+  $name = 'modr8_log';
+  $table = array(
+    'fields' => array(
+      'modid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'author_uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
+      'action' => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''),
+      'title' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
+      'message' => array('type' => 'text', 'size' => 'big',  'not null' => TRUE),
+      'teaser' => array('type' => 'text', 'size' => 'big',  'not null' => TRUE),
+      'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0)
+    ),
+    'indexes' => array(
+      'nid_time' => array('nid', 'modid'),
+      'action' => array('action')
+    ),
+    'primary key' => array('modid'),
+  );
+  db_create_table(&$ret, $name, $table);
   return $ret;
 }
Index: modr8.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.module,v
retrieving revision 1.17
diff -u -p -r1.17 modr8.module
--- modr8.module	16 Aug 2007 02:54:53 -0000	1.17
+++ modr8.module	3 Mar 2008 02:55:46 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: modr8.module,v 1.17 2007/08/16 02:54:53 pwolanin Exp $
+// $Id: modr8.module,v 1.5.2.12 2007/08/16 02:58:04 pwolanin Exp $
 
 /**
  * @file
@@ -9,55 +9,66 @@
 /**
  * Implementation of hook_help().
  */
-function modr8_help($section) {
-  switch ($section) {
+function modr8_help($path, $arg) {
+  switch ($path) {
     case 'admin/help#modr8':
-      return '<p>'. t("Easy, dedicated moderation of content.  Assign the 'moderate content' permission to one or mode user roles.  Set up the default moderation option for each node type."). '</p>';
+      return '<p>'. t("Easy, dedicated moderation of content. Assign the 'moderate content' permission to one or mode user roles. Set up the default moderation option for each node type.") .'</p>';
     // OPTIONAL: Add additional cases for other paths that should display help text.
   }
 }
 
+/**
+ * An access function for Moderation Menu Tab
+ */
+function modr8_moderation_access($nid) {
+  return user_access('moderate content') && db_result(db_query("SELECT COUNT(*) FROM {modr8_log} ml WHERE ml.nid = %d", $nid));
+}
 
 /**
  * Implementation of hook_menu().
  */
-function modr8_menu($may_cache) {
+function modr8_menu() {
   $items = array();
 
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/content/modr8',
-      'title' => t('Moderated content'),
-      'description' => t('Approve or delete moderated content.'),
-      'access' => user_access('moderate content'),
-      'callback' => 'modr8_page',
+    $items['admin/content/modr8'] = array(
+      'title' => 'Moderated content',
+      'description' => 'Approve or delete moderated content.',
+      'access callback' => 'user_access',
+      'access arguments' => array('moderate content'),
+      'page callback' => 'modr8_page',
+      'file' => 'modr8_admin.inc',
+      'file path' => drupal_get_path('module', 'modr8') ,
     );
-    $items[] = array(
-      'path' => 'admin/logs/modr8',
-      'title' => t('Content moderation log'),
-      'description' => t('Show log of all actions on moderated content.'),
-      'access' => user_access('moderate content'),
-      'callback' => 'modr8_log_view',
+    $items['admin/reports/modr8'] = array(
+      'title' => 'Content moderation log',
+      'description' => 'Show log of all actions on moderated content.',
+      'access callback' => 'user_access',
+      'access arguments' => array('moderate content'),
+      'page callback' => 'modr8_log_view',
+      'file' => 'modr8_admin.inc',
+      'file path' => drupal_get_path('module', 'modr8') ,
     );    
-    $items[] = array(
-      'path' => 'admin/settings/modr8',
-      'title' => t('Modr8 settings'),
-      'description' => t('Configure content moderation.'),
-      'callback' => 'modr8_settings',
-      'access' => user_access('administer site configuration'), 
+    $items['admin/settings/modr8'] = array(
+      'title' => 'Modr8 settings',
+      'description' => 'Configure content moderation.',
+      'page callback' => 'modr8_settings',
+      'access callback' => 'user_access',
+      'access arguments' => array('administer site configuration'),
+      'file' => 'modr8_admin.inc',
+      'file path' => drupal_get_path('module', 'modr8') ,
     );
-  }
-  elseif (arg(0) == 'node' && is_numeric($nid = arg(1))) {  
-    $items[] = array(
-      'path' => 'node/'. $nid .'/modr8', 
-      'title' => t('Moderation'),
-      'callback' => 'modr8_log_view',
-      'callback arguments' => array('node', $nid),
-      'access' => user_access('moderate content') && db_result(db_query("SELECT COUNT(*) FROM {modr8_log} ml WHERE ml.nid = %d", $nid)),
+ 
+    $items['node/%/modr8'] = array(
+      'title' => 'Moderation',
+      'page callback' => 'modr8_log_view',
+      'page arguments' => array('node', 1),
+      'access callback' => 'modr8_moderation_access',
+      'access arguments' => array(1),
+      'file' => 'modr8_admin.inc',
+      'file path' => drupal_get_path('module', 'modr8') ,
       'weight' => 10,
       'type' => MENU_LOCAL_TASK
     );
-  }
 
   return $items;
 }
@@ -70,42 +81,10 @@ function modr8_perm() {
 }
 
 /**
- * menu callback for moderation log.
- */
-function modr8_log_view($op = '', $id = 0) {  
-  
-  require_once drupal_get_path('module', 'modr8'). '/modr8_admin.inc';
-  
-  switch ($op) {
-    case '':
-      return modr8_log_overview();
-    case 'event':
-      if (is_numeric($id)) {
-        drupal_set_title(t('Moderation log event'));
-        return modr8_log_event($id);
-      }
-      break;
-    case 'node':
-      if (is_numeric($id)) {
-        $node = node_load($id);
-         if ($node->nid) {
-           drupal_set_title(check_plain($node->title));
-         }
-         return modr8_log_overview($id);
-      }
-      break;
-  }
-  drupal_not_found();
-}
-
-
-/**
  * menu callback for settings form.
  */
 function modr8_settings() {  
   
-  require_once drupal_get_path('module', 'modr8'). '/modr8_admin.inc';
-  
   return drupal_get_form('modr8_settings_form');
 }
 
@@ -149,7 +128,7 @@ function modr8_nodeapi(&$node, $op, $tea
   }
 }
 
-function modr8_form_alter($form_id, &$form){
+function modr8_form_alter(&$form, $form_state, $form_id) {
 
   if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id)  {
 
@@ -185,32 +164,6 @@ function modr8_form_alter($form_id, &$fo
 }
 
 /**
- * Menu callback; displays the content moderation form.
- */
-function modr8_page() {
-  require_once drupal_get_path('module', 'modr8'). '/modr8_admin.inc';
-
-  $is_published = '';
-  if (!user_access('administer nodes')) {
-    // Users who don't have the 'administer nodes' permission can only see published nodes.
-    $is_published = 'n.status = 1 AND ';
-  }
-  $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE '. $is_published .' n.moderate = 1');
-  $page_sql = db_rewrite_sql('SELECT n.nid FROM {node} n WHERE '. $is_published .' n.moderate = 1 ORDER BY n.changed DESC');
-  $result = pager_query($page_sql, variable_get('modr8_nodes_per_page', 10), 0, $count_sql);
-  
-  $output = '<p>'. l(t('Show log of all actions on moderated content.'), 'admin/logs/modr8') .'</p>';
-  if (db_num_rows($result)) {
-    $output .= drupal_get_form('modr8_form', $result);
-    $output .= theme('pager');
-  }
-  else {
-    $output .= '<p>'. t('@items in moderation', array('@items' => format_plural(0, '1 post', '@count posts'))). '</p>';
-  }
-  return $output;
-}
-
-/**
  * Implementation of hook_db_rewrite_sql().
  */
 function modr8_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
@@ -240,7 +193,7 @@ function modr8_db_rewrite_sql($query, $p
 /**
  * Implementation of hook_cron()
  *
- *.Remove expired moderation log events.
+ * Remove expired moderation log events.
  */
 function modr8_cron() {
   if ($log_clear = variable_get('modr8_log_clear', 0)) {
@@ -257,7 +210,7 @@ function modr8_block($op = 'list', $delt
     return $blocks;
   }
   elseif ($op == 'view') {
-    if (user_access('moderate content')){
+    if (user_access('moderate content')) {
       $block['subject'] = t('Moderation queue');
       $is_published = '';
       if (!user_access('administer nodes')) {
@@ -265,10 +218,10 @@ function modr8_block($op = 'list', $delt
         $is_published = 'n.status = 1 AND ';
       }
       $count = db_result(db_query(db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE '. $is_published .' n.moderate = 1')));
-      $content = '<p>'. l(t('@items in moderation',array('@items' => format_plural($count, '1 post', '@count posts'))),'admin/content/modr8'). '</p>';
+      $content = '<p>'. l(t('@items in moderation', array('@items' => format_plural($count, '1 post', '@count posts'))), 'admin/content/modr8') .'</p>';
       if ($count) {
         $sql = db_rewrite_sql('SELECT n.nid, n.title FROM {node} n WHERE '. $is_published .' n.moderate = 1 ORDER BY n.changed DESC');
-        $result = db_query_range($sql,0,6);
+        $result = db_query_range($sql, 0, 6);
         $content .= node_title_list($result, t('Recent additions:'));
       }
       $block['content'] = $content;
@@ -276,7 +229,21 @@ function modr8_block($op = 'list', $delt
     }
   }
 }
-
+/**
+ * Implementation of hook_theme().
+ */
+function modr8_theme() {
+  return array(
+    'modr8_message' => array('arguments' => array('teaser', 'nodetype', 'op')),
+    'modr8_form' => array('arguments' => array('form')),
+    'moderation_event' => array('arguments' => array('event')),
+    'modr8_note' => array('arguments' => array('note')),
+	
+  );
+}
+/**
+ * Theming function for messages.
+ */
 function theme_modr8_message($teaser = FALSE, $nodetype = 'page', $op = 'view') {
   if ($teaser) {
     return ' <div class="marker">'. t('Pending moderation') .'</div>';
Index: modr8_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8_admin.inc,v
retrieving revision 1.13
diff -u -p -r1.13 modr8_admin.inc
--- modr8_admin.inc	13 Dec 2007 00:58:19 -0000	1.13
+++ modr8_admin.inc	3 Mar 2008 02:55:46 -0000
@@ -1,7 +1,7 @@
 <?php
-// $Id: modr8_admin.inc,v 1.13 2007/12/13 00:58:19 pwolanin Exp $
+// $Id: modr8_admin.inc,v 1.2.2.10 2007/08/16 04:10:08 pwolanin Exp $
 
-function modr8_settings_form() {  
+function modr8_settings_form($form_state) {  
   
   $form['modr8_default_option'] = array(
     '#type' => 'radios',
@@ -61,7 +61,7 @@ function modr8_settings_form() {  
     '#type' => 'textarea',
     '#title' => t('Acceptance e-mail'),
     '#default_value' => variable_get('modr8_accepted_text', $accept_default),
-  	'#description' => t('Replacement strings are: %macros', array('%macros' => $macros)),
+    '#description' => t('Replacement strings are: %macros', array('%macros' => $macros)),
   );
   
   $form['text']['modr8_send_deny'] = array(
@@ -82,7 +82,7 @@ function modr8_settings_form() {  
     '#type' => 'textarea',
     '#title' => t('Denial e-mail'),
     '#default_value' => variable_get('modr8_denial_text', $denial_default),
-  	'#description' => t('Replacement strings are: %macros', array('%macros' => $macros)),
+    '#description' => t('Replacement strings are: %macros', array('%macros' => $macros)),
   );
 
   $form['text']['modr8_send_noact'] = array(
@@ -103,32 +103,62 @@ function modr8_settings_form() {  
     '#type' => 'textarea',
     '#title' => t('No action e-mail note'),
     '#default_value' => variable_get('modr8_noact_text', $noact_default),
-  	'#description' => t('Replacement strings are: %macros', array('%macros' => $macros)),
+    '#description' => t('Replacement strings are: %macros', array('%macros' => $macros)),
   );
-  $form['#validate'] = array('modr8_settings_validate' => array());
+  $form['#validate'] = array('modr8_settings_validate');
   
   return system_settings_form($form);
 }
 
-function modr8_settings_validate($form_id, $form_values) {
-  if ($form_values['modr8_email_from'] && !valid_email_address($form_values['modr8_email_from'])) {
+function modr8_settings_validate($form, &$form_state) {
+  if ($form_state['values']['modr8_email_from'] && !valid_email_address($form_state['values']['modr8_email_from'])) {
     form_set_error('modr8_email_from', t('You must either enter a valid e-mail address, or leave the moderator e-mail field empty.'));
   }
 }
 
-function modr8_form($result = NULL) {
+
+/**
+ * Menu callback; displays the content moderation form.
+ */
+function modr8_page() {
+
+  $is_published = '';
+  if (!user_access('administer nodes')) {
+    // Users who don't have the 'administer nodes' permission can only see published nodes.
+    $is_published = 'n.status = 1 AND ';
+  }
+  $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE '. $is_published .' n.moderate = 1');
+  $page_sql = db_rewrite_sql('SELECT n.nid FROM {node} n WHERE '. $is_published .' n.moderate = 1 ORDER BY n.changed DESC');
+  $result = pager_query($page_sql, 10, 0, $count_sql);
+  $result_count = pager_query($page_sql, 10, 0, $count_sql);
+  $output = '<p>'. l(t('Show log of all actions on moderated content.'), 'admin/reports/modr8') .'</p>';
  
+
+  if (db_fetch_object($result_count)) {
+    $output .= drupal_get_form('modr8_form', $result);
+    $output .= theme('pager');
+	
+  }
+  else {
+    $output .= '<p>'. t('@items in moderation', array('@items' => format_plural(0, '1 post', '@count posts'))) .'</p>';
+  }
+  return $output;
+}
+
+function modr8_form($form_state, $result = NULL) {
   $form = array(
     '#theme' => 'modr8_form',
     '#tree' => TRUE,
   );
 
   while ($r = db_fetch_object($result)) {
+  
     $node = node_load($r->nid);
     // This flag can be used by modr8, or other modules to change the teaser specifically
     // for when it's being shown in the moderation list.
     $node->modr8_form_teaser = TRUE;
     $teaser = node_view($node, TRUE, FALSE, FALSE);
+	
     $form[$node->nid] = array(
       '#tree' => TRUE,
     );
@@ -155,10 +185,10 @@ function modr8_form($result = NULL) {
 
     $log_link = '';
     $events = db_query("SELECT modid FROM {modr8_log} WHERE nid = %d", $node->nid);
-    $count = db_num_rows($events);
+    $count = db_result(db_query("SELECT COUNT(modid) FROM {modr8_log} WHERE nid = %d", $node->nid));
     if ($count) {
       if ($count == 1) {
-        $url = 'admin/logs/modr8/event/'. db_result($events);
+        $url = 'admin/reports/modr8/event/'. db_result($events);
       }
       else {
         $url = 'node/'. $node->nid .'/modr8/';
@@ -185,7 +215,7 @@ function modr8_form($result = NULL) {
   }
   $form['submit'] = array(
     '#type' => 'submit',
-    '#value' => t('Submit'),
+    '#value' => t('Save'),
   );
   
   return $form;
@@ -203,8 +233,9 @@ function theme_modr8_form(&$form) {
     // Only do this for nodes; not the submit button.
     if (is_numeric($key)) {
       $row = array();
+      $note_field = '';
       if (variable_get('modr8_send_approve', FALSE) || variable_get('modr8_send_deny', FALSE)) {
-        $note_field = drupal_render($form[$key]['note']);
+        $note_field .= drupal_render($form[$key]['note']);
       }
       $row[] = array(
         'data' => drupal_render($form[$key]['ops']) . $note_field,
@@ -231,12 +262,12 @@ function theme_modr8_form(&$form) {
 /**
  * Form submit handler, which approves or deletes the node.
  */
-function modr8_form_submit($form_id, $form_values) {
-  foreach ($form_values as $nid => $values) {
+function modr8_form_submit($form, &$form_state) {
+  foreach ($form_state['values'] as $nid => $values) {
     $message = '';   
     switch ($values['ops']) {
       case 'approve':
-        if (variable_get('modr8_send_approve', FALSE)){
+        if (variable_get('modr8_send_approve', FALSE)) {
           $message = modr8_usermail('approve', $nid, $values);
         }
         $publish = '';
@@ -249,7 +280,7 @@ function modr8_form_submit($form_id, $fo
         modr8_log_action('approve', $nid, $values, $message);
         break;
       case 'delete':
-        if (variable_get('modr8_send_deny', FALSE)){
+        if (variable_get('modr8_send_deny', FALSE)) {
           $message = modr8_usermail('deny', $nid, $values);
         }
         node_delete($nid);
@@ -257,7 +288,7 @@ function modr8_form_submit($form_id, $fo
         modr8_log_action('delete', $nid, $values, $message);
         break;
       case 'nada':
-        if (variable_get('modr8_send_noact', FALSE) && !empty($values['note'])){
+        if (variable_get('modr8_send_noact', FALSE) && !empty($values['note'])) {
           $message = modr8_usermail('nada', $nid, $values);
           modr8_log_action('nada', $nid, $values, $message);
         }    
@@ -267,14 +298,12 @@ function modr8_form_submit($form_id, $fo
 
 function modr8_log_action($op, $nid, $values, $message) {
   global $user;
-  $actions = array('approve' => 'Approve','delete' => 'Delete','nada' => 'No action');
+  $actions = array('approve' => 'Approve', 'delete' => 'Delete', 'nada' => '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()); 
-  
-  module_invoke_all("modr8_action", $op, $nid);
 }
 
-function modr8_usermail($op, $nid, $values){
+function modr8_usermail($op, $nid, $values) {
   $node = node_load($nid);
   
   if (is_object($node)) {
@@ -302,16 +331,7 @@ function modr8_usermail($op, $nid, $valu
     
     $note = theme('modr8_note', $values['note']);
     
-    // eval the replacements
-    $replacements_raw = modr8_replacements();
-    foreach ($replacements_raw as $key => $val) {
-      eval('$replacements["$key"] = '. $val .';');
-    }
-    
-    // replace the macros
-    $subject = strtr($subject, $replacements);
-    $message = strtr($message, $replacements);
-    
+    $sendmail_from = '';
     $site_mail = variable_get('modr8_email_from', '');
     if (!$site_mail) {
       $sendmail_from = ini_get('sendmail_from');
@@ -321,7 +341,13 @@ function modr8_usermail($op, $nid, $valu
       drupal_set_message(t('You should create an administrator mail address for your site! <a href="@url">Do it here</a>.', array('@url' => url('admin/settings/site-information'))), 'error');
     }
     // send the email
-    if (drupal_mail('modr8_usermail',$account->mail, $subject, $message, $site_mail)) {
+    $language = user_preferred_language($account);
+    $params = array('account' => $account, 'node' => $node, 'subject' => $subject, 'message' => $message, 'note' => $note);
+    
+    if ($account->uid == 0) { 
+      $message = t('Anonymous user; no %type message was sent.', array('%type' => $optype));
+    }
+    elseif ($account->uid && drupal_mail('modr8', 'notify', $account->mail, user_preferred_language($account), $params)) {
       drupal_set_message(t('%type message was sent to %username', array('%type' => $optype, '%username' => $account->name)));
       $message = filter_xss(nl2br($message), array('br', 'a')); // Return sanitized e-mail with HTML breaks added.
     }
@@ -337,15 +363,37 @@ function modr8_usermail($op, $nid, $valu
   return $message;
 }
 
-function theme_modr8_note($note){
-  if ($note){
+/**
+ * Implementation of hook_mail()
+ */
+function modr8_mail($key, &$message, $params) {
+  $language = $message['language'];
+  $node = $params['node'];
+  $account = $params['account'];
+  $note = $params['note'];
+  switch ($key) {
+    case 'notify':
+	  // eval the replacements
+      $replacements_raw = modr8_replacements();
+      foreach ($replacements_raw as $key => $val) 
+        eval('$replacements["$key"] = '. $val .';');
+      $params['subject'] = strtr($params['subject'], $replacements);
+      $params['message'] = strtr($params['message'], $replacements);
+      $message['subject'] = $params['subject'];
+      $message['body'] = $params['message'];
+    break;
+  }
+}
+
+function theme_modr8_note($note) {
+  if ($note) {
     $note = t("Note:
   @note", array('@note' => $note));
   }
   return $note;
 }
 
-function modr8_replacements(){
+function modr8_replacements() {
   return array(
     '%title' => '$node->title',
     '%teaser' => '$node->teaser',
@@ -354,10 +402,10 @@ function modr8_replacements(){
     '%medium_date' => 'format_date($node->created, "medium")',
     '%long_date' => 'format_date($node->created, "long")',
     '%type' => 'node_get_types("name", $node)',
-    '%node_url' => 'url("node/". $node->nid, NULL, NULL, TRUE)',
+    '%node_url' => 'url("node/". $node->nid, array("absolute" => TRUE))',
     '%author_name' => '$account->name',
     '%author_mail' => '$account->mail',
-    '%author_url' => 'url("user/". $account->uid, NULL, NULL, TRUE)',
+    '%author_url' => 'url("user/". $account->uid, array("absolute" => TRUE))',
     '%site' => 'variable_get("site_name", "Drupal")',
     '%note' => '$note',
   );
@@ -398,13 +446,41 @@ The %site team');
 }
 
 
+/**
+ * menu callback for moderation log.
+ */
+function modr8_log_view($op = '', $id = 0) {  
+  
+  switch ($op) {
+    case '':
+      return modr8_log_overview();
+    case 'node':
+      if (is_numeric($id)) {
+        $node = node_load($id);
+        if (!empty($node->title)) {
+          drupal_set_title(check_plain($node->title));
+        }
+        return modr8_log_overview($id);
+      }
+      break;
+    case 'event':
+      if (is_numeric($id)) {
+        drupal_set_title(t('Moderation log event'));
+        return modr8_log_event($id);
+		
+      }
+      break;
+  }
+  drupal_not_found();
+}
+
 function modr8_log_overview($nid = 0) {
 
   $header = array(
     array('data' => t('Action'), ),
     array('data' => t('Moderator'), 'field' => 'u.name'),
     array('data' => t('Date'), 'field' => 'ml.modid', 'sort' => 'desc'),
-    array('data' => t('Title (view event)'),),
+    array('data' => t('Title (view event)')),
   );
   $tablesort = tablesort_sql($header);
 
@@ -422,14 +498,14 @@ function modr8_log_overview($nid = 0) {
   
   while ($event = db_fetch_object($result)) {
     $rows[] = array(t($event->action), theme('username', $event), format_date($event->timestamp, 'small'),
-    l(truncate_utf8($event->title, 50, TRUE, TRUE), 'admin/logs/modr8/event/'. $event->modid, array(), NULL, NULL, FALSE, TRUE)
+    l(truncate_utf8($event->title, 50, TRUE, TRUE), 'admin/reports/modr8/event/'. $event->modid, array(), NULL, NULL, FALSE, TRUE)
     );
   }
 
   if (!$rows) {
     $rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 4));
   }
-
+  $output = '';
   $output .= theme('table', $header, $rows);
   $output .= theme('pager', NULL, 50, 0);
 
@@ -451,7 +527,7 @@ function modr8_log_event($modid) {
 }
 
 function theme_moderation_event($event) {
-  //drupal_set_message(print_r($event, TRUE));
+
   $rows[] = array(array('data' => l(t('Overview of all moderation log events for this post'), 'node/'. $event->nid .'/modr8/'), 'colspan' => 2));
   $rows[] = array(t('Action:'), t($event->action));
   $rows[] = array(t('Date:'), format_date($event->timestamp, 'small'));
