--- abuse.module.old	2007-08-14 23:44:53.000000000 -0400
+++ abuse.module	2007-08-15 01:41:17.000000000 -0400
@@ -176,6 +176,25 @@ function abuse_admin_settings() {
     '#rows' => 10, 
   );
 
+  $form['general_settings']['abuse_flag_text'] = array(
+    '#type' => 'textfield',
+    '#title' => t('The link users see to flag a node will read'),
+    '#default_value' => variable_get('abuse_flag_text', 'Flag as offensive'),
+    '#size' => 72,
+  );
+
+  $form['general_settings']['abuse_edit_unflag'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow moderator approved content to be flagged again if it is edited'),
+    '#default_value' => variable_get('abuse_edit_unflag', ''),
+  );
+
+  $form['general_settings']['abuse_anon_flag_anon'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Allow anonymous users to flag content by other anonymous users'),
+    '#default_value' => variable_get('abuse_anon_flag_anon', ''),
+  ); 
+
   $form['nodetypes'] = array(
     '#type' => 'fieldset',
     '#title' => t('Enable flagging for these content types'),
@@ -304,6 +323,15 @@ function abuse_nodeapi(&$node, $op, $a3,
   switch ($op) {
     case 'delete':
       _abuse_perform_delete($node->nid, 'node');
+    case 'update':
+	if(_abuse_get_status('node', $node->nid) == 'OK')
+		{
+		if(variable_get('abuse_edit_unflag', ''))
+			{
+			_abuse_perform_delete($node->nid, 'node');
+			drupal_set_message('Since the node has been edited, it may be re-flagged as abuse.');
+			}
+		}
   }
 }
 
@@ -363,13 +391,13 @@ function abuse_admin_removed() {
 function abuse_link($type, $object = null, $teaser = false) {
   global $user;
   $links = array();
-  if ($object && $user && $user->uid == $object->uid) {
+  if ($object && $user && $user->uid == $object->uid && (!variable_get('abuse_anon_flag_anon','') || $user->uid)) {
     // Don't want user to flag their own content
     return $$links;
   }
   if ($type == 'node' && !$teaser) {
     if (variable_get(ABUSE_CONTENT_NODE_TYPE . $object->type, 0) && (user_access(REPORT_ABUSE) || user_access(DIRECT_FLAG))) {
-      if ($user->uid && ($user->uid != $object->uid)) {
+      if ((!$user->uid) || ($user->uid != $object->uid)) {
         $already_reported_check = db_result(db_query("SELECT COUNT(*) FROM {abuse} WHERE type='%s' AND oid=%d AND uid=%d", $type, $object->nid, $user->uid));
         if ($already_reported_check > 0) {
 //          $links['abuse_already_flagged'] = array(
@@ -378,7 +406,7 @@ function abuse_link($type, $object = nul
         } 
         else {
           $links['abuse_flag_node'] = array(
-            'title' => t('Flag as offensive'),
+            'title' => t(variable_get('abuse_flag_text','Flag as offensive')),
             'href' => 'abuse/report/node/'. $object->nid,
             'attributes' => array('class' => 'flag-content',
                                   'title' => t('Notify administrators of problematic content') 
@@ -388,7 +416,7 @@ function abuse_link($type, $object = nul
       }
       else {
         $links['abuse_flag_node'] = array(
-          'title' => t('Flag as offensive'),
+          'title' => t(variable_get('abuse_flag_text','Flag as offensive')),
           'href' => 'abuse/report/node/'. $object->nid,
           'attributes' => array('class' => 'flag-content',
                                 'title' => t('Notify administrators of problematic content') 
@@ -407,7 +435,7 @@ function abuse_link($type, $object = nul
       } 
       else {
         $links['abuse_flag_comment'] = array(
-          'title' => t('Flag as offensive'),
+          'title' => t(variable_get('abuse_flag_text','Flag as offensive')),
           'href' => 'abuse/report/comment/'. $object->cid,
           'attributes' => array('class' => 'flag-content',
                                 'title' => t('Notify administrators of problematic comment')
@@ -417,7 +445,7 @@ function abuse_link($type, $object = nul
     } 
     else {
         $links['abuse_flag_comment'] = array(
-          'title' => t('Flag as offensive'),
+          'title' => t(variable_get('abuse_flag_text','Flag as offensive')),
           'href' => 'abuse/report/comment/'. $object->cid,
           'attributes' => array('class' => 'flag-content',
                                 'title' => t('Notify administrators of problematic comment')
@@ -472,6 +500,10 @@ function abuse_report_form($object, $use
     '#type' => 'value',
     '#value' => $object->oid
   );
+  $form['intro'] = array(
+    '#type' => 'item',
+    '#value' => variable_get('abuse_form_pre',''),
+  );
   if ($user->uid) {
     $form['user'] = array(
       '#type' => 'item',
@@ -586,7 +618,7 @@ function abuse_report_form_submit($form_
   db_query("INSERT INTO {abuse} (aid, type, oid, created, body, reason, uid, name, mail) VALUES (%d, '%s', %d, %d, '%s', '%s', %d, '%s', '%s')",
     $aid, $type, $oid, time(), $form_values['body'], $form_values['reason'], $user->uid, $form_values['name'], $form_values['mail']);
   if ($result) {
-    drupal_goto($object->path['URL'], $object->path['QUERY'], $object->path['BREADCRUMB']);
+    drupal_goto('/');
   } 
   else {
     drupal_set_message(t('Thank you for your report.'));
@@ -627,6 +659,7 @@ function abuse_operations_form($object) 
     '#type' => 'submit',
     '#value' => t('Ban')
   );
+  $form['#submit'] = array ('abuse_operations_form_submit' => 1);
 
   return $form;
 }
@@ -810,14 +843,16 @@ function abuse_ban_form_submit($form_id,
 
 function theme_abuse_page($reports) {
   $content = '<fieldset><ul id="listing">';
+  $formnumber = 0;
   foreach ($reports as $report) {
-    $content .= theme('abuse_report', $report);
+    $content .= theme('abuse_report', $report, $formnumber);
+    $formnumber++;
   }
   $content .= '</ul></fieldset>';
   return $content;
 }
 
-function theme_abuse_report($object) {
+function theme_abuse_report($object,$formnumber) {
   $account = user_load(array('uid' => $object->uid));
   $offences = number_format(_abuse_get_offence_count($object->uid));
   $warnings = number_format(_abuse_get_warning_count($object->uid));
@@ -831,16 +866,29 @@ function theme_abuse_report($object) {
   $output .= "<dl class=\"flags\">\n";
   foreach ($object->reports as $report) {
     $output .= "<dt>". theme('username', $report) .' '. format_date($report->created) ."</dt>\n";
+    $reason = _abuse_reasons($report->reason);
+    $output .= "<dd>". $reason[0]->reason  . "</dd>\n";
     $output .= "<dd>". check_plain($report->body) ."</dd>\n";
   }
   $output .= "</dl>\n";
   $output .= "<div class=\"buttons\">\n";
-  $output .= drupal_get_form('abuse_operations_form', $object);
+  $output .= drupal_get_form('abuse_operations_form' . $formnumber, $object);
   $output .= '</div>';
   $output .= '</li>';
   return $output;
 }
 
+function abuse_forms() {
+  $args = func_get_args();
+  $form_id = $args[0][0]; 
+
+  $forms = array();
+  if(strpos($form_id,"abuse_operations_form") == 0) {
+	$forms[$form_id] = array('callback' => 'abuse_operations_form');
+  }
+  return $forms;
+} 
+
 // Private functions
 
 /**
@@ -946,16 +994,12 @@ function _abuse_load_reports($type, $oid
 function _abuse_allow($type, $oid) {
   $object = _abuse_load($type, $oid);
   $account = user_load(array('uid' => $object->uid, 'status' => 1));
-  if ($account->uid) {
     db_query("UPDATE {abuse} SET valid=-1 WHERE type='%s' AND oid=%d", $type, $oid);
     switch ($type) {
       case 'node':
         db_query("UPDATE {node} SET status=1 WHERE nid=%d", $oid);
-        break;
       case 'comment':
         db_query("UPDATE {comments} SET status=0 WHERE cid=%d", $oid);
-        break;
-    }
     cache_clear_all($oid, 'cache', TRUE);
     _abuse_set_status($type, $oid, ABUSE_LIVE);
   }
@@ -1028,11 +1072,16 @@ function _abuse_get_warning_count($uid) 
   return db_result(db_query('SELECT count(*) FROM {abuse_warnings} WHERE uid=%d', $uid));
 }
 
-function _abuse_reasons() {
+function _abuse_reasons($arid = NULL) {
   static $reasons;
   if (!$reasons) {
     $reasons = array();
-    $resultset = db_query("SELECT * FROM {abuse_reasons}");
+    $query = "SELECT * FROM {abuse_reasons}";
+    if($arid)
+      {
+      $query .= ' WHERE arid=' . $arid;
+      }
+    $resultset = db_query($query);
     while ($reason = db_fetch_object($resultset)) {
       $reasons[] = $reason;
     }
