示例#1
0
        public GroupForumThread(GroupForum parent, int id, int userid, int timestamp, string caption, bool pinned, bool locked, int deletedlevel, int deleterid)
        {
            CloudServer.GetGame().GetClientManager().OnClientDisconnect += GroupForumThread_OnClientDisconnect;
            Views         = new List <GroupForumThreadPostView>();;
            UsersOnThread = new List <GameClient>();
            ParentForum   = parent;

            Id        = id;
            UserId    = userid;
            Timestamp = timestamp;
            Caption   = caption;
            Posts     = new List <GroupForumThreadPost>();

            Pinned           = pinned;
            Locked           = locked;
            DeletedLevel     = deletedlevel;
            DeleterUserId    = deleterid;
            DeletedTimestamp = (int)CloudServer.GetUnixTimestamp();

            DataTable table;

            using (var adap = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("SELECT * FROM group_forums_thread_posts WHERE thread_id = @id");
                adap.AddParameter("id", this.Id);
                table = adap.getTable();
            }

            foreach (DataRow Row in table.Rows)
            {
                Posts.Add(new GroupForumThreadPost(this, Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["timestamp"]), Row["message"].ToString(), Convert.ToInt32(Row["deleted_level"]), Convert.ToInt32(Row["deleter_user_id"])));
            }


            //DataTable table;
            using (var Adap = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                Adap.SetQuery("SELECT * FROM group_forums_thread_views WHERE thread_id = @id");
                Adap.AddParameter("id", Id);
                table = Adap.getTable();
            }


            foreach (DataRow Row in table.Rows)
            {
                Views.Add(new GroupForumThreadPostView(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["count"])));
            }
        }
示例#2
0
        public GroupForumSettings(GroupForum Forum)
        {
            this.ParentForum = Forum;

            DataRow Row;

            using (var adap = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("SELECT * FROM group_forums_settings WHERE group_id = @id");
                adap.AddParameter("id", Forum.Id);
                Row = adap.getRow();
            }

            this.WhoCanRead            = Convert.ToInt32(Row["who_can_read"]);
            this.WhoCanPost            = Convert.ToInt32(Row["who_can_post"]);
            this.WhoCanInitDiscussions = Convert.ToInt32(Row["who_can_init_discussions"]);
            this.WhoCanModerate        = Convert.ToInt32(Row["who_can_mod"]);
        }
示例#3
0
        public bool TryGetForum(int Id, out GroupForum Forum)
        {
            if ((Forum = Forums.FirstOrDefault(c => c.Id == Id)) != null)
            {
                return(true);
            }

            Group Gp;

            if (!CloudServer.GetGame().GetGroupManager().TryGetGroup(Id, out Gp))
            {
                return(false);
            }

            if (!Gp.ForumEnabled)
            {
                return(false);
            }

            Forum = new GroupForum(Gp);
            Forums.Add(Forum);
            return(true);
        }
示例#4
0
        public GroupForum CreateGroupForum(Group Gp)
        {
            GroupForum GF;

            if (TryGetForum(Gp.Id, out GF))
            {
                return(GF);
            }

            using (var adap = CloudServer.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("INSERT INTO group_forums_settings (group_id) VALUES (@gp)");
                adap.AddParameter("gp", Gp.Id);
                adap.RunQuery();

                adap.SetQuery("UPDATE groups SET forum_enabled = '1' WHERE id = @id");
                adap.AddParameter("id", Gp.Id);
                adap.RunQuery();
            }

            GF = new GroupForum(Gp);
            Forums.Add(GF);
            return(GF);
        }
示例#5
0
        public GroupForum GetForum(int GroupId)
        {
            GroupForum f = null;

            return(TryGetForum(GroupId, out f) ? f : null);
        }