commit 7e7274a98b605bdbcc36f13d7a65743593f6c9bd
Author: djg_tram <drupal.org/user/930216>
Date:   Tue Nov 22 19:30:03 2011 +0100

    Time-limited editing

diff --git a/advanced_forum.module b/advanced_forum.module
index 03f701a..c6ed1e3 100644
--- a/advanced_forum.module
+++ b/advanced_forum.module
@@ -65,6 +65,12 @@ function advanced_forum_menu_alter(&$items) {
 
   // Take over forum/%forum_forum page also
   $items['forum/%forum_forum']['page callback'] = 'advanced_forum_page';
+
+  // Provide the new access callback for timed editing.
+  if (variable_get('advanced_forum_timed_edit', 0) > 0) {
+    $items['comment/%comment/edit']['access callback'] = 'advanced_forum_comment_access';
+    $items['comment/%comment/edit']['access arguments'] = array('edit', 1);
+  }
 }
 
 /**
@@ -378,6 +384,13 @@ function advanced_forum_links_alter($object, $view_mode, $object_type = 'node')
         'href' => 'node/' . $node->nid . '/delete',
       );
     }
+
+  }
+
+  else if ($object_type == 'comment') {
+    if (!advanced_forum_comment_access('edit', $object)) {
+      unset($links['comment-edit']);
+    }
   }
 
   // Change first post from "add comment" to "reply" if it isn't already.
@@ -386,7 +399,7 @@ function advanced_forum_links_alter($object, $view_mode, $object_type = 'node')
     $links['comment-add']['href'] = "comment/reply/$node->nid";
   }
 
-
+ 
   // List the keys we are interested in.
   $affected_keys = array('post-edit', 'comment-edit', 'post-delete', 'comment-delete', 'quote', 'comment-add', 'comment-reply');
 
@@ -1283,3 +1296,16 @@ function advanced_forum_post_position($node_id, $post_id) {
 
   return $post_position;
 }
+
+function advanced_forum_comment_access($op, $comment) {
+  global $user;
+  static $timed_edit_interval = NULL;
+
+  if ($op == 'edit') {
+    if (!isset($timed_edit_interval)) {
+      $timed_edit_interval = variable_get('advanced_forum_timed_edit', 0) * 60;
+    }
+    $comment_age = time() - $comment->created;
+    return ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && $comment_age <= $timed_edit_interval && user_access('edit own comments')) || user_access('administer comments');
+  }
+}
diff --git a/includes/settings.inc b/includes/settings.inc
index a2ea57d..6dd15a6 100644
--- a/includes/settings.inc
+++ b/includes/settings.inc
@@ -192,6 +192,24 @@ function advanced_forum_settings_page() {
     '#default_value' => variable_get('advanced_forum_topic_title_length', 20),
   );
 
+  /* Editing settings */
+  $form['advanced_forum_editing'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Editing'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+
+  // Disable breadcrumbs
+  $form['advanced_forum_editing']['advanced_forum_timed_edit'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Time limit for editing'),
+    '#default_value' => variable_get('advanced_forum_timed_edit', 0),
+    '#description' => t('The allowed time interval for users to edit their own posts. Set to zero to disable time limited editing.'),
+    '#size' => 5,
+    '#field_suffix' => t('minutes'),
+  );
+
   // Send our form to Drupal to make a settings page
   return system_settings_form($form);
 }
