import mir.misc.StringUtil;
import mir.storage.StorageObjectFailure;
import mir.util.DateTimeFunctions;
+import mir.util.EntityUtility;
import mircoders.entity.EntityComment;
import mircoders.entity.EntityContent;
import mircoders.global.MirGlobal;
addSimpleCommentOperation(new ModifyCommentFieldOperation("hide", "is_published", "0"));
}
+ public String getAdminPageGenerator(String aPage, Map aTemplateData, EntityAdapter aUser, String aDefault) {
+ return aDefault;
+ }
+
public String makePasswordDigest(String aPassword) {
return aPassword;
}
protected abstract static class EntityModifyingOperation implements MirSimpleEntityOperation {
private String name;
+ private boolean logOperation;
- protected EntityModifyingOperation(String aName) {
+ protected EntityModifyingOperation(String aName, boolean aLogOperation) {
name = aName;
+ logOperation = aLogOperation;
}
public String getName() {
Entity entity = anEntity.getEntity();
try {
performModification(aUser, entity);
+
+ if (logOperation) {
+ try {
+ StringBuffer line = new StringBuffer();
+
+ line.append(DateTimeFunctions.advancedDateFormat(
+ MirGlobal.config().getString("Mir.DefaultDateTimeFormat"),
+ (new GregorianCalendar()).getTime(),
+ MirGlobal.config().getString("Mir.DefaultTimezone")));
+ line.append(" ");
+ if (aUser != null)
+ line.append(aUser.get("login"));
+ else
+ line.append("unknown");
+
+ line.append(" ");
+ line.append(getName());
+ EntityUtility.appendLineToField(entity, "comment", line.toString());
+ }
+ catch (Throwable t) {
+ logger.error("Error while trying to log an article operation: " + t.toString());
+ }
+ }
+
entity.update();
}
catch (Throwable t) {
}
public static abstract class CommentModifyingOperation extends EntityModifyingOperation {
+ public CommentModifyingOperation(String aName, boolean aLogOperation) {
+ super(aName, aLogOperation);
+ }
+
public CommentModifyingOperation(String aName) {
- super(aName);
+ this(aName, true);
}
protected boolean isAvailable(Entity anEntity) throws StorageObjectFailure {
protected void performModification(EntityAdapter aUser, Entity anEntity) throws StorageObjectFailure {
performModification(aUser, (EntityComment) anEntity);
- DatabaseContent.getInstance().setUnproduced("id="+anEntity.getValue("to_media"));
+ DatabaseContent.getInstance().setUnproduced("id="+anEntity.getFieldValue("to_media"));
};
protected abstract boolean isAvailable(EntityComment aComment) throws StorageObjectFailure ;
}
public static abstract class ArticleModifyingOperation extends EntityModifyingOperation {
- private boolean logOperation;
-
public ArticleModifyingOperation(String aName, boolean aLogOperation) {
- super(aName);
-
- logOperation = aLogOperation;
+ super(aName, aLogOperation);
}
protected boolean isAvailable(Entity anEntity) throws StorageObjectFailure {
protected void performModification(EntityAdapter aUser, Entity anEntity) throws StorageObjectFailure {
performModification(aUser, (EntityContent) anEntity);
- anEntity.setValueForProperty("is_produced", "0");
-
- if (logOperation) {
- try {
- StringBuffer line = new StringBuffer();
-
- line.append(DateTimeFunctions.advancedDateFormat(
- MirGlobal.config().getString("Mir.DefaultDateTimeFormat"),
- (new GregorianCalendar()).getTime(),
- MirGlobal.config().getString("Mir.DefaultTimezone")));
- line.append(" ");
- if (aUser != null)
- line.append(aUser.get("login"));
- else
- line.append("unknown");
-
- line.append(" ");
- line.append(getName());
- ( (EntityContent) anEntity).appendToComments(line.toString());
- }
- catch (Throwable t) {
- logger.error("Error while trying to log an article operation: " + t.toString());
- }
- }
+ anEntity.setFieldValue("is_produced", "0");
};
protected abstract boolean isAvailable(EntityContent anArticle) throws StorageObjectFailure ;
}
protected void performModification(EntityAdapter aUser, EntityComment aComment) throws StorageObjectFailure {
- aComment.setValueForProperty(field, value);
+ aComment.setFieldValue(field, value);
}
}
while (i.hasNext()) {
Map.Entry entry = (Map.Entry) i.next();
- aComment.setValueForProperty((String) entry.getKey(), (String) entry.getValue());
+ aComment.setFieldValue((String) entry.getKey(), (String) entry.getValue());
}
}
}
}
protected boolean isAvailable(EntityComment aComment) {
- return aComment.getValue(field) == null || !aComment.getValue(field).equals(value);
+ return aComment.getFieldValue(field) == null || !aComment.getFieldValue(field).equals(value);
}
protected void performModification(EntityAdapter aUser, EntityComment aComment) throws StorageObjectFailure {
- aComment.setValueForProperty(field, value);
+ aComment.setFieldValue(field, value);
}
}
}
protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectFailure {
- anArticle.setValueForProperty(field, value);
+ anArticle.setFieldValue(field, value);
}
}
}
protected boolean isAvailable(EntityContent anArticle) {
- return anArticle.getValue(field) == null || !anArticle.getValue(field).equals(value);
+ return anArticle.getFieldValue(field) == null || !anArticle.getFieldValue(field).equals(value);
}
protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectFailure {
- anArticle.setValueForProperty(field, value);
+ anArticle.setFieldValue(field, value);
}
}
}
protected boolean isAvailable(EntityContent anArticle) {
- return anArticle.getValue(field) != null && oldValues.contains(anArticle.getValue(field));
+ return anArticle.getFieldValue(field) != null && oldValues.contains(anArticle.getFieldValue(field));
}
protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectFailure {
- anArticle.setValueForProperty(field, newValue);
+ anArticle.setFieldValue(field, newValue);
}
}
}