Index: src/main/resources/templates/default/admin/config_list.htm =================================================================== --- src/main/resources/templates/default/admin/config_list.htm (revision 201) +++ src/main/resources/templates/default/admin/config_list.htm (working copy) @@ -168,6 +168,11 @@ + ${I18n.getMessage("Config.Form.editTimeAllowedMinutes")} + + + + ${I18n.getMessage("Config.Form.hideShadowTopics")} <#assign o = config.getProperty("hide.shadow.topics")/> Index: src/main/java/net/jforum/util/preferences/ConfigKeys.java =================================================================== --- src/main/java/net/jforum/util/preferences/ConfigKeys.java (revision 201) +++ src/main/java/net/jforum/util/preferences/ConfigKeys.java (working copy) @@ -170,6 +170,8 @@ public static final String CAPTCHA_MIN_WORDS = "captcha.min.words"; public static final String CAPTCHA_MAX_WORDS = "captcha.max.words"; + public static final String EDIT_TIME_ALLOWED_MINUTES = "edit.time.allowed.minutes"; + public static final String RATE_LIMIT_AUTOLOCK_FORUM_IDS = "rate.limit.autolock.forum.ids"; public static final String RATE_LIMIT_TOPIC_INTERVAL_DAYS = "rate.limit.topic.interval.days"; Index: src/main/java/net/jforum/view/forum/common/PostCommon.java =================================================================== --- src/main/java/net/jforum/view/forum/common/PostCommon.java (revision 194) +++ src/main/java/net/jforum/view/forum/common/PostCommon.java (working copy) @@ -300,9 +300,49 @@ public static boolean canEditPost(Post post) { - return SessionFacade.isLogged() - && (post.getUserId() == SessionFacade.getUserSession().getUserId() || SessionFacade.getUserSession().isModerator(post.getForumId()) - && SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_POST_EDIT)); + // To be able to edit a post: + // must be logged on AND + // either a moderator with POST_MODERATION_POST_EDIT + // or the user of the post if the edit time has not expired yet. + + boolean isLogged = SessionFacade.isLogged(); + + // Not logged ? No right to post what so ever. + if (!isLogged) { + return false; + } + + // Is moderator with edit rights ? Then you are allowed no matter the time limit. + + boolean isModeratorWithEditRights = + SessionFacade.getUserSession().isModerator(post.getForumId()) && SecurityRepository.canAccess(SecurityConstants.PERM_MODERATION_POST_EDIT); + + if (isModeratorWithEditRights) { + return true; + } + + // Now, are you the user that created the post ? If not, what are you doing here ? Otherwise, let's also check the time limit + + boolean isCreator = post.getUserId() == SessionFacade.getUserSession().getUserId(); + + if (!isCreator) { + return false; + } + + // If the config is set to 0, allow infinite edit time + int editTimeMinutes = SystemGlobals.getIntValue(ConfigKeys.EDIT_TIME_ALLOWED_MINUTES); + if (editTimeMinutes == 0) { + return true; + } + + // Otherwise .... + long milisSincePostCreation = (new Date()).getTime() - post.getTime().getTime(); + + if ( milisSincePostCreation / 60000 > editTimeMinutes ) { + return false; + } + + return true; } public static List topicPosts(PostDAO dao, boolean canEdit, int userId, int topicId, int start, int count) Index: src/main/config/languages/en_US.properties =================================================================== --- src/main/config/languages/en_US.properties (revision 201) +++ src/main/config/languages/en_US.properties (working copy) @@ -298,6 +298,7 @@ Config.Form.postsCacheEnabled = Cache most recent read topics in memory Config.Form.postsCacheSize = Number of most recent read topics to keep in memory (LRU). Only used if the previous option is set to "true" Config.Form.postsNewDelay = Delay (in ms) between each post from the user. Set it to 0 (zero) to disable the config +Config.Form.editTimeAllowedMinutes = Edit Time allowed for posts ( in minutes; set to 0 to have no limit ) Config.Form.rateLimit = Post Rate Limiting Config.Form.rateLimitAutolockForumIds = Forum IDs where topics will be autolocked ( separated by comma ) Config.Form.rateLimitTopicIntervalDays = Minimum days between new topic for standard users @@ -1109,6 +1110,8 @@ move = Move +split = Split + next = Next november = November Index: src/main/config/SystemGlobals.properties =================================================================== --- src/main/config/SystemGlobals.properties (revision 201) +++ src/main/config/SystemGlobals.properties (working copy) @@ -147,6 +147,11 @@ captcha.max.font.size = 35 # ############### +# Edit Time Limit +# ############### +edit.time.allowed.minutes = 30 + +# ############### # Post Rate Limit # ############### rate.limit.autolock.forum.ids = 2