? modr8-actions-310723-2.patch
? modr8_coder-313907.patch
? more-modr8-cleanup-313907-5.patch
? response-form-319073-5.patch
Index: modr8.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8.module,v
retrieving revision 1.23
diff -u -p -r1.23 modr8.module
--- modr8.module	14 Oct 2008 17:24:44 -0000	1.23
+++ modr8.module	14 Oct 2008 19:53:54 -0000
@@ -64,11 +64,36 @@ function modr8_menu() {
     'weight' => 10,
     'type' => MENU_LOCAL_TASK
   );
+  $items['node/%node/log/response/%'] = array(
+    'title' => 'Moderation response',
+    'page callback' => 'modr8_response_page',
+    'page arguments' => array(1),
+    'access callback' => 'modr8_response_access',
+    'access arguments' => array(1, 4),
+    'file' => 'modr8_admin.inc',
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
 
 /**
+ * Access callback.
+ */
+function modr8_response_access($node, $token) {
+  global $user;
+
+  return ($node->moderate && ($user->uid == $node->uid) && ($token == modr8_response_token($node->nid, $user)));
+}
+
+/**
+ * Generate a token for responding to a node in moderation.
+ */
+function modr8_response_token($nid, $account) {
+  return sha1($account->uid . $account->init . sha1('modr8' . $nid) . drupal_get_private_key() . $nid);
+}
+
+/**
  * Implementation of hook_perm().
  */
 function modr8_perm() {
Index: modr8_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/modr8/modr8_admin.inc,v
retrieving revision 1.23
diff -u -p -r1.23 modr8_admin.inc
--- modr8_admin.inc	14 Oct 2008 17:13:40 -0000	1.23
+++ modr8_admin.inc	14 Oct 2008 19:53:54 -0000
@@ -116,6 +116,67 @@ function modr8_settings_validate($form, 
   }
 }
 
+/**
+ * Menu callback; the moderation response page.
+ */
+function modr8_response_page($node) {
+  drupal_set_title(t('Submit response regarding %title', array('%title' => $node->title)));
+  return drupal_get_form('modr8_response_form', $node);
+}
+ 
+function modr8_response_form($form_state, $node) {
+  $form = array();
+  $form['title'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Response title'),
+    '#required' => TRUE,
+    '#maxlength' => 80,
+    '#weight' => -5,
+  );
+  $form['body'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Message to the moderator'),
+    '#description' => t('Please respond to the moderation messsage you received and provide additional information as appropriate to help the moderator.'),
+    '#rows' => 20,
+    '#required' => TRUE,
+  );
+  $form['buttons']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Submit'),
+    '#weight' => 5,
+  );
+  // 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['preview'] = array(
+    '#type' => 'value',
+    '#value' => $teaser,
+  );
+  $form['author_uid'] = array(
+    '#type' => 'value',
+    '#value' => $node->uid,
+  );
+  $form['nid'] = array(
+    '#type' => 'value',
+    '#value' => $node->nid,
+  );
+
+  return $form;
+}
+
+/**
+ * Form submit handler - log author response.
+ *
+ * @see.modr8_response_form().
+ */
+function modr8_response_form_submit($form, &$form_state) {
+  $form_state['values']['title'] = check_plain($form_state['values']['title']);
+  $message = filter_xss(nl2br($form_state['values']['body']), array('br'));
+  modr8_log_action('response', $form_state['values']['nid'], $form_state['values'], $message);
+  $form_state['redirect'] = 'node/'. $form_state['values']['nid'];
+  drupal_set_message(t('Your response has been logged.'));
+}
 
 /**
  * Menu callback; displays the content moderation form.
@@ -302,7 +363,7 @@ function modr8_form_submit($form, &$form
 
 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', 'response' => 'Response');
 
   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());
   // Notify modules interested in each action we took.
@@ -417,6 +478,7 @@ function modr8_replacements() {
     '%author_url' => 'url("user/". $account->uid, array("absolute" => TRUE))',
     '%site' => 'variable_get("site_name", "Drupal")',
     '%note' => '$note',
+    '%response_url' => 'url("node/". $node->nid ."/response/". modr8_response_token($node->nid, $account) ."/log", array("absolute" => TRUE))',
   );
 }
 
@@ -448,6 +510,8 @@ function modr8_noact_default() {
 
 %note
 
+To respond to the moderator, you can visit %response_url
+
 You can visit %node_url to view it yourself, but is is not yet visible to other site visitors.
 
 Regards,
@@ -487,7 +551,7 @@ function modr8_log_overview($nid = 0) {
 
   $header = array(
     array('data' => t('Action'), ),
-    array('data' => t('Moderator'), 'field' => 'u.name'),
+    array('data' => t('User'), 'field' => 'u.name'),
     array('data' => t('Date'), 'field' => 'ml.modid', 'sort' => 'desc'),
     array('data' => t('Title (view event)')),
   );
@@ -540,10 +604,18 @@ function theme_moderation_event($event) 
   $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'));
-  $rows[] = array(t('Moderator:'), theme('username', $event));
-  $rows[] = array('data' => array(t('E-mail message:'), $event->message), 'style' => 'vertical-align:top;');
-  $rows[] = array(t('Author:'), theme('username', $event->author));
-  $rows[] = array('data' => array(t('Teaser (as reviewed):'), $event->teaser), 'style' => 'vertical-align:top;');
+  if ($event->action == 'Response') {
+    $rows[] = array(t('Author:'), theme('username', $event));
+    $rows[] = array(t('Response title:'), $event->title);
+    $rows[] = array('data' => array(t('Response message:'), $event->message), 'style' => 'vertical-align:top;');
+    $rows[] = array('data' => array(t('Teaser (as of response):'), $event->teaser), 'style' => 'vertical-align:top;');
+  }
+  else {
+    $rows[] = array(t('Moderator:'), theme('username', $event));
+    $rows[] = array('data' => array(t('E-mail message:'), $event->message), 'style' => 'vertical-align:top;');
+    $rows[] = array(t('Author:'), theme('username', $event->author));
+    $rows[] = array('data' => array(t('Teaser (as reviewed):'), $event->teaser), 'style' => 'vertical-align:top;');
+  }
 
   return theme('table', NULL, $rows);
 }
