CheckWhetherIgnoredVersionUpdate() public static method

public static CheckWhetherIgnoredVersionUpdate ( uint version ) : bool
version uint
return bool
Beispiel #1
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars     = new Dictionary <string, object>();
            var settings = webInterface.GetWebUISettings();

            if (requestParameters.ContainsKey("Submit"))
            {
                settings.WebRegistration = requestParameters["WebRegistration"].ToString() == "1";
                settings.MapCenter.X     = int.Parse(requestParameters["GridCenterX"].ToString());
                settings.MapCenter.Y     = int.Parse(requestParameters["GridCenterY"].ToString());
                settings.LocalFrontPage  = requestParameters["LocalFrontPage"].ToString();
                if (settings.LocalFrontPage != "")
                {
                    settings.LocalFrontPage = "local/" + settings.LocalFrontPage;
                }
                settings.LocalCSS                  = requestParameters["LocalCSS"].ToString();
                settings.HideSlideshowBar          = requestParameters["HideSlideshowBar"].ToString() == "1";
                settings.HideLanguageTranslatorBar = requestParameters["HideLanguageBar"].ToString() == "1";
                settings.HideStyleBar              = requestParameters["HideStyleBar"].ToString() == "1";
                if (settings.LocalCSS != "")
                {
                    settings.LocalCSS     = "local/" + settings.LocalCSS;
                    settings.HideStyleBar = true; // not needed if a local style is used
                }

                webInterface.SaveWebUISettings(settings);

                response = "Successfully updated WebUI settings.";

                return(null);
            }
            else if (requestParameters.ContainsKey("IgnorePagesUpdates"))
            {
                settings.LastPagesVersionUpdateIgnored = PagesMigrator.CurrentVersion;
                webInterface.SaveWebUISettings(settings);
            }
            else if (requestParameters.ContainsKey("IgnoreSettingsUpdates"))
            {
                settings.LastSettingsVersionUpdateIgnored = PagesMigrator.CurrentVersion;
                webInterface.SaveWebUISettings(settings);
            }
            vars.Add("WebRegistrationNo", !settings.WebRegistration ? "selected=\"selected\"" : "");
            vars.Add("WebRegistrationYes", settings.WebRegistration ? "selected=\"selected\"" : "");
            vars.Add("GridCenterX", settings.MapCenter.X);
            vars.Add("GridCenterY", settings.MapCenter.Y);
            if (settings.LocalFrontPage.StartsWith("local/"))
            {
                vars.Add("LocalFrontPage", settings.LocalFrontPage.Remove(0, 6)); // remove 'local/' prefix
            }
            else
            {
                vars.Add("LocalFrontPage", settings.LocalFrontPage);
            }

            if (settings.LocalCSS.StartsWith("local/"))
            {
                vars.Add("LocalCSS", settings.LocalCSS.Remove(0, 6)); // remove 'local/' prefix
            }
            else
            {
                vars.Add("LocalCSS", settings.LocalCSS);
            }

            vars.Add("HideSlideshowBarNo", !settings.HideSlideshowBar ? "selected=\"selected\"" : "");
            vars.Add("HideSlideshowBarYes", settings.HideSlideshowBar ? "selected=\"selected\"" : "");
            vars.Add("HideLanguageBarNo", !settings.HideLanguageTranslatorBar ? "selected=\"selected\"" : "");
            vars.Add("HideLanguageBarYes", settings.HideLanguageTranslatorBar ? "selected=\"selected\"" : "");
            vars.Add("HideStyleBarNo", !settings.HideStyleBar ? "selected=\"selected\"" : "");
            vars.Add("HideStyleBarYes", settings.HideStyleBar ? "selected=\"selected\"" : "");
            vars.Add("IgnorePagesUpdates",
                     PagesMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastPagesVersionUpdateIgnored)
                         ? ""
                         : "checked");
            vars.Add("IgnoreSettingsUpdates",
                     settings.LastSettingsVersionUpdateIgnored != SettingsMigrator.CurrentVersion ? "" : "checked");

            vars.Add("SettingsManager", translator.GetTranslatedString("SettingsManager"));
            vars.Add("IgnorePagesUpdatesText", translator.GetTranslatedString("IgnorePagesUpdatesText"));
            vars.Add("IgnoreSettingsUpdatesText", translator.GetTranslatedString("IgnoreSettingsUpdatesText"));
            vars.Add("WebRegistrationText", translator.GetTranslatedString("WebRegistrationText"));
            vars.Add("GridCenterXText", translator.GetTranslatedString("GridCenterXText"));
            vars.Add("GridCenterYText", translator.GetTranslatedString("GridCenterYText"));
            vars.Add("LocalFrontPageText", translator.GetTranslatedString("LocalFrontPageText"));
            vars.Add("LocalCSSText", translator.GetTranslatedString("LocalCSSText"));
            vars.Add("WelcomeMessageText", translator.GetTranslatedString("WelcomeMessageText"));
            vars.Add("HideSlideshowBarText", translator.GetTranslatedString("HideSlideshowBarText"));
            vars.Add("HideLanguageBarText", translator.GetTranslatedString("HideLanguageBarText"));
            vars.Add("HideStyleBarText", translator.GetTranslatedString("HideStyleBarText"));
            vars.Add("Save", translator.GetTranslatedString("Save"));
            vars.Add("No", translator.GetTranslatedString("No"));
            vars.Add("Yes", translator.GetTranslatedString("Yes"));

            return(vars);
        }
Beispiel #2
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            #region Find pages

            List <Dictionary <string, object> > pages = new List <Dictionary <string, object> >();

            var settings = webInterface.GetWebUISettings();
            var rootPage = webInterface.GetGridPages();

            rootPage.Children.Sort((a, b) => a.MenuPosition.CompareTo(b.MenuPosition));

            foreach (GridPage page in rootPage.Children)
            {
                if (page.LoggedOutRequired && Authenticator.CheckAuthentication(httpRequest))
                {
                    continue;
                }

                if (page.LoggedInRequired && !Authenticator.CheckAuthentication(httpRequest))
                {
                    continue;
                }

                if (page.AdminRequired && !Authenticator.CheckAdminAuthentication(httpRequest, page.AdminLevelRequired))
                {
                    continue;
                }

                List <Dictionary <string, object> > childPages = new List <Dictionary <string, object> >();
                page.Children.Sort((a, b) => a.MenuPosition.CompareTo(b.MenuPosition));
                foreach (GridPage childPage in page.Children)
                {
                    if (childPage.LoggedOutRequired && Authenticator.CheckAuthentication(httpRequest))
                    {
                        continue;
                    }

                    if (childPage.LoggedInRequired && !Authenticator.CheckAuthentication(httpRequest))
                    {
                        continue;
                    }

                    if (childPage.AdminRequired &&
                        !Authenticator.CheckAdminAuthentication(httpRequest, childPage.AdminLevelRequired))
                    {
                        continue;
                    }

                    childPages.Add(new Dictionary <string, object>
                    {
                        { "ChildMenuItemID", childPage.MenuID },
                        { "ChildShowInMenu", childPage.ShowInMenu },
                        { "ChildMenuItemLocation", childPage.Location },
                        { "ChildMenuItemTitleHelp", GetTranslatedString(translator, childPage.MenuToolTip, childPage, true) },
                        { "ChildMenuItemTitle", GetTranslatedString(translator, childPage.MenuTitle, childPage, false) }
                    });

                    //Add one for menu.js
                    pages.Add(new Dictionary <string, object>
                    {
                        { "MenuItemID", childPage.MenuID },
                        { "ShowInMenu", false },
                        { "MenuItemLocation", childPage.Location }
                    });
                }

                pages.Add(new Dictionary <string, object>
                {
                    { "MenuItemID", page.MenuID },
                    { "ShowInMenu", page.ShowInMenu },
                    { "HasChildren", page.Children.Count > 0 },
                    { "ChildrenMenuItems", childPages },
                    { "MenuItemLocation", page.Location },
                    { "MenuItemTitleHelp", GetTranslatedString(translator, page.MenuToolTip, page, true) },
                    { "MenuItemTitle", GetTranslatedString(translator, page.MenuTitle, page, false) },
                    { "MenuItemToolTip", GetTranslatedString(translator, page.MenuToolTip, page, true) }
                });
            }

            vars.Add("MenuItems", pages);

            #endregion

            // Tooltips Urls
            vars.Add("TooltipsWelcomeScreen", translator.GetTranslatedString("TooltipsWelcomeScreen"));
            vars.Add("TooltipsWorldMap", translator.GetTranslatedString("TooltipsWorldMap"));

            // Style Switcher
            vars.Add("styles1", translator.GetTranslatedString("styles1"));
            vars.Add("styles2", translator.GetTranslatedString("styles2"));
            vars.Add("styles3", translator.GetTranslatedString("styles3"));
            vars.Add("styles4", translator.GetTranslatedString("styles4"));
            vars.Add("styles5", translator.GetTranslatedString("styles5"));

            vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText"));
            vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText"));
            vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText"));

            // Language Switcher
            vars.Add("en", translator.GetTranslatedString("en"));
            vars.Add("fr", translator.GetTranslatedString("fr"));
            vars.Add("de", translator.GetTranslatedString("de"));
            vars.Add("ga", translator.GetTranslatedString("ga"));
            vars.Add("it", translator.GetTranslatedString("it"));
            vars.Add("es", translator.GetTranslatedString("es"));
            vars.Add("nl", translator.GetTranslatedString("nl"));
            vars.Add("ru", translator.GetTranslatedString("ru"));
            vars.Add("zh_CN", translator.GetTranslatedString("zh_CN"));

            // Index Page
            vars.Add("HomeText", translator.GetTranslatedString("HomeText"));
            vars.Add("HomeTextWelcome", translator.GetTranslatedString("HomeTextWelcome"));
            vars.Add("HomeTextTips", translator.GetTranslatedString("HomeTextTips"));
            vars.Add("WelcomeScreen", translator.GetTranslatedString("WelcomeScreen"));
            vars.Add("WelcomeToText", translator.GetTranslatedString("WelcomeToText"));

            if (PagesMigrator.RequiresUpdate() &&
                PagesMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastPagesVersionUpdateIgnored))
            {
                vars.Add("PagesUpdateRequired",
                         translator.GetTranslatedString("Pages") + " " +
                         translator.GetTranslatedString("DefaultsUpdated"));
            }
            else
            {
                vars.Add("PagesUpdateRequired", "");
            }
            if (SettingsMigrator.RequiresUpdate() &&
                SettingsMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastSettingsVersionUpdateIgnored))
            {
                vars.Add("SettingsUpdateRequired",
                         translator.GetTranslatedString("Settings") + " " +
                         translator.GetTranslatedString("DefaultsUpdated"));
            }
            else
            {
                vars.Add("SettingsUpdateRequired", "");
            }

            vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar);
            vars.Add("ShowStyleBar", !settings.HideStyleBar);

            vars.Add("Maintenance", false);
            vars.Add("NoMaintenance", true);
            return(vars);
        }
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            // homescreen login
            string error = "";

            if (requestParameters.ContainsKey("username") && requestParameters.ContainsKey("password"))
            {
                string username = requestParameters["username"].ToString();
                string password = requestParameters["password"].ToString();

                ILoginService loginService = webInterface.Registry.RequestModuleInterface <ILoginService>();
                if (loginService.VerifyClient(UUID.Zero, username, "UserAccount", password))
                {
                    UUID        sessionID = UUID.Random();
                    UserAccount account   =
                        webInterface.Registry.RequestModuleInterface <IUserAccountService>()
                        .GetUserAccount(null, username);
                    Authenticator.AddAuthentication(sessionID, account);
                    if (account.UserLevel > 0)
                    {
                        Authenticator.AddAdminAuthentication(sessionID, account);
                    }
                    httpResponse.AddCookie(new System.Web.HttpCookie("SessionID", sessionID.ToString())
                    {
                        Expires = DateTime.MinValue,
                        Path    = ""
                    });

                    response = "<h3>Successfully logged in</h3>" +
                               "<script language=\"javascript\">" +
                               "setTimeout(function() {window.location.href = \"index.html\";}, 0);" +
                               "</script>";
                }
                else
                {
                    response = "<h3>Failed to verify user name and password</h3>";
                }
                return(null);
            }

            // Tooltips Urls
            vars.Add("TooltipsWelcomeScreen", translator.GetTranslatedString("TooltipsWelcomeScreen"));
            vars.Add("TooltipsWorldMap", translator.GetTranslatedString("TooltipsWorldMap"));

            // Index Page
            vars.Add("HomeText", translator.GetTranslatedString("HomeText"));
            vars.Add("HomeTextWelcome", translator.GetTranslatedString("HomeTextWelcome"));
            vars.Add("HomeTextTips", translator.GetTranslatedString("HomeTextTips"));
            vars.Add("WelcomeScreen", translator.GetTranslatedString("WelcomeScreen"));
            vars.Add("WelcomeToText", translator.GetTranslatedString("WelcomeToText"));

            // login
            vars.Add("UserLogin", !Authenticator.CheckAuthentication(httpRequest));
            vars.Add("ErrorMessage", error);
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserName"));
            vars.Add("PasswordText", translator.GetTranslatedString("Password"));
            vars.Add("ForgotPassword", translator.GetTranslatedString("ForgotPassword"));
            vars.Add("Submit", translator.GetTranslatedString("Login"));

            var settings = webInterface.GetWebUISettings();

            if (PagesMigrator.RequiresUpdate() &&
                PagesMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastPagesVersionUpdateIgnored))
            {
                vars.Add("PagesUpdateRequired",
                         translator.GetTranslatedString("Pages") + " " +
                         translator.GetTranslatedString("DefaultsUpdated"));
            }
            else
            {
                vars.Add("PagesUpdateRequired", "");
            }
            if (SettingsMigrator.RequiresUpdate() &&
                SettingsMigrator.CheckWhetherIgnoredVersionUpdate(settings.LastSettingsVersionUpdateIgnored))
            {
                vars.Add("SettingsUpdateRequired",
                         translator.GetTranslatedString("Settings") + " " +
                         translator.GetTranslatedString("DefaultsUpdated"));
            }
            else
            {
                vars.Add("SettingsUpdateRequired", "");
            }

            vars.Add("ShowSlideshowBar", !settings.HideSlideshowBar);

            // user setup news inclusion
            if (settings.LocalFrontPage == "")
            {
                vars.Add("LocalPage", false);
                vars.Add("LocalFrontPage", "");
            }
            else
            {
                vars.Add("LocalPage", true);
                vars.Add("LocalFrontPage", settings.LocalFrontPage);
            }

            return(vars);
        }