All layers except normal are hidden from guests

main
Inga 🏳‍🌈 14 years ago
parent 43918d7a3d
commit 71fd56fa95
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 6
      Common/UserContext.cs
  4. 7
      Common/dataobjects/AccountSettings.cs
  5. 6
      Common/dataobjects/AnonymousUserSettings.cs
  6. 2
      Common/dataobjects/IUserSettings.cs
  7. 8
      Common/dataobjects/Post.cs
  8. 3
      Common/dataobjects/Thread.cs
  9. 21
      IISMainHandler/WebContext.cs
  10. 29
      IISMainHandler/handlers/request/MarkThreadAsReadHandler.cs
  11. 24
      IISMainHandler/handlers/request/ReturnPostHandler.cs

@ -17,10 +17,6 @@ namespace FLocal.Common {
get; get;
} }
abstract public dataobjects.IUserSettings userSettings {
get;
}
abstract public string formatDateTime(DateTime dateTime); abstract public string formatDateTime(DateTime dateTime);
abstract public XElement formatTotalPosts(long posts); abstract public XElement formatTotalPosts(long posts);
@ -32,6 +28,8 @@ namespace FLocal.Common {
get; get;
} }
abstract public bool isPostVisible(dataobjects.Post post);
} }
public static class UserContext_Extensions { public static class UserContext_Extensions {

@ -89,6 +89,13 @@ namespace FLocal.Common.dataobjects {
} }
} }
public bool isPostVisible(Post post) {
if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return false;
if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_PRIVELEGED) return false;
if(post.layer.name == PostLayer.NAME_HIDDEN) return false;
return true;
}
protected override void doFromHash(Dictionary<string, string> data) { protected override void doFromHash(Dictionary<string, string> data) {
this._accountId = int.Parse(data[TableSpec.FIELD_ACCOUNTID]); this._accountId = int.Parse(data[TableSpec.FIELD_ACCOUNTID]);
this._postsPerPage = int.Parse(data[TableSpec.FIELD_POSTSPERPAGE]); this._postsPerPage = int.Parse(data[TableSpec.FIELD_POSTSPERPAGE]);

@ -43,5 +43,11 @@ 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;
}
} }
} }

@ -27,6 +27,8 @@ namespace FLocal.Common.dataobjects {
get; get;
} }
bool isPostVisible(Post post);
} }
public static class IUserSettings_Extension { public static class IUserSettings_Extension {

@ -165,13 +165,7 @@ namespace FLocal.Common.dataobjects {
public XElement exportToXmlWithoutThread(UserContext context, bool includeParentPost, params XElement[] additional) { public XElement exportToXmlWithoutThread(UserContext context, bool includeParentPost, params XElement[] additional) {
if(context.account == null && this.poster.showPostsToUsers != User.ENUM_SHOWPOSTSTOUSERS_ALL) { if(!context.isPostVisible(this)) return null;
return null;
}
if(this.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) {
return null;
}
XElement result = new XElement("post", XElement result = new XElement("post",
new XElement("id", this.id), new XElement("id", this.id),

@ -182,6 +182,9 @@ namespace FLocal.Common.dataobjects {
} }
public XElement exportToXml(UserContext context, bool includeFirstPost, params XElement[] additional) { public XElement exportToXml(UserContext context, bool includeFirstPost, params XElement[] additional) {
if(!context.isPostVisible(this.firstPost)) return null;
XElement result = new XElement("thread", XElement result = new XElement("thread",
new XElement("id", this.id), new XElement("id", this.id),
new XElement("firstPostId", this.firstPostId), new XElement("firstPostId", this.firstPostId),

@ -32,11 +32,9 @@ namespace FLocal.IISHandler {
} }
} }
private IUserSettings _userSettings; public IUserSettings userSettings {
public override IUserSettings userSettings { get;
get { private set;
return this._userSettings;
}
} }
public override Common.IOutputParams outputParams { public override Common.IOutputParams outputParams {
@ -59,7 +57,10 @@ namespace FLocal.IISHandler {
return PageOuter.create(this.userSettings.postsPerPage, posts).exportToXml(2, 0, 2); return PageOuter.create(this.userSettings.postsPerPage, posts).exportToXml(2, 0, 2);
} }
public DateTime requestTime; public DateTime requestTime {
get;
private set;
}
public Session session; public Session session;
@ -72,6 +73,10 @@ namespace FLocal.IISHandler {
} }
} }
public override bool isPostVisible(Post post) {
return this.userSettings.isPostVisible(post);
}
public WebContext(HttpContext httpcontext) { public WebContext(HttpContext httpcontext) {
this.httpcontext = httpcontext; this.httpcontext = httpcontext;
this.requestTime = DateTime.Now; this.requestTime = DateTime.Now;
@ -90,9 +95,9 @@ 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();
} }
} }

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Common.dataobjects;
using FLocal.Importer;
using System.Text.RegularExpressions;
using FLocal.Core;
using FLocal.Common;
using FLocal.Common.actions;
using System.Web;
namespace FLocal.IISHandler.handlers.request {
class MarkThreadAsReadHandler : ReturnPostHandler {
protected override void _Do(WebContext context) {
Account account = context.session.account;
Thread thread = Thread.LoadById(int.Parse(context.requestParts[2]));
if(!context.requestParts[3].StartsWith("p")) throw new CriticalException("wrong url");
Post post = Post.LoadById(int.Parse(context.requestParts[3].PHPSubstring(1)));
if(post.thread.id != thread.id) throw new CriticalException("id mismatch");
thread.forceMarkAsRead(account, post);
}
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace FLocal.IISHandler.handlers.request {
abstract class ReturnPostHandler : AbstractPostHandler {
protected override string templateName {
get {
return null;
}
}
abstract protected void _Do(WebContext context);
protected override XElement[] Do(WebContext context) {
this._Do(context);
throw new RedirectException(context.httprequest.UrlReferrer.ToString());
}
}
}
Loading…
Cancel
Save