diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 5f7b1b0..50b04df 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -399 \ No newline at end of file +402 \ No newline at end of file diff --git a/Builder/IISUploadHandler/build.txt b/Builder/IISUploadHandler/build.txt index b9c6c00..fa59ff2 100644 --- a/Builder/IISUploadHandler/build.txt +++ b/Builder/IISUploadHandler/build.txt @@ -1 +1 @@ -131 \ No newline at end of file +134 \ No newline at end of file diff --git a/Common/Common.csproj b/Common/Common.csproj index 66cc857..8df3d7f 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -63,6 +63,7 @@ + diff --git a/Common/dataobjects/Board.cs b/Common/dataobjects/Board.cs index 0616386..6f59d7c 100644 --- a/Common/dataobjects/Board.cs +++ b/Common/dataobjects/Board.cs @@ -308,9 +308,9 @@ namespace FLocal.Common.dataobjects { } } - public Thread CreateThread(User poster, string title, string body, int desiredLayerId) { + public Thread CreateThread(User poster, string title, string body, PostLayer desiredLayer) { - int actualLayerId = Math.Max(poster.getMinAllowedLayer(this), desiredLayerId); + PostLayer actualLayer = poster.getActualLayer(this, desiredLayer); AbstractChange threadInsert = new InsertChange( Thread.TableSpec.instance, new Dictionary { @@ -331,7 +331,7 @@ namespace FLocal.Common.dataobjects { Config.Transactional(transaction => { threadInsertSet.Add(threadInsert); threadInsertSet.Apply(transaction); - foreach(AbstractChange change in Thread.getNewPostChanges(this, threadInsert.getId().Value, null, poster, actualLayerId, title, body).Value) { + foreach(AbstractChange change in Thread.getNewPostChanges(this, threadInsert.getId().Value, null, poster, actualLayer, title, body).Value) { dataInsertSet.Add(change); } dataInsertSet.Apply(transaction); diff --git a/Common/dataobjects/Post.cs b/Common/dataobjects/Post.cs index 3a623b3..a8245b5 100644 --- a/Common/dataobjects/Post.cs +++ b/Common/dataobjects/Post.cs @@ -90,6 +90,11 @@ namespace FLocal.Common.dataobjects { return this._layerId; } } + public PostLayer layer { + get { + return PostLayer.LoadById(this.layerId); + } + } private string _title; public string title { @@ -175,6 +180,7 @@ namespace FLocal.Common.dataobjects { new XElement("lastChangeDate", this.postDate.ToXml()), new XElement("revision", this.revision), new XElement("layerId", this.layerId), + new XElement("layerName", this.layer.name), new XElement("title", this.title), new XElement("body", context.outputParams.preprocessBodyIntermediate(this.body)), new XElement("bodyShort", this.bodyShort), @@ -191,15 +197,15 @@ namespace FLocal.Common.dataobjects { return result; } - public Post Reply(User poster, string title, string body, int desiredLayerId) { + public Post Reply(User poster, string title, string body, PostLayer desiredLayer) { if(this.thread.isLocked) { throw new FLocalException("thread locked"); } - int actualLayerId = Math.Max(poster.getMinAllowedLayer(this.thread.board), desiredLayerId); + PostLayer actualLayer = poster.getActualLayer(this.thread.board, desiredLayer); - var changes = Thread.getNewPostChanges(this.thread.board, this.threadId, this, poster, actualLayerId, title, body); + var changes = Thread.getNewPostChanges(this.thread.board, this.threadId, this, poster, actualLayer, title, body); ChangeSetUtil.ApplyChanges(changes.Value.ToArray()); return Post.LoadById(changes.Key.getId().Value); diff --git a/Common/dataobjects/PostLayer.cs b/Common/dataobjects/PostLayer.cs new file mode 100644 index 0000000..faeb313 --- /dev/null +++ b/Common/dataobjects/PostLayer.cs @@ -0,0 +1,75 @@ +п»їusing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Linq; +using FLocal.Core; +using FLocal.Core.DB; +using FLocal.Core.DB.conditions; + +namespace FLocal.Common.dataobjects { + public class PostLayer : SqlObject { + + public const string NAME_NORMAL = "normal"; + public const string NAME_OFFTOP = "offtop"; + public const string NAME_GARBAGE = "garbage"; + public const string NAME_HIDDEN = "hidden"; + + public class TableSpec : ISqlObjectTableSpec { + public const string TABLE = "Layers"; + public const string FIELD_ID = "Id"; + public const string FIELD_NAME = "Name"; + public static readonly TableSpec instance = new TableSpec(); + public string name { get { return TABLE; } } + public string idName { get { return FIELD_ID; } } + public void refreshSqlObject(int id) { Refresh(id); } + } + + protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } } + + private string _name; + public string name { + get { + this.LoadIfNotLoaded(); + return this._name; + } + } + + protected override void doFromHash(Dictionary data) { + this._name = data[TableSpec.FIELD_NAME]; + } + + private static readonly object allLayers_Locker = new object(); + public static IEnumerable allLayers { + get { + return + from id in Cache>.instance.get( + allLayers_Locker, + () => { + IEnumerable ids = from stringId in Config.instance.mainConnection.LoadIdsByConditions( + TableSpec.instance, + new FLocal.Core.DB.conditions.EmptyCondition(), + Diapasone.unlimited + ) select int.Parse(stringId); + Category.LoadByIds(ids); + return ids; + } + ) + let layer = PostLayer.LoadById(id) + orderby layer.id + select layer; + } + } + internal static void allLayers_Reset() { + Cache>.instance.delete(allLayers_Locker); + } + + public XElement exportToXml(UserContext context) { + return new XElement("layer", + new XElement("id", this.id), + new XElement("name", this.name) + ); + } + + } +} diff --git a/Common/dataobjects/Thread.cs b/Common/dataobjects/Thread.cs index 11dbf7b..1385a02 100644 --- a/Common/dataobjects/Thread.cs +++ b/Common/dataobjects/Thread.cs @@ -174,6 +174,7 @@ namespace FLocal.Common.dataobjects { new XElement("totalViews", this.totalViews), new XElement("bodyShort", this.firstPost.bodyShort), new XElement("layerId", this.firstPost.layerId), + new XElement("layerName", this.firstPost.layer.name), context.formatTotalPosts(this.totalPosts) ); if(includeFirstPost) { @@ -358,7 +359,7 @@ namespace FLocal.Common.dataobjects { }); } - internal static KeyValuePair> getNewPostChanges(Board board, int threadId, Post parentPost, User poster, int layerId, string title, string body) { + internal static KeyValuePair> getNewPostChanges(Board board, int threadId, Post parentPost, User poster, PostLayer layer, string title, string body) { string parentPostId = null; if(parentPost != null) parentPostId = parentPost.id.ToString(); bool isNewThread = (parentPost == null); @@ -371,7 +372,7 @@ namespace FLocal.Common.dataobjects { { Post.TableSpec.FIELD_POSTDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) }, { Post.TableSpec.FIELD_REVISION, new ScalarFieldValue("0") }, { Post.TableSpec.FIELD_LASTCHANGEDATE, new ScalarFieldValue(DateTime.Now.ToUTCString()) }, - { Post.TableSpec.FIELD_LAYERID, new ScalarFieldValue(layerId.ToString()) }, + { Post.TableSpec.FIELD_LAYERID, new ScalarFieldValue(layer.id.ToString()) }, { Post.TableSpec.FIELD_TITLE, new ScalarFieldValue(title) }, { Post.TableSpec.FIELD_BODY, new ScalarFieldValue(UBBParser.UBBToIntermediate(body)) }, } diff --git a/Common/dataobjects/User.cs b/Common/dataobjects/User.cs index 68b99a1..bbaf3ff 100644 --- a/Common/dataobjects/User.cs +++ b/Common/dataobjects/User.cs @@ -197,8 +197,8 @@ namespace FLocal.Common.dataobjects { ); } - public int getMinAllowedLayer(Board board) { - return 1; + public PostLayer getActualLayer(Board board, PostLayer desiredLayer) { + return desiredLayer; } } diff --git a/IISMainHandler/handlers/request/CreateThreadHandler.cs b/IISMainHandler/handlers/request/CreateThreadHandler.cs index ad5598b..3e5a5ac 100644 --- a/IISMainHandler/handlers/request/CreateThreadHandler.cs +++ b/IISMainHandler/handlers/request/CreateThreadHandler.cs @@ -16,7 +16,7 @@ namespace FLocal.IISHandler.handlers.request { context.session.account.user, this.getTitle(context), this.getBody(context), - int.Parse(context.httprequest.Form["layerId"]) + PostLayer.LoadById(int.Parse(context.httprequest.Form["layerId"])) ); Post newPost = newThread.firstPost; diff --git a/IISMainHandler/handlers/request/ReplyHandler.cs b/IISMainHandler/handlers/request/ReplyHandler.cs index fd23132..56d1409 100644 --- a/IISMainHandler/handlers/request/ReplyHandler.cs +++ b/IISMainHandler/handlers/request/ReplyHandler.cs @@ -18,7 +18,7 @@ namespace FLocal.IISHandler.handlers.request { context.session.account.user, this.getTitle(context), this.getBody(context), - int.Parse(context.httprequest.Form["layerId"]) + PostLayer.LoadById(int.Parse(context.httprequest.Form["layerId"])) ); newPost.thread.markAsRead(context.session.account, newPost, newPost); diff --git a/IISMainHandler/handlers/response/CreateThreadHandler.cs b/IISMainHandler/handlers/response/CreateThreadHandler.cs index a39f637..485bc48 100644 --- a/IISMainHandler/handlers/response/CreateThreadHandler.cs +++ b/IISMainHandler/handlers/response/CreateThreadHandler.cs @@ -23,6 +23,9 @@ namespace FLocal.IISHandler.handlers.response { return new XElement[] { board.exportToXml(context, false), + new XElement("layers", + from layer in PostLayer.allLayers select layer.exportToXml(context) + ), }; } } diff --git a/IISMainHandler/handlers/response/ReplyHandler.cs b/IISMainHandler/handlers/response/ReplyHandler.cs index 04b2d11..e5079fc 100644 --- a/IISMainHandler/handlers/response/ReplyHandler.cs +++ b/IISMainHandler/handlers/response/ReplyHandler.cs @@ -25,6 +25,9 @@ namespace FLocal.IISHandler.handlers.response { post.thread.board.exportToXml(context, false), post.thread.exportToXml(context, false), post.exportToXmlWithoutThread(context, false), + new XElement("layers", + from layer in PostLayer.allLayers select layer.exportToXml(context) + ), }; } } diff --git a/static/images/message-3-notread.gif b/static/images/message-garbage-notread.gif similarity index 100% rename from static/images/message-3-notread.gif rename to static/images/message-garbage-notread.gif diff --git a/static/images/message-3-read.gif b/static/images/message-garbage-read.gif similarity index 100% rename from static/images/message-3-read.gif rename to static/images/message-garbage-read.gif diff --git a/static/images/message-1-notread.gif b/static/images/message-normal-notread.gif similarity index 100% rename from static/images/message-1-notread.gif rename to static/images/message-normal-notread.gif diff --git a/static/images/message-1-read.gif b/static/images/message-normal-read.gif similarity index 100% rename from static/images/message-1-read.gif rename to static/images/message-normal-read.gif diff --git a/static/images/message-2-notread.gif b/static/images/message-offtop-notread.gif similarity index 100% rename from static/images/message-2-notread.gif rename to static/images/message-offtop-notread.gif diff --git a/static/images/message-2-read.gif b/static/images/message-offtop-read.gif similarity index 100% rename from static/images/message-2-read.gif rename to static/images/message-offtop-read.gif diff --git a/templates/Full/NewThread.xslt b/templates/Full/NewThread.xslt index 34ea165..1769633 100644 --- a/templates/Full/NewThread.xslt +++ b/templates/Full/NewThread.xslt @@ -34,9 +34,9 @@ Слой сообщения:

diff --git a/templates/Full/PostReply.xslt b/templates/Full/PostReply.xslt index 288e796..a4ab849 100644 --- a/templates/Full/PostReply.xslt +++ b/templates/Full/PostReply.xslt @@ -46,24 +46,9 @@ Слой сообщения:

diff --git a/templates/Full/elems/PostInfo.xslt b/templates/Full/elems/PostInfo.xslt index 4489c70..7589ab8 100644 --- a/templates/Full/elems/PostInfo.xslt +++ b/templates/Full/elems/PostInfo.xslt @@ -21,10 +21,10 @@ - /static/images/message--notread.gif + /static/images/message--notread.gif - /static/images/message--read.gif + /static/images/message--read.gif diff --git a/templates/Full/elems/TextEditor.xslt b/templates/Full/elems/TextEditor.xslt index f44e16f..fc6e18f 100644 --- a/templates/Full/elems/TextEditor.xslt +++ b/templates/Full/elems/TextEditor.xslt @@ -241,5 +241,15 @@ function insertInBody(str) { + + + + \ No newline at end of file diff --git a/templates/Full/elems/ThreadInfo.xslt b/templates/Full/elems/ThreadInfo.xslt index 1c664bb..b7b3f64 100644 --- a/templates/Full/elems/ThreadInfo.xslt +++ b/templates/Full/elems/ThreadInfo.xslt @@ -16,10 +16,10 @@ * - /static/images/message--notread.gif + /static/images/message--notread.gif - /static/images/message--read.gif + /static/images/message--read.gif