import mir.util.DateTimeFunctions;
import mir.util.GeneratorFormatAdapters;
import mir.util.StringRoutines;
+import mir.util.EntityUtility;
import mircoders.entity.EntityComment;
import mircoders.entity.EntityContent;
import mircoders.localizer.MirAdminInterfaceLocalizer;
line.append(" ");
line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
- aComment.appendLineToField("comment", line.toString());
+ EntityUtility.appendLineToField(aComment, "comment", line.toString());
MirGlobal.performCommentOperation(null, aComment, filterRule.getCommentAction());
setCookie(aResponse);
line.append(" ");
line.append(filterRule.getType() +" ("+ filterRule.getExpression()+")");
- anArticle.appendLineToField("comment", line.toString());
+ EntityUtility.appendLineToField(anArticle, "comment", line.toString());
MirGlobal.performArticleOperation(null, anArticle, filterRule.getArticleAction());
setCookie(aResponse);
public FilterRule getFilter(String anId) {
synchronized (filterRules) {
- FilterRule result = (FilterRule) findFilter(filterRules, anId);
+ FilterRule result = findFilter(filterRules, anId);
if (result == null)
return result;
else
moveFilter(filterRules, anIdentifier, 1);
}
+ public void moveFilterToTop(String anIdentifier) {
+ setFilterPosition(filterRules, anIdentifier, 0);
+ }
+
+ public void moveFilterToBottom(String anIdentifier) {
+ setFilterPosition(filterRules, anIdentifier, Integer.MAX_VALUE);
+ }
+
private String addFilter(List aFilters, String aType, String anExpression, String aComments, String aCommentAction, String anArticleAction, Date aLastHit) {
MirAntiAbuseFilterType type = (MirAntiAbuseFilterType) filterTypes.get(aType);
return null;
}
+ private void setFilterPosition(List aFilters, String anIdentifier, int aPosition) {
+ synchronized (aFilters) {
+ if (aPosition<0)
+ aPosition=0;
+
+ for (int i = 0; i < aFilters.size(); i++) {
+ FilterRule rule = (FilterRule) aFilters.get(i);
+
+ if (rule.getId().equals(anIdentifier)) {
+ aFilters.remove(rule);
+
+ if (aPosition<aFilters.size())
+ aFilters.add(aPosition, rule);
+ else
+ aFilters.add(rule);
+ break;
+ }
+ }
+ }
+ }
+
private void moveFilter(List aFilters, String anIdentifier, int aDirection) {
synchronized (aFilters) {
for (int i = 0; i < aFilters.size(); i++) {
log.clear();
else {
while (log.size() > 0 && log.size() > logSize) {
- log.remove(0);
+ log.remove(log.size()-1);
}
}
}
private void appendLog(LogEntry anEntry) {
synchronized (log) {
if (logEnabled) {
- log.add(anEntry);
+ log.add(0, anEntry);
truncateLog();
}
}