Example #1
0
        public static bool PushFeedToDiscuzCloud(TopicInfo topic, PostInfo post, AttachmentInfo[] attachments, UserConnect connectInfo, string ip, string rootUrl)
        {
            DiscuzCloudConfigInfo       config = DiscuzCloudConfigInfo.Current;
            List <DiscuzOAuthParameter> list   = new List <DiscuzOAuthParameter>();

            list.Add(new DiscuzOAuthParameter("client_ip", ip));
            list.Add(new DiscuzOAuthParameter("thread_id", topic.Tid.ToString()));
            list.Add(new DiscuzOAuthParameter("author_id", topic.Posterid.ToString()));
            list.Add(new DiscuzOAuthParameter("author", topic.Poster));
            list.Add(new DiscuzOAuthParameter("forum_id", topic.Fid.ToString()));
            list.Add(new DiscuzOAuthParameter("p_id", post.Pid.ToString()));
            list.Add(new DiscuzOAuthParameter("subject", topic.Title));
            GeneralConfigInfo config2 = GeneralConfigInfo.Current;

            list.Add(new DiscuzOAuthParameter("html_content", UBB.UBBToHTML(new PostpramsInfo
            {
                Sdetail     = post.Message,
                Smiliesinfo = Smilies.GetSmiliesListWithInfo(),
                Bbcodemode  = config2.Bbcodemode,
                Parseurloff = post.Parseurloff,
                BBCode      = post.Bbcodeoff < 1,
                Signature   = 0,
                Allowhtml   = post.Htmlon,
                Pid         = post.Pid,
                Showimages  = 1 - post.Smileyoff,
                Smileyoff   = post.Smileyoff,
                Smiliesmax  = config2.Smiliesmax,
                Hide        = 0
            })));
            list.Add(new DiscuzOAuthParameter("bbcode_content", post.Message));
            list.Add(new DiscuzOAuthParameter("read_permission", "0"));
            list.Add(new DiscuzOAuthParameter("u_id", topic.Posterid.ToString()));
            list.Add(new DiscuzOAuthParameter("f_type", TypeConverter.BooleanToIntString(connectInfo.AllowPushFeed)));
            StringBuilder stringBuilder = new StringBuilder();
            int           num           = 0;

            if (attachments != null)
            {
                for (int i = 0; i < attachments.Length; i++)
                {
                    AttachmentInfo attachmentInfo = attachments[i];
                    if (num < 3 && attachmentInfo.Filetype.IndexOf("image") > -1 && attachmentInfo.Attachprice <= 0)
                    {
                        stringBuilder.AppendFormat("|{0}upload/{1}", rootUrl, attachmentInfo.Filename.Replace("\\", "/"));
                        num++;
                    }
                }
            }
            list.Add(new DiscuzOAuthParameter("attach_images", stringBuilder.ToString().TrimStart('|')));
            DiscuzOAuth discuzOAuth = new DiscuzOAuth();
            string      postData    = "";
            string      oAuthUrl    = discuzOAuth.GetOAuthUrl(API_CONNECT_URL + "connect/feed/new", "POST", config.Connectappid, config.Connectappkey, connectInfo.Token, connectInfo.Secret, "", "", list, out postData);

            Utils.GetHttpWebResponse(oAuthUrl, postData);
            return(true);
        }
Example #2
0
        /// <summary>
        /// 更新用户全部信息
        /// </summary>
        /// <param name="__userinfo"></param>
        /// <returns></returns>
        public static bool UpdateUserAllInfo(UserInfo userInfo)
        {
            Users.UpdateUser(userInfo);

            //当用户不是版主(超级版主)或管理员
            if ((userInfo.Adminid == 0) || (userInfo.Adminid > 3))
            {
                //删除用户在版主列表中相关数据
                Data.Moderators.DeleteModerator(userInfo.Uid);
                //同时更新版块相关的版主信息
                UpdateForumsFieldModerators(userInfo.Username);
            }
            else
            {
                DNTCache cache = DNTCache.GetCacheService();
                cache.RemoveObject("/Forum/AdminUsers");
            }

            #region 以下为更新该用户的扩展信息

            string signature = Utils.HtmlEncode(ForumUtils.BanWordFilter(userInfo.Signature));

            UserGroupInfo     usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(userInfo.Groupid);
            GeneralConfigInfo config        = GeneralConfigs.GetConfig();

            PostpramsInfo postPramsInfo = new PostpramsInfo();
            postPramsInfo.Usergroupid        = usergroupinfo.Groupid;
            postPramsInfo.Attachimgpost      = config.Attachimgpost;
            postPramsInfo.Showattachmentpath = config.Showattachmentpath;
            postPramsInfo.Hide                   = 0;
            postPramsInfo.Price                  = 0;
            postPramsInfo.Sdetail                = userInfo.Signature;
            postPramsInfo.Smileyoff              = 1;
            postPramsInfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
            postPramsInfo.Parseurloff            = 1;
            postPramsInfo.Showimages             = usergroupinfo.Allowsigimgcode;
            postPramsInfo.Allowhtml              = 0;
            postPramsInfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            postPramsInfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            postPramsInfo.Smiliesmax             = config.Smiliesmax;
            postPramsInfo.Signature              = 1;
            postPramsInfo.Onlinetimeout          = config.Onlinetimeout;

            userInfo.Signature = signature;
            userInfo.Authstr   = ForumUtils.CreateAuthStr(20);
            userInfo.Sightml   = UBB.UBBToHTML(postPramsInfo);
            Users.UpdateUser(userInfo);

            #endregion

            Users.UpdateUserForumSetting(userInfo);
            return(true);
        }
Example #3
0
        /// <summary>
        /// 更新用户全部信息
        /// </summary>
        /// <param name="__userinfo"></param>
        /// <returns></returns>
        public static bool UpdateUserAllInfo(UserInfo __userinfo)
        {
            DatabaseProvider.GetInstance().UpdateUserAllInfo(__userinfo);

            //当用户不是版主(超级版主)或管理员
            if ((__userinfo.Adminid == 0) || (__userinfo.Adminid > 3))
            {
                //删除用户在版主列表中相关数据
                DatabaseProvider.GetInstance().DeleteModerator(__userinfo.Uid);

                //同时更新版块相关的版主信息
                UpdateForumsFieldModerators(__userinfo.Username);
            }

            #region 以下为更新该用户的扩展信息

            string signature = Utils.HtmlEncode(ForumUtils.BanWordFilter(__userinfo.Signature));

            UserGroupInfo     usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(__userinfo.Groupid);
            GeneralConfigInfo config        = GeneralConfigs.GetConfig();

            PostpramsInfo _postpramsinfo = new PostpramsInfo();
            _postpramsinfo.Usergroupid        = usergroupinfo.Groupid;
            _postpramsinfo.Attachimgpost      = config.Attachimgpost;
            _postpramsinfo.Showattachmentpath = config.Showattachmentpath;
            _postpramsinfo.Hide                   = 0;
            _postpramsinfo.Price                  = 0;
            _postpramsinfo.Sdetail                = __userinfo.Signature;
            _postpramsinfo.Smileyoff              = 1;
            _postpramsinfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
            _postpramsinfo.Parseurloff            = 1;
            _postpramsinfo.Showimages             = usergroupinfo.Allowsigimgcode;
            _postpramsinfo.Allowhtml              = 0;
            _postpramsinfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            _postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            _postpramsinfo.Smiliesmax             = config.Smiliesmax;
            _postpramsinfo.Signature              = 1;
            _postpramsinfo.Onlinetimeout          = config.Onlinetimeout;

            DatabaseProvider.GetInstance().UpdateUserField(__userinfo, signature, ForumUtils.CreateAuthStr(20), UBB.UBBToHTML(_postpramsinfo));

            #endregion

            Users.UpdateUserForumSetting(__userinfo);

            return(true);
        }
Example #4
0
        /// <summary>
        /// 发送feed请求到云平台
        /// </summary>
        /// <param name="topic"></param>
        /// <param name="post"></param>
        /// <param name="attachments"></param>
        /// <param name="connectInfo"></param>
        /// <returns></returns>
        public static bool PushFeedToDiscuzCloud(TopicInfo topic, PostInfo post, AttachmentInfo[] attachments, UserConnectInfo connectInfo, string ip, string rootUrl)
        {
            DiscuzCloudConfigInfo       config   = DiscuzCloudConfigs.GetConfig();
            List <DiscuzOAuthParameter> parmlist = new List <DiscuzOAuthParameter>();

            parmlist.Add(new DiscuzOAuthParameter("client_ip", ip));
            parmlist.Add(new DiscuzOAuthParameter("thread_id", topic.Tid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("author_id", topic.Posterid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("author", topic.Poster));
            parmlist.Add(new DiscuzOAuthParameter("forum_id", topic.Fid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("p_id", post.Pid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("subject", topic.Title));

            #region 构造postparmsinfo

            GeneralConfigInfo generalConfig = GeneralConfigs.GetConfig();
            PostpramsInfo     postpramsInfo = new PostpramsInfo();
            postpramsInfo.Sdetail     = post.Message;
            postpramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo();
            postpramsInfo.Bbcodemode  = generalConfig.Bbcodemode;
            postpramsInfo.Parseurloff = post.Parseurloff;
            postpramsInfo.Bbcodeoff   = post.Bbcodeoff;
            postpramsInfo.Signature   = 0;
            postpramsInfo.Allowhtml   = post.Htmlon;
            postpramsInfo.Pid         = post.Pid;
            postpramsInfo.Showimages  = 1 - post.Smileyoff;
            postpramsInfo.Smileyoff   = post.Smileyoff;
            postpramsInfo.Smiliesmax  = generalConfig.Smiliesmax;
            //判断是否为回复可见帖, hide=0为不解析[hide]标签, hide>0解析为回复可见字样, hide=-1解析为以下内容回复可见字样显示真实内容
            //将逻辑判断放入取列表的循环中处理,此处只做是否为回复人的判断,主题作者也该可见
            postpramsInfo.Hide = 0;

            #endregion
            parmlist.Add(new DiscuzOAuthParameter("html_content", UBB.UBBToHTML(postpramsInfo)));
            parmlist.Add(new DiscuzOAuthParameter("bbcode_content", post.Message));
            parmlist.Add(new DiscuzOAuthParameter("read_permission", "0"));
            parmlist.Add(new DiscuzOAuthParameter("u_id", topic.Posterid.ToString()));
            parmlist.Add(new DiscuzOAuthParameter("f_type", connectInfo.AllowPushFeed.ToString()));

            StringBuilder attachUrlList = new StringBuilder();
            int           attachCount   = 0;
            if (attachments != null)
            {
                foreach (AttachmentInfo info in attachments)
                {
                    if (attachCount < 3 && info.Filetype.IndexOf("image") > -1 && info.Attachprice <= 0)
                    {
                        attachUrlList.AppendFormat("|{0}upload/{1}", rootUrl, info.Filename.Replace("\\", "/"));
                        attachCount++;
                    }
                }
            }

            parmlist.Add(new DiscuzOAuthParameter("attach_images", attachUrlList.ToString().TrimStart('|')));

            DiscuzOAuth oAuth    = new DiscuzOAuth();
            string      queryStr = "";
            string      feedUrl  = oAuth.GetOAuthUrl(API_CONNECT_URL + "connect/feed/new", "POST",
                                                     config.Connectappid, config.Connectappkey, connectInfo.Token, connectInfo.Secret, "", "", parmlist, out queryStr);

            Utils.GetHttpWebResponse(feedUrl, queryStr);
            return(true);
        }