UserDataHandler implemented

main
Inga 🏳‍🌈 14 years ago
parent bb19104ef5
commit 0d47aa4086
  1. 2
      Builder/IISMainHandler/build.txt
  2. 1
      Common/Common.csproj
  3. 2
      Common/dataobjects/Account.cs
  4. 50
      Common/dataobjects/User.cs
  5. 4
      IISMainHandler/HandlersFactory.cs
  6. 2
      IISMainHandler/IISMainHandler.csproj
  7. 33
      IISMainHandler/handlers/request/UserDataHandler.cs
  8. 28
      IISMainHandler/handlers/response/UserDataHandler.cs
  9. 75
      templates/Full/UserData.xslt
  10. 4
      templates/Full/UserInfo.xslt
  11. 8
      templates/Full/elems/MyHeader.xslt
  12. 2
      templates/Full/elems/PostInfo.xslt
  13. 4
      templates/Lite/UserInfo.xslt

@ -100,6 +100,7 @@
<Compile Include="dataobjects\Post.cs" /> <Compile Include="dataobjects\Post.cs" />
<Compile Include="dataobjects\PostLayer.cs" /> <Compile Include="dataobjects\PostLayer.cs" />
<Compile Include="dataobjects\Punishment.cs" /> <Compile Include="dataobjects\Punishment.cs" />
<Compile Include="dataobjects\PunishmentLayerChange.cs" />
<Compile Include="dataobjects\PunishmentTransfer.cs" /> <Compile Include="dataobjects\PunishmentTransfer.cs" />
<Compile Include="dataobjects\PunishmentType.cs" /> <Compile Include="dataobjects\PunishmentType.cs" />
<Compile Include="dataobjects\QuickLink.cs" /> <Compile Include="dataobjects\QuickLink.cs" />

@ -184,11 +184,13 @@ namespace FLocal.Common.dataobjects {
new Dictionary<string, AbstractFieldValue> { new Dictionary<string, AbstractFieldValue> {
{ User.TableSpec.FIELD_AVATARID, new ScalarFieldValue(null) }, { User.TableSpec.FIELD_AVATARID, new ScalarFieldValue(null) },
{ User.TableSpec.FIELD_BIOGRAPHY, new ScalarFieldValue("") }, { User.TableSpec.FIELD_BIOGRAPHY, new ScalarFieldValue("") },
{ User.TableSpec.FIELD_BIOGRAPHYUBB, new ScalarFieldValue("") },
{ User.TableSpec.FIELD_LOCATION, new ScalarFieldValue("") }, { User.TableSpec.FIELD_LOCATION, new ScalarFieldValue("") },
{ User.TableSpec.FIELD_NAME, new ScalarFieldValue(name) }, { User.TableSpec.FIELD_NAME, new ScalarFieldValue(name) },
{ User.TableSpec.FIELD_REGDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) }, { User.TableSpec.FIELD_REGDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) },
{ User.TableSpec.FIELD_SHOWPOSTSTOUSERS, new ScalarFieldValue(User.ENUM_SHOWPOSTSTOUSERS_ALL) }, { User.TableSpec.FIELD_SHOWPOSTSTOUSERS, new ScalarFieldValue(User.ENUM_SHOWPOSTSTOUSERS_ALL) },
{ User.TableSpec.FIELD_SIGNATURE, new ScalarFieldValue("") }, { User.TableSpec.FIELD_SIGNATURE, new ScalarFieldValue("") },
{ User.TableSpec.FIELD_SIGNATUREUBB, new ScalarFieldValue("") },
{ User.TableSpec.FIELD_TITLE, new ScalarFieldValue("novice") }, { User.TableSpec.FIELD_TITLE, new ScalarFieldValue("novice") },
{ User.TableSpec.FIELD_TOTALPOSTS, new ScalarFieldValue("0") }, { User.TableSpec.FIELD_TOTALPOSTS, new ScalarFieldValue("0") },
{ User.TableSpec.FIELD_USERGROUPID, new ScalarFieldValue("1") }, { User.TableSpec.FIELD_USERGROUPID, new ScalarFieldValue("1") },

@ -6,6 +6,7 @@ using System.Xml.Linq;
using FLocal.Core; using FLocal.Core;
using FLocal.Core.DB; using FLocal.Core.DB;
using FLocal.Core.DB.conditions; using FLocal.Core.DB.conditions;
using FLocal.Common.actions;
namespace FLocal.Common.dataobjects { namespace FLocal.Common.dataobjects {
public class User : SqlObject<User> { public class User : SqlObject<User> {
@ -15,18 +16,27 @@ namespace FLocal.Common.dataobjects {
public const string ENUM_SHOWPOSTSTOUSERS_PRIVELEGED = "Priveleged"; public const string ENUM_SHOWPOSTSTOUSERS_PRIVELEGED = "Priveleged";
public const string ENUM_SHOWPOSTSTOUSERS_NONE = "None"; public const string ENUM_SHOWPOSTSTOUSERS_NONE = "None";
public struct UserData {
public string title;
public string location;
public string signatureUbb;
public string biographyUbb;
}
public class TableSpec : ISqlObjectTableSpec { public class TableSpec : ISqlObjectTableSpec {
public const string TABLE = "Users"; public const string TABLE = "Users";
public const string FIELD_ID = "Id"; public const string FIELD_ID = "Id";
public const string FIELD_REGDATE = "RegDate"; public const string FIELD_REGDATE = "RegDate";
public const string FIELD_TOTALPOSTS = "TotalPosts"; public const string FIELD_TOTALPOSTS = "TotalPosts";
public const string FIELD_SIGNATURE = "Signature"; public const string FIELD_SIGNATURE = "Signature";
public const string FIELD_SIGNATUREUBB = "SignatureUbb";
public const string FIELD_TITLE = "Title"; public const string FIELD_TITLE = "Title";
public const string FIELD_LOCATION = "Location"; public const string FIELD_LOCATION = "Location";
public const string FIELD_NAME = "Name"; public const string FIELD_NAME = "Name";
public const string FIELD_USERGROUPID = "UserGroupId"; public const string FIELD_USERGROUPID = "UserGroupId";
public const string FIELD_SHOWPOSTSTOUSERS = "ShowPostsToUsers"; public const string FIELD_SHOWPOSTSTOUSERS = "ShowPostsToUsers";
public const string FIELD_BIOGRAPHY = "Biography"; public const string FIELD_BIOGRAPHY = "Biography";
public const string FIELD_BIOGRAPHYUBB = "BiographyUbb";
public const string FIELD_AVATARID = "AvatarId"; public const string FIELD_AVATARID = "AvatarId";
public static readonly TableSpec instance = new TableSpec(); public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } } public string name { get { return TABLE; } }
@ -60,6 +70,14 @@ namespace FLocal.Common.dataobjects {
} }
} }
private string _signatureUbb;
public string signatureUbb {
get {
this.LoadIfNotLoaded();
return this._signatureUbb;
}
}
private string _title; private string _title;
public string title { public string title {
get { get {
@ -113,6 +131,14 @@ namespace FLocal.Common.dataobjects {
} }
} }
private string _biographyUbb;
public string biographyUbb {
get {
this.LoadIfNotLoaded();
return this._biographyUbb;
}
}
private int? _avatarId; private int? _avatarId;
public int? avatarId { public int? avatarId {
get { get {
@ -147,12 +173,14 @@ namespace FLocal.Common.dataobjects {
this._regDate = new DateTime(long.Parse(data[TableSpec.FIELD_REGDATE])); this._regDate = new DateTime(long.Parse(data[TableSpec.FIELD_REGDATE]));
this._totalPosts = int.Parse(data[TableSpec.FIELD_TOTALPOSTS]); this._totalPosts = int.Parse(data[TableSpec.FIELD_TOTALPOSTS]);
this._signature = data[TableSpec.FIELD_SIGNATURE]; this._signature = data[TableSpec.FIELD_SIGNATURE];
this._signatureUbb = data[TableSpec.FIELD_SIGNATUREUBB];
this._title = data[TableSpec.FIELD_TITLE]; this._title = data[TableSpec.FIELD_TITLE];
this._location = data[TableSpec.FIELD_LOCATION]; this._location = data[TableSpec.FIELD_LOCATION];
this._name = data[TableSpec.FIELD_NAME]; this._name = data[TableSpec.FIELD_NAME];
this._userGroupId = int.Parse(data[TableSpec.FIELD_USERGROUPID]); this._userGroupId = int.Parse(data[TableSpec.FIELD_USERGROUPID]);
this._showPostsToUsers = data[TableSpec.FIELD_SHOWPOSTSTOUSERS]; this._showPostsToUsers = data[TableSpec.FIELD_SHOWPOSTSTOUSERS];
this._biography = data[TableSpec.FIELD_BIOGRAPHY]; this._biography = data[TableSpec.FIELD_BIOGRAPHY];
this._biographyUbb = data[TableSpec.FIELD_BIOGRAPHYUBB];
this._avatarId = Util.ParseInt(data[TableSpec.FIELD_AVATARID]); this._avatarId = Util.ParseInt(data[TableSpec.FIELD_AVATARID]);
} }
@ -161,7 +189,10 @@ namespace FLocal.Common.dataobjects {
new XElement("id", this.id), new XElement("id", this.id),
new XElement("regDate", this.regDate.ToXml()), new XElement("regDate", this.regDate.ToXml()),
new XElement("totalPosts", this.totalPosts), new XElement("totalPosts", this.totalPosts),
new XElement("signature", this.signature), new XElement("signature", context.outputParams.preprocessBodyIntermediate(this.signature)),
new XElement("signatureUbb", this.signatureUbb),
new XElement("biography", context.outputParams.preprocessBodyIntermediate(this.biography)),
new XElement("biographyUbb", this.biographyUbb),
new XElement("title", this.title), new XElement("title", this.title),
new XElement("location", this.location), new XElement("location", this.location),
new XElement("name", this.name), new XElement("name", this.name),
@ -276,5 +307,22 @@ namespace FLocal.Common.dataobjects {
); );
} }
public void UpdateData(UserData newData) {
ChangeSetUtil.ApplyChanges(
new UpdateChange(
TableSpec.instance,
new Dictionary<string,AbstractFieldValue> {
{ TableSpec.FIELD_LOCATION, new ScalarFieldValue(newData.location) },
{ TableSpec.FIELD_TITLE, new ScalarFieldValue(newData.title) },
{ TableSpec.FIELD_BIOGRAPHYUBB, new ScalarFieldValue(newData.biographyUbb) },
{ TableSpec.FIELD_BIOGRAPHY, new ScalarFieldValue(UBBParser.UBBToIntermediate(newData.biographyUbb)) },
{ TableSpec.FIELD_SIGNATUREUBB, new ScalarFieldValue(newData.signatureUbb) },
{ TableSpec.FIELD_SIGNATURE, new ScalarFieldValue(UBBParser.UBBToIntermediate(newData.signatureUbb)) },
},
this.id
)
);
}
} }
} }

@ -100,6 +100,8 @@ namespace FLocal.IISHandler {
} }
case "settings": case "settings":
return new handlers.response.SettingsHandler(); return new handlers.response.SettingsHandler();
case "userdata":
return new handlers.response.UserDataHandler();
case "conversations": case "conversations":
if(context.requestParts.Length == 2) { if(context.requestParts.Length == 2) {
return new handlers.response.ConversationsHandler(); return new handlers.response.ConversationsHandler();
@ -224,6 +226,8 @@ namespace FLocal.IISHandler {
return new handlers.request.CreateThreadHandler(); return new handlers.request.CreateThreadHandler();
case "settings": case "settings":
return new handlers.request.SettingsHandler(); return new handlers.request.SettingsHandler();
case "userdata":
return new handlers.request.UserDataHandler();
case "sendpm": case "sendpm":
return new handlers.request.SendPMHandler(); return new handlers.request.SendPMHandler();
case "markthreadasread": case "markthreadasread":

@ -144,6 +144,8 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="handlers\request\UserDataHandler.cs" />
<Compile Include="handlers\response\UserDataHandler.cs" />
<Compile Include="handlers\response\UserThreadsHandler.cs" /> <Compile Include="handlers\response\UserThreadsHandler.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.request {
class UserDataHandler : AbstractPostHandler {
protected override string templateName {
get {
return "result/SettingsSaved.xslt";
}
}
protected override XElement[] Do(WebContext context) {
User.UserData newData = new User.UserData {
location = context.httprequest.Form["location"],
title = context.httprequest.Form["title"],
signatureUbb = context.httprequest.Form["signature"],
biographyUbb = context.httprequest.Form["biography"],
};
context.account.user.UpdateData(newData);
return new XElement[0];
}
}
}

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml.Linq;
using FLocal.Core;
using FLocal.Common;
using FLocal.Common.dataobjects;
namespace FLocal.IISHandler.handlers.response {
class UserDataHandler : AbstractGetHandler {
override protected string templateName {
get {
return "UserData.xslt";
}
}
override protected IEnumerable<XElement> getSpecificData(WebContext context) {
return new XElement[] {
context.account.user.exportToXmlForViewing(context),
};
}
}
}

@ -0,0 +1,75 @@
<?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:import href="elems\Main.xslt"/>
<xsl:template name="specificTitle">Ëè÷íûå äàííûå</xsl:template>
<xsl:template name="specific">
<table width="95%" align="center" cellpadding="1" cellspacing="1" class="tablesurround">
<tr>
<td>
<table cellpadding="3" cellspacing="1" width="100%" class="tableborders">
<tr>
<td class="tdheader">
<xsl:text>Èçìåíåíèå ëè÷íûõ äàííûõ</xsl:text>
</td>
</tr>
<tr class="darktable">
<td>
<xsl:text>???</xsl:text>
</td>
</tr>
<tr>
<td class="lighttable">
<form method="post" action="/do/UserData/">
<p>
<xsl:text>Òèòóë</xsl:text>
<br/>
<input type="text" name="title">
<xsl:attribute name="value"><xsl:value-of select="user/title"/></xsl:attribute>
</input>
</p>
<p>
<xsl:text>Èç:</xsl:text>
<br/>
<input type="text" name="location">
<xsl:attribute name="value"><xsl:value-of select="user/location"/></xsl:attribute>
</input>
</p>
<p>
<xsl:text>Áèîãðàôèÿ:</xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="4" class="formboxes" name="biography">
<xsl:choose>
<xsl:when test="user/biographyUbb">
<xsl:value-of select="user/biographyUbb"/>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</textarea>
</p>
<p>
<xsl:text>Ïîäïèñü:</xsl:text>
<br/>
<textarea cols="100" tabindex="2" rows="4" class="formboxes" name="signature">
<xsl:choose>
<xsl:when test="user/signatureUbb">
<xsl:value-of select="user/signatureUbb"/>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</textarea>
</p>
<input type="submit" name="buttlogin" value="Îòïðàâèòü!" class="buttons" />
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

@ -112,7 +112,7 @@
<xsl:text>Áèîãðàôèÿ</xsl:text> <xsl:text>Áèîãðàôèÿ</xsl:text>
</td> </td>
<td colspan="2"> <td colspan="2">
<xsl:value-of select="user/biography"/> <xsl:value-of select="user/biography" disable-output-escaping="yes" />
</td> </td>
</tr> </tr>
<tr> <tr>
@ -152,7 +152,7 @@
<xsl:text>Ïîäïèñü</xsl:text> <xsl:text>Ïîäïèñü</xsl:text>
</td> </td>
<td> <td>
<xsl:value-of select="user/signature"/> <xsl:value-of select="user/signature" disable-output-escaping="yes" />
</td> </td>
</tr> </tr>
<tr> <tr>

@ -45,6 +45,14 @@
</xsl:with-param> </xsl:with-param>
</xsl:call-template> </xsl:call-template>
<xsl:text> | </xsl:text> <xsl:text> | </xsl:text>
<xsl:call-template name="headerLink">
<xsl:with-param name="url">/My/UserData/</xsl:with-param>
<xsl:with-param name="text">Ëè÷íûå äàííûå</xsl:with-param>
<xsl:with-param name="isDisabled">
<xsl:if test="not(session/sessionKey)">true</xsl:if>
</xsl:with-param>
</xsl:call-template>
<xsl:text> | </xsl:text>
<a target="_top"> <a target="_top">
<xsl:if test="session/sessionKey"> <xsl:if test="session/sessionKey">
<xsl:attribute name="href">/do/Logout/?sessionKey=<xsl:value-of select="session/sessionKey"/></xsl:attribute> <xsl:attribute name="href">/do/Logout/?sessionKey=<xsl:value-of select="session/sessionKey"/></xsl:attribute>

@ -138,7 +138,7 @@
<tr> <tr>
<td> <td>
<div style="width:100%;max-height:50px;height: expression( this.scrollHeight > 49 ? '50px' : 'auto' );overflow:hidden"> <div style="width:100%;max-height:50px;height: expression( this.scrollHeight > 49 ? '50px' : 'auto' );overflow:hidden">
<font size="-2"><xsl:value-of select="poster/user/signature"/><br /></font> <font size="-2"><xsl:value-of select="poster/user/signature" disable-output-escaping="yes" /><br /></font>
</div> </div>
</td> </td>
</tr> </tr>

@ -112,7 +112,7 @@
<xsl:text>Áèîãðàôèÿ</xsl:text> <xsl:text>Áèîãðàôèÿ</xsl:text>
</td> </td>
<td colspan="2"> <td colspan="2">
<xsl:value-of select="user/biography"/> <xsl:value-of select="user/biography" disable-output-escaping="yes" />
</td> </td>
</tr> </tr>
<tr> <tr>
@ -152,7 +152,7 @@
<xsl:text>Ïîäïèñü</xsl:text> <xsl:text>Ïîäïèñü</xsl:text>
</td> </td>
<td> <td>
<xsl:value-of select="user/signature"/> <xsl:value-of select="user/signature" disable-output-escaping="yes" />
</td> </td>
</tr> </tr>
<tr> <tr>

Loading…
Cancel
Save