Ejemplo n.º 1
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            int userGroupId = commandParam.LocalUid > 0 ? Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid : 7;
            int topicCount, postCount, todayCount;
            List <IndexPageForumInfo> list = Discuz.Forum.Forums.GetForumIndexCollection(1, userGroupId, 0, out topicCount, out postCount, out todayCount);

            List <IndexForum> newList      = new List <IndexForum>();

            foreach (IndexPageForumInfo f in list)
            {
                IndexForum newf = new IndexForum();
                newf.Fid           = f.Fid;
                newf.Url           = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Urls.ShowForumAspxRewrite(f.Fid, 1, f.Rewritename);
                newf.CurTopics     = f.CurrentTopics;
                newf.Description   = f.Description;
                newf.Icon          = f.Icon;
                newf.LastPost      = f.Lastpost;
                newf.LastPoster    = f.Lastposter.Trim();
                newf.LastPosterId  = f.Lastposterid;
                newf.LastTid       = f.Lasttid;
                newf.LastTitle     = f.Lasttitle.Trim();
                newf.Moderators    = f.Moderators;
                newf.Name          = f.Name;
                newf.ParentId      = f.Parentid;
                newf.ParentIdList  = f.Parentidlist.Trim();
                newf.PathList      = f.Pathlist.Trim();
                newf.Posts         = f.Posts;
                newf.Rules         = f.Rules;
                newf.Status        = f.Status;
                newf.SubForumCount = f.Subforumcount;
                newf.TodayPosts    = f.Todayposts;
                newf.Topics        = f.Topics;

                newList.Add(newf);
            }

            ForumGetIndexListResponse fgilr = new ForumGetIndexListResponse();

            fgilr.Forums = newList.ToArray();
            fgilr.List   = true;

            result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(fgilr) : SerializationHelper.Serialize(fgilr);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获得首页版块信息
        /// </summary>
        /// <returns></returns>
        public string GetIndexList()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }
            int userGroupId = 7;

            if (Uid > 0)
            {
                userGroupId = Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid;
            }

            int topicCount, postCount, todayCount;
            List <IndexPageForumInfo> list = Discuz.Forum.Forums.GetForumIndexCollection(1, userGroupId, 0, out topicCount, out postCount, out todayCount);

            List <IndexForum> newList = new List <IndexForum>();

            foreach (IndexPageForumInfo f in list)
            {
                IndexForum newf = new IndexForum();
                newf.Fid           = f.Fid;
                newf.Url           = ForumUrl + Urls.ShowForumAspxRewrite(f.Fid, 1, f.Rewritename);
                newf.CurTopics     = f.CurrentTopics;
                newf.Description   = f.Description;
                newf.Icon          = f.Icon;
                newf.LastPost      = f.Lastpost;
                newf.LastPoster    = f.Lastposter.Trim();
                newf.LastPosterId  = f.Lastposterid;
                newf.LastTid       = f.Lasttid;
                newf.LastTitle     = f.Lasttitle.Trim();
                newf.Moderators    = f.Moderators;
                newf.Name          = f.Name;
                newf.ParentId      = f.Parentid;
                newf.ParentIdList  = f.Parentidlist.Trim();
                newf.PathList      = f.Pathlist.Trim();
                newf.Posts         = f.Posts;
                newf.Rules         = f.Rules;
                newf.Status        = f.Status;
                newf.SubForumCount = f.Subforumcount;
                newf.TodayPosts    = f.Todayposts;
                newf.Topics        = f.Topics;

                newList.Add(newf);
            }

            ForumGetIndexListResponse fgilr = new ForumGetIndexListResponse();

            fgilr.Forums = newList.ToArray();
            fgilr.List   = true;

            if (Format == FormatType.JSON)
            {
                return(JsonConvert.SerializeObject(fgilr));
            }
            return(SerializationHelper.Serialize(fgilr));
        }
Ejemplo n.º 3
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            int userGroupId = commandParam.LocalUid > 0 ? Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid : 7;
            int topicCount, postCount, todayCount;
            List<IndexPageForumInfo> list = Discuz.Forum.Forums.GetForumIndexCollection(1, userGroupId, 0, out topicCount, out postCount, out todayCount);

            List<IndexForum> newList = new List<IndexForum>();

            foreach (IndexPageForumInfo f in list)
            {
                IndexForum newf = new IndexForum();
                newf.Fid = f.Fid;
                newf.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Urls.ShowForumAspxRewrite(f.Fid, 1, f.Rewritename);
                newf.CurTopics = f.CurrentTopics;
                newf.Description = f.Description;
                newf.Icon = f.Icon;
                newf.LastPost = f.Lastpost;
                newf.LastPoster = f.Lastposter.Trim();
                newf.LastPosterId = f.Lastposterid;
                newf.LastTid = f.Lasttid;
                newf.LastTitle = f.Lasttitle.Trim();
                newf.Moderators = f.Moderators;
                newf.Name = f.Name;
                newf.ParentId = f.Parentid;
                newf.ParentIdList = f.Parentidlist.Trim();
                newf.PathList = f.Pathlist.Trim();
                newf.Posts = f.Posts;
                newf.Rules = f.Rules;
                newf.Status = f.Status;
                newf.SubForumCount = f.Subforumcount;
                newf.TodayPosts = f.Todayposts;
                newf.Topics = f.Topics;

                newList.Add(newf);
            }

            ForumGetIndexListResponse fgilr = new ForumGetIndexListResponse();
            fgilr.Forums = newList.ToArray();
            fgilr.List = true;

            result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(fgilr) : SerializationHelper.Serialize(fgilr);
            return true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获得首页版块信息
        /// </summary>
        /// <returns></returns>
        public string GetIndexList()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return "";
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return "";
            }
            int userGroupId = 7;
            if (Uid > 0)
                userGroupId = Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid;

            int topicCount, postCount, todayCount;
            List<IndexPageForumInfo> list = Discuz.Forum.Forums.GetForumIndexCollection(1, userGroupId, 0, out topicCount, out postCount, out todayCount);

            List<IndexForum> newList = new List<IndexForum>();

            foreach (IndexPageForumInfo f in list)
            {
                IndexForum newf = new IndexForum();
                newf.Fid = f.Fid;
                newf.Url = ForumUrl + Urls.ShowForumAspxRewrite(f.Fid, 1, f.Rewritename);
                newf.CurTopics = f.CurrentTopics;
                newf.Description = f.Description;
                newf.Icon = f.Icon;
                newf.LastPost = f.Lastpost;
                newf.LastPoster = f.Lastposter.Trim();
                newf.LastPosterId = f.Lastposterid;
                newf.LastTid = f.Lasttid;
                newf.LastTitle = f.Lasttitle.Trim();
                newf.Moderators = f.Moderators;
                newf.Name = f.Name;
                newf.ParentId = f.Parentid;
                newf.ParentIdList = f.Parentidlist.Trim();
                newf.PathList = f.Pathlist.Trim();
                newf.Posts = f.Posts;
                newf.Rules = f.Rules;
                newf.Status = f.Status;
                newf.SubForumCount = f.Subforumcount;
                newf.TodayPosts = f.Todayposts;
                newf.Topics = f.Topics;

                newList.Add(newf);
            }

            ForumGetIndexListResponse fgilr = new ForumGetIndexListResponse();
            fgilr.Forums = newList.ToArray();
            fgilr.List = true;

            if (Format == FormatType.JSON)
            {
                return JavaScriptConvert.SerializeObject(fgilr);
            }
            return SerializationHelper.Serialize(fgilr);

        }