From d5177a4ecb500de06749818f8fb94baee1914658 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Tue, 21 Dec 2010 11:08:55 +0000 Subject: [PATCH] Fixed wrong isPostVisible computation for logged in users with default settings --- Builder/IISMainHandler/build.txt | 2 +- Common/dataobjects/AccountSettings.cs | 2 +- Common/dataobjects/AnonymousUserSettings.cs | 20 +++++++++++++++----- IISMainHandler/WebContext.cs | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 67bb48c..1f057f4 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1833 \ No newline at end of file +1837 \ No newline at end of file diff --git a/Common/dataobjects/AccountSettings.cs b/Common/dataobjects/AccountSettings.cs index 50c58c8..fb51048 100644 --- a/Common/dataobjects/AccountSettings.cs +++ b/Common/dataobjects/AccountSettings.cs @@ -183,7 +183,7 @@ namespace FLocal.Common.dataobjects { if(accountid2id[account.id].HasValue) { return AccountSettings.LoadById(accountid2id[account.id].Value); } else { - return new AnonymousUserSettings(); + return new AnonymousUserSettings(account); //If cache for this account was just cleared, we will return AnonymousUserSettings. It is ok. } } diff --git a/Common/dataobjects/AnonymousUserSettings.cs b/Common/dataobjects/AnonymousUserSettings.cs index fdea9f1..bde9efa 100644 --- a/Common/dataobjects/AnonymousUserSettings.cs +++ b/Common/dataobjects/AnonymousUserSettings.cs @@ -7,8 +7,11 @@ using FLocal.Core; namespace FLocal.Common.dataobjects { public class AnonymousUserSettings : IUserSettings { - public AnonymousUserSettings() { - var allSkins = Skin.allSkins.ToArray(); + private readonly Account account; + + public AnonymousUserSettings(Account account) { + this.account = account; + //var allSkins = Skin.allSkins.ToArray(); //this._skinId = allSkins[Util.RandomInt(0, allSkins.Length)].id; this._skinId = 28; this._modernSkinId = 2; @@ -61,9 +64,16 @@ namespace FLocal.Common.dataobjects { } public bool isPostVisible(Post post) { - if(post.poster.showPostsToUsers != User.ENUM_SHOWPOSTSTOUSERS_ALL) return false; - if(post.layer.name != PostLayer.NAME_NORMAL) return false; - return true; + if(this.account != null) { + if(post.layer.name == PostLayer.NAME_HIDDEN) return false; + if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return false; + if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_PRIVELEGED) return account.user.userGroup.name == UserGroup.NAME_JUDGES || account.user.userGroup.name == UserGroup.NAME_ADMINISTRATORS; + return true; + } else { + if(post.poster.showPostsToUsers != User.ENUM_SHOWPOSTSTOUSERS_ALL) return false; + if(post.layer.name != PostLayer.NAME_NORMAL) return false; + return true; + } } diff --git a/IISMainHandler/WebContext.cs b/IISMainHandler/WebContext.cs index d949c16..763f02b 100644 --- a/IISMainHandler/WebContext.cs +++ b/IISMainHandler/WebContext.cs @@ -157,7 +157,7 @@ namespace FLocal.IISHandler { if(this.session != null) { this.userSettings = AccountSettings.LoadByAccount(this.session.account); } else { - this.userSettings = new AnonymousUserSettings(); + this.userSettings = new AnonymousUserSettings(null); } }