X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FOptionsPage.java;h=008a1ce65f280e26b12ff92600396e3c923a2121;hb=refs%2Fheads%2Frefactoring;hp=c770da38f830285def0c6fae43d48124345a9bb1;hpb=b95f0d80fa0ac4f9f6f8b51b2fecf796a1f72801;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index c770da3..008a1ce 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -1,5 +1,5 @@ /* - * Sone - OptionsPage.java - Copyright © 2010–2012 David Roden + * Sone - OptionsPage.java - Copyright © 2010–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ package net.pterodactylus.sone.web; import java.util.ArrayList; import java.util.List; -import net.pterodactylus.sone.core.Core.Preferences; +import net.pterodactylus.sone.core.Preferences; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.ShowCustomAvatars; import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; @@ -53,9 +53,6 @@ public class OptionsPage extends SoneTemplatePage { // TEMPLATEPAGE METHODS // - /** - * {@inheritDoc} - */ @Override protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); @@ -64,16 +61,11 @@ public class OptionsPage extends SoneTemplatePage { if (request.getMethod() == Method.POST) { List fieldErrors = new ArrayList(); if (currentSone != null) { - boolean autoFollow = request.getHttpRequest().isPartSet("auto-follow"); - currentSone.getOptions().getBooleanOption("AutoFollow").set(autoFollow); - boolean enableSoneInsertNotifications = request.getHttpRequest().isPartSet("enable-sone-insert-notifications"); - currentSone.getOptions().getBooleanOption("EnableSoneInsertNotifications").set(enableSoneInsertNotifications); - boolean showNotificationNewSones = request.getHttpRequest().isPartSet("show-notification-new-sones"); - currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").set(showNotificationNewSones); - boolean showNotificationNewPosts = request.getHttpRequest().isPartSet("show-notification-new-posts"); - currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").set(showNotificationNewPosts); - boolean showNotificationNewReplies = request.getHttpRequest().isPartSet("show-notification-new-replies"); - currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").set(showNotificationNewReplies); + setBooleanOption(request, currentSone, "auto-follow", "AutoFollow"); + setBooleanOption(request, currentSone, "enable-sone-insert-notifications", "EnableSoneInsertNotifications"); + setBooleanOption(request, currentSone, "show-notification-new-sones", "ShowNotification/NewSones"); + setBooleanOption(request, currentSone, "show-notification-new-posts", "ShowNotification/NewPosts"); + setBooleanOption(request, currentSone, "show-notification-new-replies", "ShowNotification/NewReplies"); String showCustomAvatars = request.getHttpRequest().getPartAsStringFailsafe("show-custom-avatars", 32); currentSone.getOptions(). getEnumOption("ShowCustomAvatars").set(ShowCustomAvatars.valueOf(showCustomAvatars)); webInterface.getCore().touchConfiguration(); @@ -159,4 +151,9 @@ public class OptionsPage extends SoneTemplatePage { templateContext.set("fcp-full-access-required", preferences.getFcpFullAccessRequired().ordinal()); } + private void setBooleanOption(FreenetRequest request, Sone currentSone, String requestPartName, String optionName) { + boolean autoFollow = request.getHttpRequest().isPartSet(requestPartName); + currentSone.getOptions().getBooleanOption(optionName).set(autoFollow); + } + }