X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FSoneTemplatePage.java;h=095db9e75e08b49ff7cb30a755893f60e9d1bcca;hp=9eacaf858db62bee05542cca2ad297c22e161daa;hb=45f92ec63dbf8134d92ceed67294faa38117b195;hpb=c5e641893a2656ebf2c2c8c369fe75eaf3061b52 diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 9eacaf8..095db9e 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -26,8 +26,9 @@ import java.util.Map; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.main.SonePlugin; +import net.pterodactylus.sone.notify.ListNotificationFilters; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.sone.web.page.FreenetTemplatePage; -import net.pterodactylus.sone.web.page.Page; import net.pterodactylus.util.collection.ListBuilder; import net.pterodactylus.util.collection.MapBuilder; import net.pterodactylus.util.template.Template; @@ -119,7 +120,6 @@ public class SoneTemplatePage extends FreenetTemplatePage { this.pageTitleKey = pageTitleKey; this.webInterface = webInterface; this.requireLogin = requireLogin; - template.getInitialContext().set("webInterface", webInterface); } // @@ -202,7 +202,7 @@ public class SoneTemplatePage extends FreenetTemplatePage { * {@inheritDoc} */ @Override - protected String getPageTitle(Request request) { + protected String getPageTitle(FreenetRequest request) { if (pageTitleKey != null) { return webInterface.getL10n().getString(pageTitleKey); } @@ -213,7 +213,7 @@ public class SoneTemplatePage extends FreenetTemplatePage { * {@inheritDoc} */ @Override - protected List> getAdditionalLinkNodes(Request request) { + protected List> getAdditionalLinkNodes(FreenetRequest request) { return new ListBuilder>().add(new MapBuilder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").get()).get(); } @@ -247,9 +247,11 @@ public class SoneTemplatePage extends FreenetTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); - templateContext.set("currentSone", getCurrentSone(request.getToadletContext(), false)); + Sone currentSone = getCurrentSone(request.getToadletContext(), false); + templateContext.set("core", webInterface.getCore()); + templateContext.set("currentSone", currentSone); templateContext.set("localSones", webInterface.getCore().getLocalSones()); templateContext.set("request", request); templateContext.set("currentVersion", SonePlugin.VERSION); @@ -257,13 +259,14 @@ public class SoneTemplatePage extends FreenetTemplatePage { templateContext.set("latestEdition", webInterface.getCore().getUpdateChecker().getLatestEdition()); templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); + templateContext.set("notifications", ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone)); } /** * {@inheritDoc} */ @Override - protected String getRedirectTarget(Page.Request request) { + protected String getRedirectTarget(FreenetRequest request) { if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) { HTTPRequest httpRequest = request.getHttpRequest(); String originalUrl = httpRequest.getPath(); @@ -293,7 +296,18 @@ public class SoneTemplatePage extends FreenetTemplatePage { * {@inheritDoc} */ @Override + protected boolean isFullAccessOnly() { + return webInterface.getCore().getPreferences().isRequireFullAccess(); + } + + /** + * {@inheritDoc} + */ + @Override public boolean isEnabled(ToadletContext toadletContext) { + if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) { + return false; + } if (requiresLogin()) { return getCurrentSone(toadletContext, false) != null; }