if (member.equals("niceName")) {
return getNiceName(sone);
} else if (member.equals("local")) {
- return sone.getInsertUri() != null;
+ return core.isLocalSone(sone);
} else if (member.equals("friend")) {
- Sone currentSone = (Sone) dataProvider.get("currentSone");
+ Sone currentSone = (Sone) templateContext.get("currentSone");
return (currentSone != null) && currentSone.hasFriend(sone.getId());
} else if (member.equals("current")) {
- Sone currentSone = (Sone) dataProvider.get("currentSone");
+ Sone currentSone = (Sone) templateContext.get("currentSone");
return (currentSone != null) && currentSone.equals(sone);
} else if (member.equals("modified")) {
return core.isModifiedSone(sone);
if (request.getMethod() == Method.POST) {
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
if (text.length() != 0) {
+ String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43);
String recipientId = request.getHttpRequest().getPartAsStringFailsafe("recipient", 43);
- Sone recipient = webInterface.getCore().getSone(recipientId, false);
Sone currentSone = getCurrentSone(request.getToadletContext());
- webInterface.getCore().createPost(currentSone, recipient, System.currentTimeMillis(), text);
+ Sone sender = webInterface.getCore().getLocalSone(senderId, false);
+ if (sender == null) {
+ sender = currentSone;
+ }
+ Sone recipient = webInterface.getCore().getSone(recipientId, false);
+ webInterface.getCore().createPost(sender, recipient, System.currentTimeMillis(), text);
throw new RedirectException(returnPage);
}
- dataProvider.set("errorTextEmpty", true);
+ templateContext.set("errorTextEmpty", true);
}
- dataProvider.set("returnPage", returnPage);
+ templateContext.set("returnPage", returnPage);
}
}
if (request.getMethod() == Method.POST) {
Post post = webInterface.getCore().getPost(postId);
if (text.length() > 0) {
- Sone currentSone = getCurrentSone(request.getToadletContext());
- webInterface.getCore().createReply(currentSone, post, text);
+ String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43);
+ Sone sender = webInterface.getCore().getLocalSone(senderId, false);
+ if (sender == null) {
+ sender = getCurrentSone(request.getToadletContext());
+ }
+ webInterface.getCore().createReply(sender, post, text);
throw new RedirectException(returnPage);
}
- dataProvider.set("errorTextEmpty", true);
+ templateContext.set("errorTextEmpty", true);
}
- dataProvider.set("postId", postId);
- dataProvider.set("text", text);
- dataProvider.set("returnPage", returnPage);
+ templateContext.set("postId", postId);
+ templateContext.set("text", text);
+ templateContext.set("returnPage", returnPage);
}
}
package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.Page.Request.Method;
- import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
/**
* Lets the user delete a post they made.
package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Reply;
-import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.Page.Request.Method;
- import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
/**
* This page lets the user delete a reply.
* {@inheritDoc}
*/
@Override
- protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
- super.processTemplate(request, dataProvider);
- dataProvider.set("currentSone", getCurrentSone(request.getToadletContext(), false));
- dataProvider.set("localSones", webInterface.getCore().getLocalSones());
- dataProvider.set("request", request);
- dataProvider.set("currentVersion", SonePlugin.VERSION);
- dataProvider.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion());
- dataProvider.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion());
- dataProvider.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate());
+ protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+ super.processTemplate(request, templateContext);
+ templateContext.set("currentSone", getCurrentSone(request.getToadletContext(), false));
++ templateContext.set("localSones", webInterface.getCore().getLocalSones());
+ templateContext.set("request", request);
+ templateContext.set("currentVersion", SonePlugin.VERSION);
+ templateContext.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion());
+ templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion());
+ templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate());
}
/**