Restrictions are shown on UserInfo page

main
Inga 🏳‍🌈 14 years ago
parent 7904c55b41
commit 42b179408e
  1. 2
      Builder/IISMainHandler/build.txt
  2. 18
      Common/dataobjects/Restriction.cs
  3. 1
      IISMainHandler/handlers/response/UserInfoHandler.cs
  4. 43
      templates/Full/UserInfo.xslt

@ -81,6 +81,20 @@ namespace FLocal.Common.dataobjects {
).ToDictionary(); ).ToDictionary();
} }
public XElement exportToXml(UserContext context) {
return new XElement("restriction",
this.user.exportToXmlForViewing(context),
this.board.exportToXmlSimple(context, Board.SubboardsOptions.None),
new XElement("layers",
from kvp in this.data
select PostLayer.LoadById(kvp.Key).exportToXml(
context,
new XElement("restrictionExpires", kvp.Value.ToXml())
)
)
);
}
private static readonly Dictionary<int, Dictionary<int, int?>> restrictionId_cache = new Dictionary<int,Dictionary<int, int?>>(); private static readonly Dictionary<int, Dictionary<int, int?>> restrictionId_cache = new Dictionary<int,Dictionary<int, int?>>();
public static Restriction GetRestriction(User user, Board board) { public static Restriction GetRestriction(User user, Board board) {
@ -171,11 +185,11 @@ namespace FLocal.Common.dataobjects {
select Restriction.LoadById(int.Parse(stringId)).id; select Restriction.LoadById(int.Parse(stringId)).id;
} }
} }
public static IEnumerable<Board> GetRestrictions(User user) { public static IEnumerable<Restriction> GetRestrictions(User user) {
if(!byUser_cache.ContainsKey(user.id)) { if(!byUser_cache.ContainsKey(user.id)) {
byUser_Recalculate(user.id); byUser_Recalculate(user.id);
} }
return from id in byUser_cache[user.id] select Restriction.LoadById(id).board; return from id in byUser_cache[user.id] select Restriction.LoadById(id);
} }
public static void RecalculateRestrictions(Board board, User user) { public static void RecalculateRestrictions(Board board, User user) {

@ -23,6 +23,7 @@ namespace FLocal.IISHandler.handlers.response {
override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) { override protected IEnumerable<XElement> getUserSpecificData(WebContext context, User user) {
return new XElement[] { return new XElement[] {
new XElement("punishments", from punishment in user.getPunishments(Diapasone.unlimited) select punishment.exportToXml(context)), new XElement("punishments", from punishment in user.getPunishments(Diapasone.unlimited) select punishment.exportToXml(context)),
new XElement("restrictions", from restriction in Restriction.GetRestrictions(user) select restriction.exportToXml(context)),
}; };
} }

@ -132,6 +132,27 @@
</xsl:choose> </xsl:choose>
</td> </td>
</tr> </tr>
<tr>
<td valign="top" class="darktable">
<xsl:text>Restrictions</xsl:text>
</td>
<td colspan="2">
<xsl:choose>
<xsl:when test="restrictions/restriction">
<table border="1" width="90%">
<tr class="tdheader">
<td width="20%">Ðàçäåë</td>
<td width="80%">Îãðàíè÷åíèå</td>
</tr>
<xsl:apply-templates select="restrictions/restriction"/>
</table>
</xsl:when>
<xsl:otherwise>
<xsl:text>Íåò</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<tr> <tr>
<td valign="top" class="darktable"> <td valign="top" class="darktable">
<xsl:text>Êîììåíòàðèé</xsl:text> <xsl:text>Êîììåíòàðèé</xsl:text>
@ -170,4 +191,26 @@
</tr> </tr>
</xsl:template> </xsl:template>
<xsl:template match="restriction">
<tr>
<td>
<a>
<xsl:attribute name="href">/Board/<xsl:value-of select="board/id"/>/</xsl:attribute>
<xsl:value-of select="board/name"/>
</a>
</td>
<td>
<xsl:apply-templates select="layers/layer"/>
</td>
</tr>
</xsl:template>
<xsl:template match="restriction/layers/layer">
<xsl:if test="position() &gt; 1"><br/></xsl:if>
<xsl:text>Çàïðåùåíî èñïîëüçîâàíèå ñëîÿ </xsl:text>
<xsl:value-of select="name"/>
<xsl:text> äî </xsl:text>
<xsl:apply-templates select="restrictionExpires" mode="dateTime"/>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
Loading…
Cancel
Save