Index: src/test/resources/config/SystemGlobalsTest.properties
===================================================================
--- src/test/resources/config/SystemGlobalsTest.properties (revision 194)
+++ src/test/resources/config/SystemGlobalsTest.properties (working copy)
@@ -134,6 +134,7 @@
captcha.registration = false
captcha.posts = false
captcha.ignore.case = false
+captcha.admin.moderators = false
captcha.width = 250
captcha.height = 50
Index: src/main/resources/templates/default/admin/config_list.htm
===================================================================
--- src/main/resources/templates/default/admin/config_list.htm (revision 194)
+++ src/main/resources/templates/default/admin/config_list.htm (working copy)
@@ -155,7 +155,19 @@
| ${I18n.getMessage("Config.Form.DisableRegistraion")} |
<#assign o = config.getProperty("registration.enabled")/>
Index: src/main/java/net/jforum/util/preferences/ConfigKeys.java
===================================================================
--- src/main/java/net/jforum/util/preferences/ConfigKeys.java (revision 194)
+++ src/main/java/net/jforum/util/preferences/ConfigKeys.java (working copy)
@@ -161,6 +161,7 @@
public static final String CAPTCHA_IGNORE_CASE = "captcha.ignore.case";
public static final String CAPTCHA_REGISTRATION = "captcha.registration";
+ public static final String CAPTCHA_ADMIN_MODERATORS = "captcha.admins.moderators";
public static final String CAPTCHA_POSTS = "captcha.posts";
public static final String CAPTCHA_WIDTH = "captcha.width";
public static final String CAPTCHA_HEIGHT = "captcha.height";
Index: src/main/java/net/jforum/entities/User.java
===================================================================
--- src/main/java/net/jforum/entities/User.java (revision 194)
+++ src/main/java/net/jforum/entities/User.java (working copy)
@@ -945,4 +945,28 @@
&& (permissionControl.canAccess(SecurityConstants.PERM_MODERATION_FORUMS,
Integer.toString(forumId)));
}
+
+ /**
+ * Checks if the user needs to have captcha displayed.
+ *
+ * @return
+ */
+ public static boolean needsCaptcha(int userId) {
+ final PermissionControl permissionControl = SecurityRepository.get(userId);
+
+ boolean showCaptchaForPosts = SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS);
+
+ // If captcha is not used, then user doesn't need it.
+ if (!showCaptchaForPosts) {
+ return false;
+ }
+
+ if (permissionControl.canAccess(SecurityConstants.PERM_ADMINISTRATION)
+ || permissionControl.canAccess(SecurityConstants.PERM_MODERATION)) {
+ // If user is Admin or Moderator -> well, do we have captcha for them also ?
+ return SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_ADMIN_MODERATORS);
+ }
+
+ return true; // or showCaptchaForPosts, but here showCaptchaForPosts is true anyway.
+ }
}
Index: src/main/java/net/jforum/view/forum/PostAction.java
===================================================================
--- src/main/java/net/jforum/view/forum/PostAction.java (revision 194)
+++ src/main/java/net/jforum/view/forum/PostAction.java (working copy)
@@ -222,7 +222,7 @@
this.context.put("avatarAllowExternalUrl", SystemGlobals.getBoolValue(ConfigKeys.AVATAR_ALLOW_EXTERNAL_URL));
this.context.put("avatarPath", SystemGlobals.getValue(ConfigKeys.AVATAR_IMAGE_DIR));
this.context.put("moderationLoggingEnabled", SystemGlobals.getBoolValue(ConfigKeys.MODERATION_LOGGING_ENABLED));
- this.context.put("needCaptcha", SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS));
+ this.context.put("needCaptcha", User.needsCaptcha(us.getUserId()));
Map topicPosters = topicDao.topicPosters(topic.getId());
@@ -527,7 +527,7 @@
this.context.put("maxAttachments", SystemGlobals.getValue(ConfigKeys.ATTACHMENTS_MAX_POST));
}
- boolean needCaptcha = SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS);
+ boolean needCaptcha = User.needsCaptcha(userId);
this.context.put("moderationLoggingEnabled", SystemGlobals.getBoolValue(ConfigKeys.MODERATION_LOGGING_ENABLED));
this.context.put("smilies", SmiliesRepository.getSmilies());
@@ -726,7 +726,7 @@
this.context.put("pageTitle", I18n.getMessage("PostForm.reply") + " " + topic.getTitle());
this.context.put("smilies", SmiliesRepository.getSmilies());
- boolean needCaptcha = SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS);
+ boolean needCaptcha = User.needsCaptcha(userId);
this.context.put("needCaptcha", needCaptcha);
}
@@ -1039,7 +1039,7 @@
post.setSubject(topic.getTitle());
}
- boolean needCaptcha = SystemGlobals.getBoolValue(ConfigKeys.CAPTCHA_POSTS)
+ boolean needCaptcha = User.needsCaptcha(us.getUserId())
&& request.getSessionContext().getAttribute(ConfigKeys.REQUEST_IGNORE_CAPTCHA) == null;
if (needCaptcha && !us.validateCaptchaResponse(this.request.getParameter("captcha_anwser"))) {
Index: src/main/config/languages/en_US.properties
===================================================================
--- src/main/config/languages/en_US.properties (revision 194)
+++ src/main/config/languages/en_US.properties (working copy)
@@ -238,6 +238,7 @@
Config.Form.AnswerSubject = Topic answer message subject
Config.Form.CacheDir = Cache Directory
Config.Form.CaptchaDuringRegistration = Enable Captcha during registration
+Config.Form.CaptchaEnableForAdminsAndModerators = Enable Captcha for Admins / Moderators
Config.Form.Charset = Message Charset
Config.Form.ClickToUpdate = Update
Config.Form.ConfigName = Name
Index: src/main/config/SystemGlobals.properties
===================================================================
--- src/main/config/SystemGlobals.properties (revision 194)
+++ src/main/config/SystemGlobals.properties (working copy)
@@ -136,7 +136,7 @@
captcha.registration = true
captcha.posts = true
captcha.ignore.case = true
-
+captcha.admins.moderators = false
captcha.width = 250
captcha.height = 75
|