Пример #1
0
        public static ForumTopic Create(Core core, Forum forum, string subject, string text, TopicStates status)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (forum == null)
            {
                throw new InvalidForumException();
            }

            core.Db.BeginTransaction();

            if (!forum.Access.Can("CREATE_TOPICS"))
            {
                // todo: throw new exception
                throw new UnauthorisedToCreateItemException();
            }

            if ((status == TopicStates.Announcement || status == TopicStates.Global) && (!forum.Access.Can("CREATE_ANNOUNCEMENTS")))
            {
                throw new UnauthorisedToCreateItemException();
            }

            if (status == TopicStates.Sticky && (!forum.Access.Can("CREATE_STICKY")))
            {
                throw new UnauthorisedToCreateItemException();
            }

            if (forum.Owner is UserGroup)
            {
                ForumSettings settings = new ForumSettings(core, (UserGroup)forum.Owner);

                if (forum.Id == 0 && (!settings.AllowTopicsAtRoot))
                {
                    throw new UnauthorisedToCreateItemException();
                }

                if (!((UserGroup)forum.Owner).IsGroupOperator(core.Session.LoggedInMember.ItemKey))
                {
                    status = TopicStates.Normal;
                }
            }

            InsertQuery iquery = new InsertQuery(ForumTopic.GetTable(typeof(ForumTopic)));
            iquery.AddField("forum_id", forum.Id);
            iquery.AddField("topic_title", subject);
            iquery.AddField("user_id", core.LoggedInMemberId);
            iquery.AddField("topic_posts", 0);
            iquery.AddField("topic_views", 0);
            iquery.AddField("topic_time_ut", UnixTime.UnixTimeStamp());
            iquery.AddField("topic_modified_ut", UnixTime.UnixTimeStamp());
            iquery.AddField("topic_last_post_time_ut", UnixTime.UnixTimeStamp());
            iquery.AddField("topic_status", (byte)status);
            iquery.AddField("topic_locked", false);
            iquery.AddField("topic_last_post_id", 0);
            iquery.AddField("topic_first_post_id", 0);
            iquery.AddField("topic_item_id", forum.Owner.Id);
            iquery.AddField("topic_item_type_id", forum.Owner.TypeId);

            long topicId = core.Db.Query(iquery);

            ForumTopic topic = new ForumTopic(core, forum, topicId);

            TopicPost post = TopicPost.Create(core, forum, topic, subject, text);

            UpdateQuery uQuery = new UpdateQuery(ForumTopic.GetTable(typeof(ForumTopic)));
            uQuery.AddField("topic_first_post_id", post.Id);
            uQuery.AddField("topic_last_post_id", post.Id);
            uQuery.AddField("topic_last_post_time_ut", post.TimeCreatedRaw);
            uQuery.AddCondition("topic_id", topic.Id);

            long rowsUpdated = core.Db.Query(uQuery);

            topic.firstPostId = post.Id;
            topic.lastPostId = post.Id;
            topic.lastPostTimeRaw = post.TimeCreatedRaw;

            if (rowsUpdated != 1)
            {
                core.Db.RollBackTransaction();
                core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
            }

            if (forum.Id > 0)
            {
                List<long> parentForumIds = new List<long>();
                parentForumIds.Add(forum.Id);

                if (forum.Parents != null)
                {
                    foreach (ParentTreeNode ptn in forum.Parents.Nodes)
                    {
                        parentForumIds.Add(ptn.ParentId);
                    }
                }

                uQuery = new UpdateQuery(Forum.GetTable(typeof(Forum)));
                uQuery.AddField("forum_posts", new QueryOperation("forum_posts", QueryOperations.Addition, 1));
                uQuery.AddField("forum_topics", new QueryOperation("forum_topics", QueryOperations.Addition, 1));
                uQuery.AddField("forum_last_post_id", post.Id);
                uQuery.AddField("forum_last_post_time_ut", post.TimeCreatedRaw);
                uQuery.AddCondition("forum_id", ConditionEquality.In, parentForumIds);

                rowsUpdated = core.Db.Query(uQuery);

                if (rowsUpdated < 1)
                {
                    core.Db.RollBackTransaction();
                    core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
                }

                uQuery = new UpdateQuery(Forum.GetTable(typeof(Forum)));
                uQuery.AddField("forum_topics", new QueryOperation("forum_topics_paged", QueryOperations.Addition, 1));
                uQuery.AddCondition("forum_id", forum.Id);

                rowsUpdated = core.Db.Query(uQuery);

                if (rowsUpdated < 1)
                {
                    core.Db.RollBackTransaction();
                    core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
                }
            }

            uQuery = new UpdateQuery(ForumSettings.GetTable(typeof(ForumSettings)));
            uQuery.AddField("forum_posts", new QueryOperation("forum_posts", QueryOperations.Addition, 1));
            uQuery.AddField("forum_topics", new QueryOperation("forum_topics", QueryOperations.Addition, 1));
            uQuery.AddCondition("forum_item_id", forum.Owner.Id);
            uQuery.AddCondition("forum_item_type_id", forum.Owner.TypeId);

            rowsUpdated = core.Db.Query(uQuery);

            if (rowsUpdated != 1)
            {
                core.Db.RollBackTransaction();
                core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
            }

            /*uQuery = new UpdateQuery(ForumMember.GetTable(typeof(ForumMember)));
            uQuery.AddField("posts", new QueryOperation("posts", QueryOperations.Addition, 1));
            uQuery.AddCondition("user_id", core.session.LoggedInMember.Id);
            uQuery.AddCondition("item_id", forum.Owner.Id);
            uQuery.AddCondition("item_type_id", forum.Owner.TypeId);

            rowsUpdated = core.db.Query(uQuery);

            if (rowsUpdated == 0)
            {
                ForumMember fm = ForumMember.Create(core, forum.Owner, core.session.LoggedInMember, true);

                uQuery = new UpdateQuery(ForumMember.GetTable(typeof(ForumMember)));
                uQuery.AddField("posts", new QueryOperation("posts", QueryOperations.Addition, 1));
                uQuery.AddCondition("user_id", core.session.LoggedInMember.Id);
                uQuery.AddCondition("item_id", forum.Owner.Id);
                uQuery.AddCondition("item_type_id", forum.Owner.TypeId);

                core.db.Query(uQuery);
            }*/

            ForumMember fm = null;

            try
            {
                fm = new ForumMember(core, forum.Owner, core.Session.LoggedInMember);
            }
            catch (InvalidForumMemberException)
            {
                fm = ForumMember.Create(core, forum.Owner, core.Session.LoggedInMember, true);
            }

            fm.ForumPosts += 1;

            /*Dictionary<long, ForumMemberRank> ranks = ForumMemberRank.GetRanks(core, forum.Owner);

            if (!(ranks.ContainsKey(fm.ForumRankId) && ranks[fm.ForumRankId].RankSpecial))
            {
                int rankLastMin = 0;
                foreach (ForumMemberRank rank in ranks.Values)
                {
                    if ((!rank.RankSpecial) && fm.ForumPosts >= rank.RankPosts && rank.RankPosts > rankLastMin)
                    {
                        fm.ForumRankId = rank.Id;
                        rankLastMin = rank.RankPosts;
                    }
                }
            }*/

            fm.Update(typeof(ForumMember));

            return topic;
        }
Пример #2
0
        public TopicPost AddReply(Core core, Forum forum, string subject, string text)
        {
            db.BeginTransaction();

            TopicPost post = TopicPost.Create(core, forum, this, subject, text);

            topicPosts++;

            UpdateQuery uQuery = new UpdateQuery(ForumTopic.GetTable(typeof(ForumTopic)));
            uQuery.AddField("topic_posts", new QueryOperation("topic_posts", QueryOperations.Addition, 1));
            uQuery.AddField("topic_last_post_id", post.Id);
            uQuery.AddField("topic_last_post_time_ut", post.TimeCreatedRaw);
            uQuery.AddCondition("topic_id", post.TopicId);

            long rowsUpdated = db.Query(uQuery);

            if (rowsUpdated != 1)
            {
                db.RollBackTransaction();
                core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
            }

            if (forumId > 0)
            {
                List<long> parentForumIds = new List<long>();
                parentForumIds.Add(Forum.Id);

                if (Forum.Parents != null)
                {
                    foreach (ParentTreeNode ptn in Forum.Parents.Nodes)
                    {
                        parentForumIds.Add(ptn.ParentId);
                    }
                }

                uQuery = new UpdateQuery(Forum.GetTable(typeof(Forum)));
                uQuery.AddField("forum_posts", new QueryOperation("forum_posts", QueryOperations.Addition, 1));
                uQuery.AddField("forum_last_post_id", post.Id);
                uQuery.AddField("forum_last_post_time_ut", post.TimeCreatedRaw);
                uQuery.AddCondition("forum_id", ConditionEquality.In, parentForumIds);

                rowsUpdated = db.Query(uQuery);

                if (rowsUpdated < 1)
                {
                    db.RollBackTransaction();
                    core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
                }
            }

            uQuery = new UpdateQuery(ForumSettings.GetTable(typeof(ForumSettings)));
            uQuery.AddField("forum_posts", new QueryOperation("forum_posts", QueryOperations.Addition, 1));
            uQuery.AddCondition("forum_item_id", Forum.Owner.Id);
            uQuery.AddCondition("forum_item_type_id", Forum.Owner.TypeId);

            rowsUpdated = db.Query(uQuery);

            if (rowsUpdated != 1)
            {
                db.RollBackTransaction();
                core.Display.ShowMessage("ERROR", "Error, rolling back transaction");
            }

            /*uQuery = new UpdateQuery(ForumMember.GetTable(typeof(ForumMember)));
            uQuery.AddField("posts", new QueryOperation("posts", QueryOperations.Addition, 1));
            uQuery.AddCondition("user_id", core.session.LoggedInMember.Id);
            uQuery.AddCondition("item_id", Forum.Owner.Id);
            uQuery.AddCondition("item_type_id", Forum.Owner.TypeId);

            rowsUpdated = db.Query(uQuery);

            if (rowsUpdated == 0)
            {
                ForumMember fm = ForumMember.Create(core, Forum.Owner, core.session.LoggedInMember, true);

                uQuery = new UpdateQuery(ForumMember.GetTable(typeof(ForumMember)));
                uQuery.AddField("posts", new QueryOperation("posts", QueryOperations.Addition, 1));
                uQuery.AddCondition("user_id", core.session.LoggedInMember.Id);
                uQuery.AddCondition("item_id", Forum.Owner.Id);
                uQuery.AddCondition("item_type_id", Forum.Owner.TypeId);

                db.Query(uQuery);
            }*/

            ForumMember fm = null;

            try
            {
                fm = new ForumMember(core, Forum.Owner, core.Session.LoggedInMember);
            }
            catch (InvalidForumMemberException)
            {
                fm = ForumMember.Create(core, Forum.Owner, core.Session.LoggedInMember, true);
            }

            fm.ForumPosts += 1;

            /*Dictionary<long, ForumMemberRank> ranks = ForumMemberRank.GetRanks(core, Forum.Owner);

            if (!(ranks.ContainsKey(fm.ForumRankId) && ranks[fm.ForumRankId].RankSpecial))
            {
                int rankLastMin = 0;
                foreach (ForumMemberRank rank in ranks.Values)
                {
                    if ((!rank.RankSpecial) && fm.ForumPosts >= rank.RankPosts && rank.RankPosts > rankLastMin)
                    {
                        fm.ForumRankId = rank.Id;
                        rankLastMin = rank.RankPosts;
                    }
                }
            }*/

            fm.Update(typeof(ForumMember));

            return post;
        }
Пример #3
0
        private static void Save(Core core, PPage page)
        {
            AccountSubModule.AuthoriseRequestSid(core);

            if (core.Session.IsLoggedIn && core.Session.LoggedInMember != null)
            {
                ForumMember member = null;

                try
                {
                    member = new ForumMember(core, page.Owner, core.Session.LoggedInMember);
                }
                catch (InvalidForumMemberException)
                {
                    member = ForumMember.Create(core, page.Owner, core.Session.LoggedInMember, false);
                }
                member.ForumSignature = core.Http.Form["signature"];

                member.Update(typeof(ForumMember));

                core.Display.ShowMessage("Profile Updated", "Your forum profile has been saved in the database.");

                core.Template.Parse("REDIRECT_URI", core.Hyperlink.AppendSid(string.Format("{0}forum/ucp",
                    page.Owner.UriStub)));
            }
        }
Пример #4
0
        private void ShowPostingScreen(string submitMode, ShowPPageEventArgs e)
        {
            long forumId = core.Functions.FormLong("f", core.Functions.RequestLong("f", 0));
            long topicId = core.Functions.FormLong("t", core.Functions.RequestLong("t", 0));
            long postId = core.Functions.FormLong("p", core.Functions.RequestLong("p", 0));
            string subject = core.Http.Form["subject"];
            string text = core.Http.Form["post"];
            string mode = core.Http.Query["mode"];
            string topicState = core.Http.Form["topic-state"];

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "forum", core.Prose.GetString("FORUM") });

            if (string.IsNullOrEmpty(mode))
            {
                mode = core.Http.Form["mode"];
            }

            if (string.IsNullOrEmpty(topicState))
            {
                topicState = ((byte)TopicStates.Normal).ToString();
            }

            List<SelectBoxItem> sbis = new List<SelectBoxItem>();
            sbis.Add(new SelectBoxItem(((byte)TopicStates.Normal).ToString(), "Topic"));

            if (page is GPage)
            {
                core.Template.Parse("S_POST", core.Hyperlink.AppendSid(string.Format("{0}forum/post",
                    ((GPage)page).Group.UriStub), true));

                if (((GPage)page).Group.IsGroupOperator(core.Session.LoggedInMember.ItemKey) && topicId == 0)
                {
                    // TODO: Global, remember to update columns to 4
                }
            }

            if (topicId > 0)
            {
                ForumTopic thisTopic = new ForumTopic(core, topicId);

                List<TopicPost> posts = thisTopic.GetLastPosts(10);

                if (posts.Count > 0)
                {
                    core.Template.Parse("PREVIEW_TOPIC", "TRUE");
                }

                foreach (TopicPost post in posts)
                {
                    VariableCollection postVariableCollection = core.Template.CreateChild("post_list");

                    postVariableCollection.Parse("SUBJECT", post.Title);
                    postVariableCollection.Parse("POST_TIME", core.Tz.DateTimeToString(post.GetCreatedDate(core.Tz)));
                    //postVariableCollection.Parse("POST_MODIFIED", core.tz.DateTimeToString(post.GetModifiedDate(core.tz)));
                    postVariableCollection.Parse("ID", post.Id.ToString());
                    core.Display.ParseBbcode(postVariableCollection, "TEXT", post.Text);
                    postVariableCollection.Parse("U_USER", post.Poster.Uri);
                    postVariableCollection.Parse("USER_DISPLAY_NAME", post.Poster.UserInfo.DisplayName);
                    postVariableCollection.Parse("USER_TILE", post.Poster.Tile);
                    postVariableCollection.Parse("USER_ICON", post.Poster.Icon);
                    postVariableCollection.Parse("USER_JOINED", core.Tz.DateTimeToString(post.Poster.UserInfo.GetRegistrationDate(core.Tz)));
                    postVariableCollection.Parse("USER_COUNTRY", post.Poster.Profile.Country);

                    if (thisTopic.ReadStatus == null)
                    {
                        postVariableCollection.Parse("IS_READ", "FALSE");
                    }
                    else
                    {
                        if (thisTopic.ReadStatus.ReadTimeRaw < post.TimeCreatedRaw)
                        {
                            postVariableCollection.Parse("IS_READ", "FALSE");
                        }
                        else
                        {
                            postVariableCollection.Parse("IS_READ", "TRUE");
                        }
                    }
                }

                if (thisTopic.Forum.Access.Can("CREATE_STICKY"))
                {
                    sbis.Add(new SelectBoxItem(((byte)TopicStates.Sticky).ToString(), "Sticky"));
                }
                if (thisTopic.Forum.Access.Can("CREATE_ANNOUNCEMENTS"))
                {
                    sbis.Add(new SelectBoxItem(((byte)TopicStates.Announcement).ToString(), "Announcement"));
                }

                if (thisTopic.Forum.Parents != null)
                {
                    foreach (ParentTreeNode ptn in thisTopic.Forum.Parents.Nodes)
                    {
                        breadCrumbParts.Add(new string[] { "*" + ptn.ParentId.ToString(), ptn.ParentTitle });
                    }
                }

                if (thisTopic.Forum.Id > 0)
                {
                    breadCrumbParts.Add(new string[] { thisTopic.Forum.Id.ToString(), thisTopic.Forum.Title });
                }

                breadCrumbParts.Add(new string[] { "topic-" + thisTopic.Id.ToString(), thisTopic.Title });

                breadCrumbParts.Add(new string[] { "*forum/post/?t=" + thisTopic.Id.ToString() + "&mode=reply", core.Prose.GetString("POST_REPLY") });
            }
            else if (forumId > 0)
            {
                Forum forum = new Forum(core, forumId);
                if (!forum.Access.Can("CREATE_TOPICS"))
                {
                    core.Display.ShowMessage("Cannot create new topic", "Not authorised to create a new topic");
                    return;
                }

                if (forum.Access.Can("CREATE_STICKY"))
                {
                    sbis.Add(new SelectBoxItem(((byte)TopicStates.Sticky).ToString(), "Sticky"));
                }
                if (forum.Access.Can("CREATE_ANNOUNCEMENTS"))
                {
                    sbis.Add(new SelectBoxItem(((byte)TopicStates.Announcement).ToString(), "Announcement"));
                }

                if (forum.Parents != null)
                {
                    foreach (ParentTreeNode ptn in forum.Parents.Nodes)
                    {
                        breadCrumbParts.Add(new string[] { "*" + ptn.ParentId.ToString(), ptn.ParentTitle });
                    }
                }

                if (forum.Id > 0)
                {
                    breadCrumbParts.Add(new string[] { forum.Id.ToString(), forum.Title });
                }

                breadCrumbParts.Add(new string[] { "*forum/post/?f=" + forum.Id.ToString() + "&mode=post", core.Prose.GetString("NEW_TOPIC") });
            }

            core.Template.Parse("S_MODE", mode);

            if (forumId > 0)
            {
                core.Template.Parse("S_FORUM", forumId.ToString());
            }

            if (topicId > 0)
            {
                core.Template.Parse("S_TOPIC", topicId.ToString());
            }

            if (postId > 0)
            {
                core.Template.Parse("S_ID", postId.ToString());
            }

            if (!string.IsNullOrEmpty(subject))
            {
                core.Template.Parse("S_SUBJECT", subject);
            }
            else
            {
                if (topicId > 0)
                {
                    ForumTopic topic = new ForumTopic(core, topicId);
                    core.Template.Parse("S_SUBJECT", "RE: " + topic.Title);
                }
            }

            if (!string.IsNullOrEmpty(text))
            {
                core.Template.Parse("S_POST_TEXT", text);
            }

            if (sbis.Count > 1 && (mode == "post" || mode == "edit"))
            {
                core.Display.ParseRadioArray("S_TOPIC_STATE", "topic-state", sbis.Count, sbis, topicState);
            }

            if (submitMode != "none")
            {
                if (topicId == 0 && (string.IsNullOrEmpty(subject) || subject.Length < 3))
                {
                    core.Template.Parse("ERROR", "New topic must have a subject");
                    return;
                }

                if (string.IsNullOrEmpty(text) || text.Length < 3)
                {
                    core.Template.Parse("ERROR", "Post too short, must be at least three characters long");
                    return;
                }
            }

            if (submitMode == "preview")
            {
                core.Display.ParseBbcode("PREVIEW", text);
                core.Display.ParseBbcode("SUBJECT", subject);

                try
                {
                    ForumMember member = new ForumMember(core, page.Owner, page.loggedInMember);

                    core.Display.ParseBbcode("SIGNATURE", member.ForumSignature);
                }
                catch (InvalidForumMemberException)
                {
                }
            }

            foreach (Emoticon emoticon in core.Emoticons)
            {
                if (emoticon.Category == "modifier") continue;
                if (emoticon.Category == "people" && emoticon.Code.Length < 3)
                {
                    VariableCollection emoticonVariableCollection = e.Template.CreateChild("emoticon_list");
                    emoticonVariableCollection.Parse("CODE", emoticon.Code);
                    emoticonVariableCollection.Parse("URI", emoticon.File);
                }
                else
                {
                    VariableCollection emoticonVariableCollection = e.Template.CreateChild("emoticon_hidden_list");
                    emoticonVariableCollection.Parse("CODE", emoticon.Code);
                    emoticonVariableCollection.Parse("URI", emoticon.File);
                }
            }

            if (submitMode == "draft" || submitMode == "post")
            {
                SavePost(mode, subject, text);
            }

            page.Owner.ParseBreadCrumbs(breadCrumbParts);
        }
Пример #5
0
        public static void ShowUCP(object sender, ShowPPageEventArgs e)
        {
            e.Template.SetTemplate("Forum", "ucp");
            ForumSettings.ShowForumHeader(e.Core, e.Page);

            e.Template.Parse("PAGE_TITLE", e.Core.Prose.GetString("USER_CONTROL_PANEL"));

            if (e.Core.Session.IsLoggedIn && e.Core.Session.LoggedInMember != null)
            {
                e.Template.Parse("S_POST", e.Core.Hyperlink.AppendSid(string.Format("{0}forum/ucp",
                    e.Page.Owner.UriStub), true));

                try
                {
                    ForumMember member = new ForumMember(e.Core, e.Page.Owner, e.Core.Session.LoggedInMember);

                    e.Template.Parse("S_SIGNATURE", member.forumSignature);
                }
                catch (InvalidForumMemberException)
                {
                    // create on submit
                }
            }
            else
            {
                e.Core.Functions.Generate403();
                return;
            }

            List<string[]> breadCrumbParts = new List<string[]>();
            breadCrumbParts.Add(new string[] { "forum", e.Core.Prose.GetString("FORUM") });
            breadCrumbParts.Add(new string[] { "ucp", e.Core.Prose.GetString("USER_CONTROL_PANEL") });

            e.Page.Owner.ParseBreadCrumbs(breadCrumbParts);

            if (!string.IsNullOrEmpty(e.Core.Http.Form["submit"]))
            {
                Save(e.Core, e.Page);
            }
        }
Пример #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="core"></param>
        /// <param name="forumOwner"></param>
        /// <param name="filter">First character based filter</param>
        /// /// <param name="page"></param>
        /// /// <param name="perPage"></param>
        /// <returns></returns>
        public static Dictionary<long, ForumMember> GetMembers(Core core, Primitive forumOwner, string filter, int page, int perPage)
        {
            Dictionary<long, ForumMember> forumMembers = new Dictionary<long, ForumMember>();
            SelectQuery sQuery = ForumMember.GetSelectQueryStub(core, UserLoadOptions.All);
            sQuery.AddCondition("item_id", forumOwner.Id);
            sQuery.AddCondition("item_type_id", forumOwner.TypeId);
            if (!string.IsNullOrEmpty(filter))
            {
                sQuery.AddCondition("user_keys.user_name_first", filter);
            }
            sQuery.LimitCount = perPage;
            sQuery.LimitStart = (page - 1) * perPage;

            System.Data.Common.DbDataReader membersReader = core.Db.ReaderQuery(sQuery);

            while (membersReader.Read())
            {
                ForumMember fm = new ForumMember(core, membersReader, UserLoadOptions.All);
                forumMembers.Add(fm.Id, fm);
            }

            membersReader.Close();
            membersReader.Dispose();

            return forumMembers;
        }
Пример #7
0
        public static Dictionary<long, ForumMember> GetMembers(Core core, Primitive forumOwner, List<long> userIds)
        {
            if (userIds == null || userIds.Count == 0)
            {
                return new Dictionary<long, ForumMember>();
            }

            Dictionary<long, ForumMember> forumMembers = new Dictionary<long, ForumMember>();
            SelectQuery sQuery = ForumMember.GetSelectQueryStub(core, UserLoadOptions.All);
            sQuery.AddCondition("user_keys.user_id", ConditionEquality.In, userIds);
            sQuery.AddCondition("item_id", forumOwner.Id);
            sQuery.AddCondition("item_type_id", forumOwner.TypeId);

            System.Data.Common.DbDataReader membersReader = core.Db.ReaderQuery(sQuery);

            while (membersReader.Read())
            {
                ForumMember fm = new ForumMember(core, membersReader, UserLoadOptions.All);
                forumMembers.Add(fm.Id, fm);
            }

            membersReader.Close();
            membersReader.Dispose();

            return forumMembers;
        }
        void AccountForumMemberManage_Edit(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_forum_member_edit");

            long id = core.Functions.RequestLong("id", 0);
            ForumMember member = null;

            /* Signature TextBox */
            TextBox signatureTextBox = new TextBox("signature");
            signatureTextBox.IsFormatted = true;
            //signatureTextBox.IsDisabled = true;
            signatureTextBox.Lines = 7;

            /* Ranks SelectBox */
            SelectBox ranksSelectBox = new SelectBox("ranks");

            try
            {
                member = new ForumMember(core, Owner, id, UserLoadOptions.All);
            }
            catch (InvalidForumMemberException)
            {
                core.Functions.Generate404();
            }
            catch (InvalidUserException)
            {
                core.Functions.Generate404();
            }

            ranksSelectBox.Add(new SelectBoxItem("0", "None"));

            Dictionary<long, ForumMemberRank> ranks = ForumMemberRank.GetRanks(core, Owner);

            foreach (ForumMemberRank rank in ranks.Values)
            {
                ranksSelectBox.Add(new SelectBoxItem(rank.Id.ToString(), rank.RankTitleText));
            }

            if (ranksSelectBox.ContainsKey(member.ForumRankId.ToString()))
            {
                ranksSelectBox.SelectedKey = member.ForumRankId.ToString();
            }

            signatureTextBox.Value = member.ForumSignature;

            /* Parse the form fields */
            template.Parse("S_USERNAME", member.UserName);
            template.Parse("S_RANK", ranksSelectBox);
            template.Parse("S_SIGNATURE", signatureTextBox);
            template.Parse("S_ID", id.ToString());
        }
        void AccountForumMemberManage_Edit_Save(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            long id = core.Functions.FormLong("id", 0);
            long rankId = core.Functions.FormLong("ranks", 0);
            ForumMember member = null;

            try
            {
                member = new ForumMember(core, Owner, id, UserLoadOptions.Common);
            }
            catch (InvalidForumMemberException)
            {
                core.Functions.Generate404();
            }
            catch (InvalidUserException)
            {
                core.Functions.Generate404();
            }

            member.ForumSignature = core.Http.Form["signature"];
            member.ForumRankId = rankId;

            member.Update(typeof(ForumMember));

            SetRedirectUri(BuildUri());
            core.Display.ShowMessage("Forum Profile Updated", "The user's forum profile has been saved in the database");
        }