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. 14
      Common/dataobjects/AnonymousUserSettings.cs
  4. 2
      IISMainHandler/WebContext.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.
}
}

@ -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,10 +64,17 @@ namespace FLocal.Common.dataobjects {
}
public bool isPostVisible(Post post) {
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;
}
}
public int maxUploadImageWidth {

@ -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);
}
}

Loading…
Cancel
Save