Fixed wrong isPostVisible computation for logged in users with default settings

main
Inga 🏳‍🌈 14 years ago
parent 93e3517370
commit d5177a4ecb
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Common/dataobjects/AccountSettings.cs
  3. 20
      Common/dataobjects/AnonymousUserSettings.cs
  4. 2
      IISMainHandler/WebContext.cs

@ -183,7 +183,7 @@ namespace FLocal.Common.dataobjects {
if(accountid2id[account.id].HasValue) { if(accountid2id[account.id].HasValue) {
return AccountSettings.LoadById(accountid2id[account.id].Value); return AccountSettings.LoadById(accountid2id[account.id].Value);
} else { } else {
return new AnonymousUserSettings(); return new AnonymousUserSettings(account);
//If cache for this account was just cleared, we will return AnonymousUserSettings. It is ok. //If cache for this account was just cleared, we will return AnonymousUserSettings. It is ok.
} }
} }

@ -7,8 +7,11 @@ using FLocal.Core;
namespace FLocal.Common.dataobjects { namespace FLocal.Common.dataobjects {
public class AnonymousUserSettings : IUserSettings { public class AnonymousUserSettings : IUserSettings {
public AnonymousUserSettings() { private readonly Account account;
var allSkins = Skin.allSkins.ToArray();
public AnonymousUserSettings(Account account) {
this.account = account;
//var allSkins = Skin.allSkins.ToArray();
//this._skinId = allSkins[Util.RandomInt(0, allSkins.Length)].id; //this._skinId = allSkins[Util.RandomInt(0, allSkins.Length)].id;
this._skinId = 28; this._skinId = 28;
this._modernSkinId = 2; this._modernSkinId = 2;
@ -61,9 +64,16 @@ namespace FLocal.Common.dataobjects {
} }
public bool isPostVisible(Post post) { public bool isPostVisible(Post post) {
if(post.poster.showPostsToUsers != User.ENUM_SHOWPOSTSTOUSERS_ALL) return false; if(this.account != null) {
if(post.layer.name != PostLayer.NAME_NORMAL) return false; if(post.layer.name == PostLayer.NAME_HIDDEN) return false;
return true; 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;
}
} }

@ -157,7 +157,7 @@ namespace FLocal.IISHandler {
if(this.session != null) { if(this.session != null) {
this.userSettings = AccountSettings.LoadByAccount(this.session.account); this.userSettings = AccountSettings.LoadByAccount(this.session.account);
} else { } else {
this.userSettings = new AnonymousUserSettings(); this.userSettings = new AnonymousUserSettings(null);
} }
} }

Loading…
Cancel
Save