Hidden posts display implemented

main
Inga 🏳‍🌈 14 years ago
parent c1e0d60315
commit cb8ca52613
  1. 2
      Builder/IISMainHandler/build.txt
  2. 1
      Common/Common.csproj
  3. 14
      Common/PostVisibilityEnum.cs
  4. 2
      Common/UserContext.cs
  5. 10
      Common/dataobjects/AccountSettings.cs
  6. 16
      Common/dataobjects/AnonymousUserSettings.cs
  7. 2
      Common/dataobjects/IUserSettings.cs
  8. 84
      Common/dataobjects/Post.cs
  9. 2
      Common/dataobjects/Thread.cs
  10. 2
      IISMainHandler/WebContext.cs
  11. 16
      templates/Full/elems/PostInfo.xslt
  12. 18
      templates/Lite/elems/PostInfo.xslt
  13. 21
      templates/Modern/elems/PostInfo.xslt
  14. 4
      templates/Rss/elems/PostInfo.xslt

@ -125,6 +125,7 @@
<Compile Include="IComplexSqlObjectTableSpec.cs" /> <Compile Include="IComplexSqlObjectTableSpec.cs" />
<Compile Include="IOutputParams.cs" /> <Compile Include="IOutputParams.cs" />
<Compile Include="ISqlObjectTableSpec.cs" /> <Compile Include="ISqlObjectTableSpec.cs" />
<Compile Include="PostVisibilityEnum.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlObject.cs" /> <Compile Include="SqlObject.cs" />
<Compile Include="TableManager.cs" /> <Compile Include="TableManager.cs" />

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLocal.Common {
public enum PostVisibilityEnum {
UNVISIBLE, //we won't show that post
HIDDEN, //we will show that there is some hidden post
VISIBLE,
}
}

@ -28,7 +28,7 @@ namespace FLocal.Common {
get; get;
} }
abstract public bool isPostVisible(dataobjects.Post post); abstract public PostVisibilityEnum isPostVisible(dataobjects.Post post);
} }

@ -135,11 +135,11 @@ namespace FLocal.Common.dataobjects {
} }
} }
public bool isPostVisible(Post post) { public PostVisibilityEnum isPostVisible(Post post) {
if(post.layer.name == PostLayer.NAME_HIDDEN) return false; if(post.layer.name == PostLayer.NAME_HIDDEN) return PostVisibilityEnum.HIDDEN;
if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return false; if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return PostVisibilityEnum.HIDDEN;
if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_PRIVELEGED) return this.account.user.userGroup.name == UserGroup.NAME_JUDGES || this.account.user.userGroup.name == UserGroup.NAME_ADMINISTRATORS; if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_PRIVELEGED) return (this.account.user.userGroup.name == UserGroup.NAME_JUDGES || this.account.user.userGroup.name == UserGroup.NAME_ADMINISTRATORS) ? PostVisibilityEnum.VISIBLE : PostVisibilityEnum.HIDDEN;
return true; return PostVisibilityEnum.VISIBLE;
} }
protected override void doFromHash(Dictionary<string, string> data) { protected override void doFromHash(Dictionary<string, string> data) {

@ -63,16 +63,16 @@ namespace FLocal.Common.dataobjects {
} }
} }
public bool isPostVisible(Post post) { public PostVisibilityEnum isPostVisible(Post post) {
if(this.account != null) { if(this.account != null) {
if(post.layer.name == PostLayer.NAME_HIDDEN) return false; if(post.layer.name == PostLayer.NAME_HIDDEN) return PostVisibilityEnum.HIDDEN;
if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return false; if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_NONE) return PostVisibilityEnum.HIDDEN;
if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_PRIVELEGED) return account.user.userGroup.name == UserGroup.NAME_JUDGES || account.user.userGroup.name == UserGroup.NAME_ADMINISTRATORS; if(post.poster.showPostsToUsers == User.ENUM_SHOWPOSTSTOUSERS_PRIVELEGED) return (account.user.userGroup.name == UserGroup.NAME_JUDGES || account.user.userGroup.name == UserGroup.NAME_ADMINISTRATORS) ? PostVisibilityEnum.VISIBLE : PostVisibilityEnum.HIDDEN;
return true; return PostVisibilityEnum.VISIBLE;
} else { } else {
if(post.poster.showPostsToUsers != User.ENUM_SHOWPOSTSTOUSERS_ALL) return false; if(post.poster.showPostsToUsers != User.ENUM_SHOWPOSTSTOUSERS_ALL) return PostVisibilityEnum.HIDDEN;
if(post.layer.name != PostLayer.NAME_NORMAL) return false; if(post.layer.name != PostLayer.NAME_NORMAL) return PostVisibilityEnum.HIDDEN;
return true; return PostVisibilityEnum.VISIBLE;
} }
} }

@ -35,7 +35,7 @@ namespace FLocal.Common.dataobjects {
get; get;
} }
bool isPostVisible(Post post); PostVisibilityEnum isPostVisible(Post post);
int maxUploadImageWidth { int maxUploadImageWidth {
get; get;

@ -221,7 +221,7 @@ namespace FLocal.Common.dataobjects {
return new XElement("post", return new XElement("post",
new XElement("id", this.id), new XElement("id", this.id),
new XElement("poster", this.poster.exportToXmlForViewing(context)), new XElement("poster", this.poster.exportToXmlForViewing(context)),
new XElement("bodyShort", context.isPostVisible(this) ? this.bodyShort : ""), new XElement("bodyShort", context.isPostVisible(this) == PostVisibilityEnum.VISIBLE ? this.bodyShort : ""),
new XElement("title", this.title) new XElement("title", this.title)
); );
} }
@ -232,41 +232,53 @@ namespace FLocal.Common.dataobjects {
public XElement exportToXml(UserContext context, params XElement[] additional) { public XElement exportToXml(UserContext context, params XElement[] additional) {
if(!context.isPostVisible(this)) return null; XElement result = null;
XElement result = new XElement("post", switch(context.isPostVisible(this)) {
new XElement("id", this.id), case PostVisibilityEnum.UNVISIBLE:
new XElement("poster", return null;
this.poster.exportToXmlForViewing( case PostVisibilityEnum.HIDDEN:
context, result = new XElement("post",
new XElement("isModerator", Moderator.isModerator(this.poster, this.thread).ToPlainString()), new XElement("hidden"),
new XElement("isAdministrator", (this.thread.board.administrator.userId == this.poster.id).ToPlainString()) new XElement("id", this.id)
) );
), break;
new XElement("postDate", this.postDate.ToXml()), case PostVisibilityEnum.VISIBLE:
new XElement("layerId", this.layerId), result = new XElement("post",
new XElement("layerName", this.layer.name), new XElement("id", this.id),
new XElement("title", this.title), new XElement("poster",
new XElement("body", context.outputParams.preprocessBodyIntermediate(this.body)), this.poster.exportToXmlForViewing(
//this.XMLBody(context), context,
new XElement("bodyShort", this.bodyShort), new XElement("isModerator", Moderator.isModerator(this.poster, this.thread).ToPlainString()),
new XElement("threadId", this.threadId), new XElement("isAdministrator", (this.thread.board.administrator.userId == this.poster.id).ToPlainString())
new XElement("isPunishmentEnabled", ((context.account != null) && Moderator.isModerator(context.account, this.thread)).ToPlainString()), )
new XElement("isOwner", ((context.account != null) && (this.poster.id == context.account.user.id)).ToPlainString()), ),
new XElement( new XElement("postDate", this.postDate.ToXml()),
"specific", new XElement("layerId", this.layerId),
new XElement( new XElement("layerName", this.layer.name),
"changeInfo", new XElement("title", this.title),
new XElement("lastChangeDate", this.lastChangeDate.ToXml()), new XElement("body", context.outputParams.preprocessBodyIntermediate(this.body)),
new XElement("revision", this.revision.ToString()) //this.XMLBody(context),
) new XElement("bodyShort", this.bodyShort),
) new XElement("threadId", this.threadId),
); new XElement("isPunishmentEnabled", ((context.account != null) && Moderator.isModerator(context.account, this.thread)).ToPlainString()),
if(this.totalPunishments > 0) { new XElement("isOwner", ((context.account != null) && (this.poster.id == context.account.user.id)).ToPlainString()),
result.Add(from punishment in punishments select new XElement("specific", punishment.exportToXml(context))); new XElement(
} "specific",
if(this.parentPostId.HasValue) { new XElement(
result.Add(new XElement("parentPost", this.parentPost.exportToXmlBase(context))); "changeInfo",
new XElement("lastChangeDate", this.lastChangeDate.ToXml()),
new XElement("revision", this.revision.ToString())
)
)
);
if(this.totalPunishments > 0) {
result.Add(from punishment in punishments select new XElement("specific", punishment.exportToXml(context)));
}
if(this.parentPostId.HasValue) {
result.Add(new XElement("parentPost", this.parentPost.exportToXmlBase(context)));
}
break;
} }
if(additional.Length > 0) { if(additional.Length > 0) {
result.Add(additional); result.Add(additional);

@ -191,7 +191,7 @@ namespace FLocal.Common.dataobjects {
public XElement exportToXml(UserContext context, params XElement[] additional) { public XElement exportToXml(UserContext context, params XElement[] additional) {
if(!context.isPostVisible(this.firstPost)) return null; if(context.isPostVisible(this.firstPost) != PostVisibilityEnum.VISIBLE) return null;
XElement result = new XElement("thread", XElement result = new XElement("thread",
new XElement("id", this.id), new XElement("id", this.id),

@ -92,7 +92,7 @@ namespace FLocal.IISHandler {
} }
} }
public override bool isPostVisible(Post post) { public override PostVisibilityEnum isPostVisible(Post post) {
return this.userSettings.isPostVisible(post); return this.userSettings.isPostVisible(post);
} }

@ -2,7 +2,21 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="UserInfoBar.xslt"/> <xsl:import href="UserInfoBar.xslt"/>
<xsl:template match="post"> <xsl:template match="post[hidden]">
<tr>
<td>
<a>
<xsl:attribute name="name">Post<xsl:value-of select="id"/></xsl:attribute>
<xsl:comment>fill</xsl:comment>
</a>
<p>Âàì íåëüçÿ âèäåòü ýòîò ñëàäêèé è çàïðåòíûé ïëîä.</p>
<xsl:if test="/root/session/notLoggedIn">
<p>Âîçìîæíî, <a href="/My/Login/Login/">âõîä íà ôîðóì</a> èñïðàâèò ñèòóàöèþ</p>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template match="post[not(hidden)]">
<xsl:param name="isReplyDisabled">true</xsl:param> <xsl:param name="isReplyDisabled">true</xsl:param>
<tr> <tr>
<td> <td>

@ -1,7 +1,23 @@
<?xml version="1.0" encoding="Windows-1251"?> <?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="post"> <xsl:template match="post[not(hidden)]">
<div>
<div class="darktable">
<a>
<xsl:attribute name="name">Post<xsl:value-of select="id"/></xsl:attribute>
<xsl:comment>fill</xsl:comment>
</a>
<div class="lighttable post">
<p>Âŕě íĺëüç˙ âčäĺňü ýňîň ńëŕäęčé č çŕďđĺňíűé ďëîä.</p>
<xsl:if test="/root/session/notLoggedIn">
<p>Âîçěîćíî, <a href="/My/Login/Login/">âőîä íŕ ôîđóě</a> čńďđŕâčň ńčňóŕöčţ</p>
</xsl:if>
</div>
</div>
</div>
</xsl:template>
<xsl:template match="post[hidden]">
<xsl:param name="isReplyDisabled">true</xsl:param> <xsl:param name="isReplyDisabled">true</xsl:param>
<div> <div>
<div class="darktable"> <div class="darktable">

@ -2,10 +2,27 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="UserInfoBar.xslt"/> <xsl:import href="UserInfoBar.xslt"/>
<xsl:template match="post"> <xsl:template match="post[hidden]">
<div class="postcontainer" style="clear:both">
<a>
<xsl:attribute name="name">Post<xsl:value-of select="id"/></xsl:attribute>
<xsl:comment>fill</xsl:comment>
</a>
<div class="postContent">
<p>Âàì íåëüçÿ âèäåòü ýòîò ñëàäêèé è çàïðåòíûé ïëîä.</p>
<xsl:if test="/root/session/notLoggedIn">
<p>Âîçìîæíî, <a href="/My/Login/Login/">âõîä íà ôîðóì</a> èñïðàâèò ñèòóàöèþ</p>
</xsl:if>
</div>
</div>
</xsl:template>
<xsl:template match="post[not(hidden)]">
<xsl:param name="isReplyDisabled">true</xsl:param> <xsl:param name="isReplyDisabled">true</xsl:param>
<div class="postcontainer" style="clear:both"> <div class="postcontainer" style="clear:both">
<a><xsl:attribute name="name">Post<xsl:value-of select="id"/></xsl:attribute></a> <a>
<xsl:attribute name="name">Post<xsl:value-of select="id"/></xsl:attribute>
<xsl:comment>fill</xsl:comment>
</a>
<div class="userbarcontainer" style="float:left"> <div class="userbarcontainer" style="float:left">
<xsl:apply-templates select="poster/user" mode="userInfoBar"/> <xsl:apply-templates select="poster/user" mode="userInfoBar"/>
</div> </div>

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="Windows-1251"?> <?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="post"> <xsl:template match="post[hidden]"/>
<xsl:template match="post[not(hidden)]">
<xsl:if test="not(poster/user/name = /root/session/user/name)"> <xsl:if test="not(poster/user/name = /root/session/user/name)">
<item> <item>
<title> <title>

Loading…
Cancel
Save