Exemple #1
0
 public static bool UpdateReplyInfo(ReplyInfo replyInfo)
 {
     return(new ReplyDao().UpdateReplyInfo(replyInfo));
 }
        private void SaveQuickReply()
        {
            int iFloodInterval = MainSettings.FloodInterval;

            if (iFloodInterval > 0)
            {
                UserProfileController upc = new UserProfileController();
                UserProfileInfo       upi = upc.Profiles_Get(SiteId, InstanceId, this.UserId);
                if (upi != null)
                {
                    if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval)
                    {
                        Controls.InfoMessage im = new Controls.InfoMessage();
                        im.Message = "<div class=\"afmessage\">" + string.Format(Utilities.GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>";
                        plhMessage.Controls.Add(im);
                        return;
                    }
                }
            }
            //TODO: Fix for anon
            //If Not Current.Request.IsAuthenticated Then
            //    If Not ctlCaptcha.IsValid Or txtUserName.Value = "" Then
            //        Exit Sub
            //    End If
            //End If
            //Dim ui As New UserProfileInfo
            //If UserId > 0 Then
            //    Dim upc As New UserProfileController
            //    ui = upc.Profiles_Get(PortalId, ForumModuleId, UserId)
            //Else
            //    ui.TopicCount = 0
            //    ui.ReplyCount = 0
            //    ui.RewardPoints = 0
            //    ui.IsMod = False
            //    ui.TrustLevel = -1

            //End If
            ForumController fc            = new ForumController();
            Forum           forumInfo     = fc.Forums_Get(SiteId, InstanceId, ForumId, this.UserId, true, false, TopicId);
            bool            UserIsTrusted = false;

            UserIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, ControlConfig.User.TrustLevel, Permissions.HasPerm(forumInfo.Security.Trust, ForumUser.UserRoles), forumInfo.AutoTrustLevel, ControlConfig.User.PostCount);
            bool isApproved = false;

            isApproved = Convert.ToBoolean(((forumInfo.IsModerated == true) ? false : true));
            if (UserIsTrusted || Permissions.HasPerm(forumInfo.Security.ModApprove, ForumUser.UserRoles))
            {
                isApproved = true;
            }
            ReplyInfo ri = new ReplyInfo();

            Data.Topics db = new Data.Topics();
            //im rc As New ReplyController
            int    ReplyId   = -1;
            string sUsername = string.Empty;

            if (HttpContext.Current.Request.IsAuthenticated)
            {
                sUsername = ControlConfig.User.DisplayName;
            }
            else
            {
                sUsername = Utilities.CleanString(SiteId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, InstanceId, ThemePath, false);
            }

            string sBody = string.Empty;
            //TODO: Check for allowhtml
            bool allowHtml = false;

            //If forumInfo.AllowHTML Then
            //    allowHtml = isHTMLPermitted(forumInfo.EditorPermittedUsers, IsTrusted, forumInfo.Security.ModEdit)
            //End If
            sBody = Utilities.CleanString(SiteId, HttpContext.Current.Request.Form["txtBody"], allowHtml, EditorTypes.TEXTBOX, forumInfo.UseFilter, forumInfo.AllowScript, InstanceId, ThemePath, forumInfo.AllowEmoticons);
            DateTime createDate = DateTime.Now;

            ri.TopicId             = TopicId;
            ri.ReplyToId           = TopicId;
            ri.Content.AuthorId    = UserId;
            ri.Content.AuthorName  = sUsername;
            ri.Content.Body        = sBody;
            ri.Content.DateCreated = createDate;
            ri.Content.DateUpdated = createDate;
            ri.Content.IsDeleted   = false;
            ri.Content.Subject     = Subject;
            ri.Content.Summary     = string.Empty;
            ri.IsApproved          = isApproved;
            ri.IsDeleted           = false;
            ri.Content.IPAddress   = HttpContext.Current.Request.UserHostAddress;
            ReplyId = db.Reply_Save(ri);
            //Check if is subscribed
            if (HttpContext.Current.Request.Params["chkSubscribe"] != null)
            {
                if (HttpContext.Current.Request.Params["chkSubscribe"] == "1" && UserId > 0)
                {
                    if (!(Subscriptions.IsSubscribed(SiteId, InstanceId, ForumId, TopicId, SubscriptionTypes.Instant, UserId)))
                    {
                        //TODO: Fix Subscriptions
                        //Dim sc As New Data.Tracking
                        //sc.Subscription_Update(SiteId, InstanceId, ForumId, TopicId, 1, UserId)
                    }
                }
            }
            if (isApproved)
            {
                //Send Subscriptions
                try
                {
                    string sURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
                    Subscriptions.SendSubscriptions(SiteId, InstanceId, PageId, ForumId, TopicId, ReplyId, UserId);

#if !SKU_LITE
                    try
                    {
                        Social oSocial = new Social();
                        oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", sURL, Subject, sBody);
                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                    }
#endif
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                }
                //Redirect to show post
                string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
                HttpContext.Current.Response.Redirect(fullURL, false);
            }
            else if (isApproved == false)
            {
                Email oEmail = new Email();
                oEmail.SendEmailToModerators(forumInfo.ModNotifyTemplateId, SiteId, ForumId, ri.TopicId, ReplyId, InstanceId, PageId, string.Empty);
                string[] Params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId };
                HttpContext.Current.Response.Redirect(Utilities.NavigateUrl(PageId, "", Params), false);
            }
            else
            {
                string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });

#if !SKU_LITE
                try
                {
                    Modules.ActiveForums.Social oSocial = new Modules.ActiveForums.Social();
                    oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", fullURL, Subject, sBody);
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
#endif
                HttpContext.Current.Response.Redirect(fullURL, false);
            }

            //End If
        }
Exemple #3
0
 public static bool SaveReplyInfo(ReplyInfo replyInfo)
 {
     return(new ReplyDao().SaveReplyInfo(replyInfo));
 }
Exemple #4
0
 public static bool UpdateReply(ReplyInfo reply)
 {
     reply.LastEditDate = DateTime.Now;
     reply.LastEditor   = ManagerHelper.GetCurrentManager().UserName;
     return((new ReplyDao()).UpdateReply(reply));
 }
Exemple #5
0
        //关注事件
        public override AbstractResponse OnEvent_SubscribeRequest(SubscribeEventRequest subscribeEventRequest)
        {
            Utils.LogWriter.SaveLog("产生关注事件:" + subscribeEventRequest.EventKey);
            string event_key = subscribeEventRequest.EventKey;

            if (!string.IsNullOrEmpty(event_key) && event_key.IndexOf("qrscene_") != -1)
            {
                //关联上级

                /*
                 * 打开分享图片
                 * 获取用户信息
                 *
                 * */

                string open_id = subscribeEventRequest.FromUserName;
                Utils.LogWriter.SaveLog("产生关注事件step1:" + open_id);
                int ReferralUserId = int.Parse(subscribeEventRequest.EventKey.Replace("qrscene_", ""));
                Utils.LogWriter.SaveLog("产生关注事件step2:" + ReferralUserId);

                //判断是否会员
                if (MemberProcessor.IsExitOpenId(open_id))
                {
                    Utils.LogWriter.SaveLog("产生关注事件step3:已存在会员信息");
                    Hidistro.Entities.Members.MemberInfo m = MemberProcessor.GetMembers(open_id);
                    if (m.ReferralUserId == 0 && m.OpenId != open_id)
                    {
                        m.ReferralUserId = ReferralUserId;
                        MemberProcessor.UpdateMember(m);
                        //Utils.LogWriter.SaveLog("扫码填补上级ID:" + ReferralUserId);
                        return(null);
                    }
                }
                else
                {
                    Utils.LogWriter.SaveLog("产生关注事件step3:不存在会员信息");
                    //关联上级并增加客户资料
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(true);

                    JObject wx_user_info = TokenApi.GetUserInfo(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, open_id);
                    Utils.LogWriter.SaveLog("产生关注事件step4:" + wx_user_info["nickname"].ToString());

                    string generateId = Globals.GetGenerateId();
                    Hidistro.Entities.Members.MemberInfo member = new Hidistro.Entities.Members.MemberInfo
                    {
                        GradeId        = MemberProcessor.GetDefaultMemberGrade(),
                        UserName       = Globals.UrlDecode(wx_user_info["nickname"].ToString()),
                        OpenId         = open_id,
                        CreateDate     = DateTime.Now,
                        SessionId      = generateId,
                        SessionEndTime = DateTime.Now.AddYears(10),
                        ReferralUserId = ReferralUserId
                    };

                    Utils.LogWriter.SaveLog("创建客户资料");
                    MemberProcessor.CreateMember(member);

                    //获取上级
                    Hidistro.Entities.Members.MemberInfo parentInfo = MemberProcessor.GetMember(ReferralUserId);

                    //获取第多少个会员
                    int count = MemberProcessor.GetMemberCount();

                    TextResponse r = new TextResponse
                    {
                        CreateTime = DateTime.Now,
                        Content    = "恭喜您!您已通过【" + parentInfo.UserName + "】的推荐成为本站会员,您是本站第" + (10000 + count)
                                     + "个会员,点击右下方【创业良机】~【组建团队】进入财富倍增快通道。",
                        ToUserName   = subscribeEventRequest.FromUserName,
                        FromUserName = subscribeEventRequest.ToUserName
                    };
                    return(r);
                }
            }

            ReplyInfo subscribeReply = ReplyHelper.GetSubscribeReply();

            if (subscribeReply == null)
            {
                return(null);
            }
            subscribeReply.Keys = "登录";
            AbstractResponse response = this.GetResponse(subscribeReply, subscribeEventRequest.FromUserName);

            if (response == null)
            {
                this.GotoManyCustomerService(subscribeEventRequest);
            }
            response.ToUserName   = subscribeEventRequest.FromUserName;
            response.FromUserName = subscribeEventRequest.ToUserName;
            return(response);
        }
Exemple #6
0
        private static void SendSubscriptions(Enumerators.Subscription subType, TopicInfo topic, ReplyInfo reply, HttpContext context)
        {
            int replyid  = -1;
            int authorid = topic.AuthorId;

            int[]         memberids  = { };
            StringBuilder Message    = new StringBuilder("<html><body>Hello {0}");
            string        strSubject = String.Empty;

            HttpContext.Current = context;
            if (reply != null)
            {
                replyid  = reply.Id;
                authorid = reply.AuthorId;
            }
            Message.Append("<br/><p>");

            ISubscription dal = Factory <ISubscription> .Create("Subscription");

            switch (subType)
            {
            case Enumerators.Subscription.ForumSubscription:

                memberids = dal.GetForumSubscriptionList(topic.ForumId);

                if (memberids.Length > 0)
                {
                    strSubject = Config.ForumTitle.Replace("&trade;", "").Replace("&copy;", "") + " - New posting";

                    Message.AppendFormat(
                        "{0} has posted to the forum {1} at {2} that you requested notification on.",
                        topic.AuthorName, topic.Forum.Subject, Config.ForumTitle);
                }
                break;

            case Enumerators.Subscription.TopicSubscription:

                memberids = dal.GetTopicSubscriptionList(topic.Id);

                if (memberids.Length > 0)
                {
                    strSubject = Config.ForumTitle.Replace("&trade;", "").Replace("&copy;", "") + " - Reply to a posting";
                    Message.AppendFormat("{0} has replied to a topic on <b>{1}</b> that you requested notification to.", reply.AuthorName, Config.ForumTitle);
                }

                break;
            }
            Message.AppendFormat(" Regarding the subject - {0}.", topic.Subject);
            Message.Append("<br/>");
            Message.Append("<br/>");
            Message.AppendFormat("You can view the posting <a href=\"{0}Content/Forums/topic.aspx?whichpage=-1&TOPIC={1}", Config.ForumUrl, topic.Id);
            if (replyid > 0)
            {
                Message.AppendFormat("#{0}", replyid);
            }
            Message.Append("\">here</a>");
            Message.Append("</p></body></html>");
            foreach (int id in memberids)
            {
                MemberInfo member = Members.GetMember(id);
                //don't send the author notification of their own posts
                if (id == authorid)
                {
                    continue;
                }
                SnitzEmail email = new SnitzEmail
                {
                    subject  = strSubject,
                    msgBody  = String.Format(Message.ToString(), member.Username),
                    toUser   = new MailAddress(member.Email, member.Username),
                    IsHtml   = true,
                    FromUser = "******"
                };
                email.Send();
            }
        }
Exemple #7
0
        public ReplyInfo HandleMessageAll(MessageInfo message)
        {
            ReplyInfo info = new ReplyInfo();

            switch (message.msg_type_id)
            {
            case 4:     // msg from contact
                //info.toUserId = message.user.senderId;
                if (message.content.type == 0)
                {
                    string msg_content = message.content.data;
                    string user_id     = message.user.senderId;
                    string user_name   = message.user.senderName;

                    log.Info("[Contact Message]: From (" + user_name + "), Context: " + msg_content);

                    if ((user_name == "YJL SOEVPM") && (msg_content.StartsWith("##")))
                    {
                        string[] tmps     = msg_content.Split('@');
                        string   notifier = user_name;
                        if (tmps.Length > 1)
                        {
                            notifier = tmps[0].Replace("##", "");
                        }

                        string content = tmps[tmps.Length - 1];

                        NotifyResponse resp = controller.NotificationStore(notifier, content);
                        if (resp.success)
                        {
                            info.reply = "好的,我记住老师的话了";
                        }
                        else
                        {
                            info.reply = "我的程序有点问题,没记住老师的话555";
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(msg_content))
                        {
                            info.reply = controller.AnswerOneOneQuestion(user_id, msg_content);
                        }
                    }
                }
                else
                {
                    log.Warn("[Warning]: Received non-text messsage from contact: " + message.user.senderName);
                    info.reply = "对不起,我现在只认识文字。";
                }
                break;

            case 3:     //Group text message
                //info.toUserId = message.user.groupId;
                if (!string.IsNullOrWhiteSpace(message.content.detail))
                {
                    if (message.user.isAtMe)
                    {
                        if (message.content.type == 0)
                        {
                            string msg_content   = message.content.desc;
                            string src_user_id   = message.user.senderId;
                            string src_user_name = message.user.senderName;
                            string gid           = message.user.groupId;

                            log.Info("[Group AtMe Message]: In Group(" + gid + "), From (" + src_user_name + "), Context: " + msg_content);

                            if (!string.IsNullOrWhiteSpace(msg_content))
                            {
                                string reply = controller.AnswerQuestion(src_user_id, msg_content);

                                info.reply = "@" + src_user_name + " " + reply;
                            }
                        }
                        else
                        {
                            log.Warn("[Warning]: Received non-text messsage in group: " + message.user.groupId);
                            info.reply = "对不起,我现在只认识文字。";
                        }
                    }
                }
                break;

            /* case 100:
             *   if (message.content.type == 0)
             *   {
             *       string msg_content = message.content.data;
             *       string user_id = message.user.senderId;
             *       string user_name = message.user.senderName;
             *
             *       log.Info("[Unknown Contact Message]: From (" + user_name + "), Context: " + msg_content);
             *
             *       if (!string.IsNullOrWhiteSpace(msg_content))
             *       {
             *           info.reply = controller.AnswerOneOneQuestion(user_id, msg_content);
             *
             *       }
             *   }
             *   else
             *   {
             *       log.Warn("[Warning]: Received non-text messsage from contact: " + message.user.senderName);
             *       info.reply = "对不起,我现在只认识文字。";
             *   }
             *   break;*/
            default:
                break;
            }

            return(info);
        }
Exemple #8
0
    private void SetUpButtons()
    {
        if (Post == null)
        {
            return;
        }
        string modtext = "";

        TopicApprove.Visible = false;
        //TopicHold.Visible = false;
        hReplyQuote.Visible = false;
        hEdit.Visible       = false;
        ViewIP.Visible      = false;
        TopicDelete.Visible = false;
        SplitTopic.Visible  = false;

        PageBase page         = (PageBase)Page;
        bool     _isadmin     = page.IsAdministrator;
        bool     newerreplies = false;

        _topicid = page.TopicId != null ? page.TopicId.Value : Convert.ToInt32(Session["TOPIC"]);

        _topic         = Topics.GetTopic(_topicid);
        _isTopicLocked = _topic.Status == (int)Enumerators.PostStatus.Closed;
        _forum         = Forums.GetForum(_topic.ForumId);
        _topicid       = _topic.Id;
        bool _isForumModerator = Moderators.IsUserForumModerator(HttpContext.Current.User.Identity.Name, _forum.Id);

        if (_post is TopicInfo)
        {
            if (Cache["M" + _topic.AuthorId] == null)
            {
                _author = Members.GetAuthor(_topic.AuthorId);
                Cache.Insert("M" + _topic.AuthorId, _author, null, DateTime.Now.AddMinutes(10d),
                             System.Web.Caching.Cache.NoSlidingExpiration);
            }
            else
            {
                _author = (AuthorInfo)Cache["M" + _topic.AuthorId];
            }
            ThisId = _topic.Id;
            if (_topic.ReplyCount > 0)
            {
                newerreplies = true;
            }
            _posttype = "TOPICS";
            _postdate = _topic.Date;
            _ip       = _topic.PosterIp;

            if (_isadmin || _isForumModerator)
            {
                TopicApprove.Visible = (_topic.Status == (int)Enumerators.PostStatus.UnModerated ||
                                        _topic.Status == (int)Enumerators.PostStatus.OnHold);
                TopicApprove.OnClientClick = string.Format(
                    "mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1}'}}, 'methodHandlers.BeginRecieve');return false;",
                    false, _topic.Id);
                //TopicHold.Visible = _topic.Status == Enumerators.PostStatus.UnModerated;
            }
            if (_topic.Status == (int)Enumerators.PostStatus.UnModerated || _topic.Status == (int)Enumerators.PostStatus.OnHold)
            {
                _unmoderated = true;
                modtext      = String.Format("<span class=\"moderation\">{0}</span>", webResources.lblRequireModeration);
                if (_topic.Status == (int)Enumerators.PostStatus.OnHold)
                {
                    modtext = String.Format("<span class=\"moderation\">!!{0}!!</span>", webResources.OnHold);
                }
            }
            SplitTopic.Visible        = false;
            hEdit.Text                = webResources.lblEditTopic;
            hEdit.ToolTip             = webResources.lblEditTopic;
            TopicDelete.AlternateText = webResources.lblDelTopic;
            TopicDelete.OnClientClick = "confirmPostBack('Do you want to delete the Topic?','DeleteTopic'," + ThisId + ");return false;";
            imgPosticon.OnClientClick = "confirmBookMark('Do you want to bookmark the Topic?'," + ThisId + ",-1); return false;";
        }
        else if (_post is ReplyInfo)
        {
            ReplyInfo reply = (ReplyInfo)_post;
            _author = Members.GetAuthor(reply.AuthorId);
            ThisId  = reply.Id;
            if (_topic.LastReplyId != reply.Id)
            {
                newerreplies = true;
            }
            _posttype = "REPLY";
            _postdate = reply.Date;
            _ip       = reply.PosterIp;

            if (_isadmin || _isForumModerator)
            {
                TopicApprove.Visible = (reply.Status == (int)Enumerators.PostStatus.UnModerated ||
                                        reply.Status == (int)Enumerators.PostStatus.OnHold);
                TopicApprove.OnClientClick = string.Format(
                    "mainScreen.LoadServerControlHtml('Moderation',{{'pageID':7,'data':'{0},{1},{2}'}}, 'methodHandlers.BeginRecieve');return false;",
                    false, "", reply.Id);
                //TopicHold.Visible = reply.Status == Enumerators.PostStatus.UnModerated;
            }
            if (reply.Status == (int)Enumerators.PostStatus.UnModerated || reply.Status == (int)Enumerators.PostStatus.OnHold)
            {
                _unmoderated = true;
                modtext      = String.Format("<span class=\"moderation\">{0}</span>", webResources.lblRequireModeration);
                if (reply.Status == (int)Enumerators.PostStatus.OnHold)
                {
                    modtext = String.Format("<span class=\"moderation\">!!{0}!!</span>", webResources.OnHold);
                }
            }

            TopicDelete.AlternateText  = webResources.lblDelReply;
            SplitTopic.CommandArgument = ThisId.ToString();
            hEdit.ToolTip             = webResources.lblEditReply;
            hEdit.Text                = webResources.lblEditReply;
            TopicDelete.OnClientClick = "confirmPostBack('Do you want to delete the Reply?','DeleteReply'," + ThisId + ");return false;";
            imgPosticon.OnClientClick = "confirmBookMark('Do you want to bookmark the Reply?'," + ThisId + "," + page.CurrentPage + ");return false;";

            SplitTopic.Visible       = _isForumModerator || _isadmin;
            SplitTopic.OnClientClick = String.Format(
                "mainScreen.LoadServerControlHtml('Split Topic',{{'pageID':6,'data':'{0},asc'}}, 'methodHandlers.BeginRecieve');return false;", reply.Id);
        }
        TopicDelete.Visible = (currentUser.ToLower() == _author.Username.ToLower() &&
                               !newerreplies);

        TopicDelete.Visible       = TopicDelete.Visible || (_isForumModerator || _isadmin);
        imgPosticon.AlternateText = String.Format("#{0}", ThisId);


        date.Text = _unmoderated ? modtext : SnitzTime.TimeAgoTag(_postdate, page.IsAuthenticated, page.Member);


        ViewIP.Visible       = _isadmin && Config.LogIP;
        ViewIP.OnClientClick = string.Format(
            "mainScreen.LoadServerControlHtml('IP Lookup',{{'pageID':4,'data':'{0}'}}, 'methodHandlers.BeginRecieve');return false;",
            _ip);

        hEdit.NavigateUrl = string.Format("~/Content/Forums/post.aspx?method=edit&type={0}&id={1}&TOPIC={2}", _posttype, ThisId, _topicid);
        hEdit.Visible     = (currentUser.ToLower() == _author.Username.ToLower() && !newerreplies);
        hEdit.Visible     = hEdit.Visible && !(_isTopicLocked || _forum.Status == (int)Enumerators.PostStatus.Closed); // but not if it is locked
        hEdit.Visible     = hEdit.Visible || _isForumModerator || _isadmin;                                            //override for admins/moderator

        hReplyQuote.Visible     = page.IsAuthenticated && !(_isTopicLocked || _forum.Status == (int)Enumerators.PostStatus.Closed);
        hReplyQuote.Visible     = hReplyQuote.Visible || (_isForumModerator || _isadmin);
        hReplyQuote.NavigateUrl = String.Format("~/Content/Forums/post.aspx?method=quote&type={0}&id={1}&TOPIC={2}", _posttype, ThisId, _topicid);
    }
Exemple #9
0
 public static bool SaveReply(ReplyInfo reply)
 {
     reply.LastEditDate = DateTime.Now;
     reply.LastEditor   = ManagerHelper.GetCurrentManager().UserName;
     return(new AliFuwuReplyDao().SaveReply(reply));
 }
        private string DeletePost()
        {
            int replyId = -1;
            int TopicId = -1;

            if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"]))
            {
                TopicId = int.Parse(Params["topicid"].ToString());
            }
            if (Params.ContainsKey("replyid") && SimulateIsNumeric.IsNumeric(Params["replyid"]))
            {
                replyId = int.Parse(Params["replyid"].ToString());
            }
            int forumId = -1;

            Data.ForumsDB db = new Data.ForumsDB();
            forumId = db.Forum_GetByTopicId(TopicId);
            ForumController fc = new ForumController();
            Forum           f  = fc.Forums_Get(forumId, this.UserId, true);

            // Need to get the list of attachments BEFORE we remove the post recods
            var attachmentController = new Data.AttachController();
            var attachmentList       = (MainSettings.DeleteBehavior == 0)
                                                                         ? attachmentController.ListForPost(TopicId, replyId)
                                                                         : null;


            if (TopicId > 0 & replyId < 1)
            {
                TopicsController tc = new TopicsController();
                TopicInfo        ti = tc.Topics_Get(PortalId, ModuleId, TopicId);

                if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ti.Content.AuthorId == UserId && ti.IsLocked == false))
                {
                    DataProvider.Instance().Topics_Delete(forumId, TopicId, MainSettings.DeleteBehavior);
                    string journalKey = string.Format("{0}:{1}", forumId.ToString(), TopicId.ToString());
                    JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey);
                }
                else
                {
                    return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
                }
            }
            else
            {
                ReplyController rc = new ReplyController();
                ReplyInfo       ri = rc.Reply_Get(PortalId, ModuleId, TopicId, replyId);
                if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ri.Content.AuthorId == UserId))
                {
                    DataProvider.Instance().Reply_Delete(forumId, TopicId, replyId, MainSettings.DeleteBehavior);
                    string journalKey = string.Format("{0}:{1}:{2}", forumId.ToString(), TopicId.ToString(), replyId.ToString());
                    JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey);
                }
                else
                {
                    return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false));
                }
            }

            // If it's a hard delete, delete associated attachments
            // attachmentList will only be populated if the DeleteBehavior is 0
            if (attachmentList != null)
            {
                var fileManager      = FileManager.Instance;
                var folderManager    = FolderManager.Instance;
                var attachmentFolder = folderManager.GetFolder(PortalId, "activeforums_Attach");

                foreach (var attachment in attachmentList)
                {
                    attachmentController.Delete(attachment.AttachmentId);

                    var file = attachment.FileId.HasValue
                                                                   ? fileManager.GetFile(attachment.FileId.Value)
                                                                   : fileManager.GetFile(attachmentFolder, attachment.FileName);

                    // Only delete the file if it exists in the attachment folder
                    if (file != null && file.FolderId == attachmentFolder.FolderID)
                    {
                        fileManager.DeleteFile(file);
                    }
                }
            }

            // Return the result
            string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);

            DataCache.CacheClearPrefix(cachekey);
            return(BuildOutput(TopicId + "|" + replyId, OutputCodes.Success, true));
        }
Exemple #11
0
 public bool Update(ReplyInfo info)
 {
     return(DBHelper.ExecuteSql("UPDATE PE_Reply SET ReplyCreator = @ReplyCreator, ReplyTime = @ReplyTime, ReplyContent = @ReplyContent WHERE ID = @ID", GetParameters(info)));
 }
Exemple #12
0
 public static bool Update(ReplyInfo info)
 {
     return(dal.Update(info));
 }
Exemple #13
0
 public static bool Add(ReplyInfo info)
 {
     return(dal.Add(info));
 }
Exemple #14
0
 public static bool UpdateReply(ReplyInfo reply)
 {
     reply.LastEditDate = DateTime.Now;
     reply.LastEditor   = HiContext.Current.User.Username;
     return(new ReplyDao().UpdateReply(reply));
 }
Exemple #15
0
        public string SplitTopic(string jsonform)
        {
            var test = HttpUtility.UrlDecode(jsonform);

            System.Collections.Specialized.NameValueCollection formresult = HttpUtility.ParseQueryString(test);
            var replyIDs = new List <int>();

            foreach (string key in formresult.AllKeys)
            {
                if (key.EndsWith("cbxRow"))
                {
                    replyIDs.Add(Convert.ToInt32(formresult[key]));
                }
            }

            int    topicid = Convert.ToInt32(formresult["ctl00$splitTopicId"]);
            int    forumId = Convert.ToInt32(formresult["ctl00$ddlForum"]);
            string sort    = formresult["ctl00$ddlSort"];

            string subject = formresult["ctl00$tbxSubject"];

            if (String.IsNullOrEmpty(subject))
            {
                return("No subject supplied");
            }

            TopicInfo oldtopic = Topics.GetTopic(topicid);
            ForumInfo forum    = Forums.GetForum(forumId);

            if (replyIDs.Count == 0)
            {
                return("No replies selected");
            }
            int       lastreplyid = sort == "desc" ? replyIDs[replyIDs.Count - 1] : replyIDs[0];
            ReplyInfo lastreply   = Replies.GetReply(lastreplyid);

            //get the reply details
            var topic = new TopicInfo
            {
                Subject            = subject,
                Message            = lastreply.Message,
                Date               = lastreply.Date,
                UseSignatures      = lastreply.UseSignatures,
                IsSticky           = false,
                PosterIp           = lastreply.PosterIp,
                Views              = 0,
                ReplyCount         = replyIDs.Count - 1,
                Status             = (int)Enumerators.PostStatus.Open,
                UnModeratedReplies = 0,
                ForumId            = forumId,
                AuthorId           = lastreply.AuthorId,
                CatId              = forum.CatId
            };

            bool isModeratedForum = forum.ModerationLevel != (int)Enumerators.Moderation.UnModerated;

            if (isModeratedForum)
            {
                if (forum.ModerationLevel == (int)Enumerators.Moderation.AllPosts ||
                    forum.ModerationLevel == (int)Enumerators.Moderation.Topics)
                {
                    topic.Status = (int)Enumerators.PostStatus.UnModerated;
                }
            }

            int newtopicid = Topics.Add(topic);

            //delete the reply used as topic
            Replies.DeleteReply(lastreplyid);
            //move the other replies to this topic
            Replies.MoveReplies(newtopicid, replyIDs);
            //update the original topic count/dates
            Topics.Update(oldtopic.Id);

            Snitz.BLL.Admin.UpdateForumCounts();

            return("Selected replies were moved to a new topic");
        }
        public AbstractResponse GetResponse(ReplyInfo reply, string openId)
        {
            if (reply.MessageType == MessageType.Text)
            {
                TextReplyInfo info     = reply as TextReplyInfo;
                TextResponse  response = new TextResponse {
                    CreateTime = DateTime.Now,
                    Content    = info.Text
                };
                if (reply.Keys == "登录")
                {
                    string str = string.Format("http://{0}/Vshop/Login.aspx?SessionId={1}", HttpContext.Current.Request.Url.Host, openId);
                    response.Content = response.Content.Replace("$login$", string.Format("<a href=\"{0}\">一键登录</a>", str));
                }
                return(response);
            }
            NewsResponse response2 = new NewsResponse {
                CreateTime = DateTime.Now,
                Articles   = new List <Article>()
            };

            if (reply.ArticleID > 0)
            {
                Hidistro.Entities.Weibo.ArticleInfo articleInfo = ArticleHelper.GetArticleInfo(reply.ArticleID);
                if (articleInfo.ArticleType == Hidistro.Entities.Weibo.ArticleType.News)
                {
                    Article item = new Article {
                        Description = articleInfo.Memo,
                        PicUrl      = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, articleInfo.ImageUrl),
                        Title       = articleInfo.Title,
                        Url         = string.IsNullOrEmpty(articleInfo.Url) ? string.Format("http://{0}/Vshop/ArticleDetail.aspx?sid={1}", HttpContext.Current.Request.Url.Host, articleInfo.ArticleId) : articleInfo.Url
                    };
                    response2.Articles.Add(item);
                    return(response2);
                }
                if (articleInfo.ArticleType == Hidistro.Entities.Weibo.ArticleType.List)
                {
                    Article article3 = new Article {
                        Description = articleInfo.Memo,
                        PicUrl      = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, articleInfo.ImageUrl),
                        Title       = articleInfo.Title,
                        Url         = string.IsNullOrEmpty(articleInfo.Url) ? string.Format("http://{0}/Vshop/ArticleDetail.aspx?sid={1}", HttpContext.Current.Request.Url.Host, articleInfo.ArticleId) : articleInfo.Url
                    };
                    response2.Articles.Add(article3);
                    foreach (Hidistro.Entities.Weibo.ArticleItemsInfo info3 in articleInfo.ItemsInfo)
                    {
                        article3 = new Article {
                            Description = "",
                            PicUrl      = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, info3.ImageUrl),
                            Title       = info3.Title,
                            Url         = string.IsNullOrEmpty(info3.Url) ? string.Format("http://{0}/Vshop/ArticleDetail.aspx?iid={1}", HttpContext.Current.Request.Url.Host, info3.Id) : info3.Url
                        };
                        response2.Articles.Add(article3);
                    }
                }
                return(response2);
            }
            foreach (NewsMsgInfo info4 in (reply as NewsReplyInfo).NewsMsg)
            {
                Article article6 = new Article {
                    Description = info4.Description,
                    PicUrl      = string.Format("http://{0}{1}", HttpContext.Current.Request.Url.Host, info4.PicUrl),
                    Title       = info4.Title,
                    Url         = string.IsNullOrEmpty(info4.Url) ? string.Format("http://{0}/Vshop/ImageTextDetails.aspx?messageId={1}", HttpContext.Current.Request.Url.Host, info4.Id) : info4.Url
                };
                response2.Articles.Add(article6);
            }
            return(response2);
        }
Exemple #17
0
        private void ProcessModeration(int mode, int topicid, int replyid, int adminmodid, string comments)
        {
            ReplyInfo      reply = null;
            MembershipUser author;

            var moderator = Membership.GetUser(adminmodid);

            int forumId;

            var topic = Topics.GetTopic(topicid);

            if (replyid > 0)
            {
                reply = Replies.GetReply(replyid);
            }
            if (reply == null)
            {
                forumId = topic.ForumId;
                author  = Membership.GetUser(topic.AuthorId, false);
            }
            else
            {
                forumId = reply.ForumId;
                author  = Membership.GetUser(reply.AuthorId, false);
            }
            var forum = Forums.GetForum(forumId);

            var strSubject = new StringBuilder();

            strSubject.AppendFormat("{0} - Your post ", Regex.Replace(Config.ForumTitle, @"&\w+;", ""));
            if (mode == 1)
            {
                strSubject.AppendLine("has been approved ");
            }
            else if (mode == 2)
            {
                strSubject.AppendLine("has been placed on hold ");
            }
            else
            {
                strSubject.AppendLine("has been rejected ");
            }
            var strMessage = new StringBuilder();

            strMessage.AppendFormat("Hello {0}.", author.UserName).AppendLine().AppendLine();
            strMessage.Append("You made a ");

            if (replyid == 0)
            {
                strMessage.Append("post ");
            }
            else
            {
                strMessage.Append("reply to the post ");
            }
            strMessage.AppendFormat("in the {0} forum entitled {1}. {2} has decided to ", forum.Subject, moderator.UserName);

            if (mode == 1)
            {
                strMessage.Append("approve your post ");
            }
            else if (mode == 2)
            {
                strMessage.Append("place your post on hold ");
            }
            else
            {
                strMessage.Append("reject your post ");
            }
            strMessage.AppendLine("for the following reason:").AppendLine();
            strMessage.AppendLine(comments).AppendLine();
            strMessage.AppendFormat("If you have any questions, please contact {0} at {1}", moderator.UserName, moderator.Email).AppendLine();

            var mailsender = new SnitzEmail
            {
                toUser   = new MailAddress(author.Email, author.UserName),
                FromUser = "******",
                IsHtml   = false,
                subject  = strSubject.ToString(),
                msgBody  = strMessage.ToString()
            };

            mailsender.Send();
        }
Exemple #18
0
 public int Reply_Save(ReplyInfo ri)
 {
     return(Convert.ToInt32(Reply_Save(ri.TopicId, ri.ReplyId, ri.ReplyToId, ri.StatusId, ri.IsApproved, ri.IsDeleted, ri.Content.Subject.Trim(), ri.Content.Body.Trim(), ri.Content.DateCreated, ri.Content.DateUpdated, ri.Content.AuthorId, ri.Content.AuthorName, ri.Content.IPAddress)));
 }
Exemple #19
0
        private void SaveQuickReply()
        {
            int iFloodInterval = MainSettings.FloodInterval;
            if (iFloodInterval > 0)
            {
                UserProfileController upc = new UserProfileController();
                UserProfileInfo upi = upc.Profiles_Get(SiteId, InstanceId, this.UserId);
                if (upi != null)
                {
                    if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval)
                    {
                        Controls.InfoMessage im = new Controls.InfoMessage();
                        im.Message = "<div class=\"afmessage\">" + string.Format(Utilities.GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>";
                        plhMessage.Controls.Add(im);
                        return;
                    }
                }
            }
            //TODO: Fix for anon
            //If Not Current.Request.IsAuthenticated Then
            //    If Not ctlCaptcha.IsValid Or txtUserName.Value = "" Then
            //        Exit Sub
            //    End If
            //End If
            //Dim ui As New UserProfileInfo
            //If UserId > 0 Then
            //    Dim upc As New UserProfileController
            //    ui = upc.Profiles_Get(PortalId, ForumModuleId, UserId)
            //Else
            //    ui.TopicCount = 0
            //    ui.ReplyCount = 0
            //    ui.RewardPoints = 0
            //    ui.IsMod = False
            //    ui.TrustLevel = -1

            //End If
            ForumController fc = new ForumController();
            Forum forumInfo = fc.Forums_Get(SiteId, InstanceId, ForumId, this.UserId, true, false, TopicId);
            bool UserIsTrusted = false;
            UserIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, ControlConfig.User.TrustLevel, Permissions.HasPerm(forumInfo.Security.Trust, ForumUser.UserRoles), forumInfo.AutoTrustLevel, ControlConfig.User.PostCount);
            bool isApproved = false;
            isApproved = Convert.ToBoolean(((forumInfo.IsModerated == true) ? false : true));
            if (UserIsTrusted || Permissions.HasPerm(forumInfo.Security.ModApprove, ForumUser.UserRoles))
            {
                isApproved = true;
            }
            ReplyInfo ri = new ReplyInfo();
            Data.Topics db = new Data.Topics();
            //im rc As New ReplyController
            int ReplyId = -1;
            string sUsername = string.Empty;
            if (HttpContext.Current.Request.IsAuthenticated)
            {
                sUsername = ControlConfig.User.DisplayName;
            }
            else
            {
                sUsername = Utilities.CleanString(SiteId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, InstanceId, ThemePath, false);
            }

            string sBody = string.Empty;
            //TODO: Check for allowhtml
            bool allowHtml = false;
            //If forumInfo.AllowHTML Then
            //    allowHtml = isHTMLPermitted(forumInfo.EditorPermittedUsers, IsTrusted, forumInfo.Security.ModEdit)
            //End If
            sBody = Utilities.CleanString(SiteId, HttpContext.Current.Request.Form["txtBody"], allowHtml, EditorTypes.TEXTBOX, forumInfo.UseFilter, forumInfo.AllowScript, InstanceId, ThemePath, forumInfo.AllowEmoticons);
            DateTime createDate = DateTime.Now;
            ri.TopicId = TopicId;
            ri.ReplyToId = TopicId;
            ri.Content.AuthorId = UserId;
            ri.Content.AuthorName = sUsername;
            ri.Content.Body = sBody;
            ri.Content.DateCreated = createDate;
            ri.Content.DateUpdated = createDate;
            ri.Content.IsDeleted = false;
            ri.Content.Subject = Subject;
            ri.Content.Summary = string.Empty;
            ri.IsApproved = isApproved;
            ri.IsDeleted = false;
            ri.Content.IPAddress = HttpContext.Current.Request.UserHostAddress;
            ReplyId = db.Reply_Save(ri);
            //Check if is subscribed
            if (HttpContext.Current.Request.Params["chkSubscribe"] != null)
            {
                if (HttpContext.Current.Request.Params["chkSubscribe"] == "1" && UserId > 0)
                {
                    if (!(Subscriptions.IsSubscribed(SiteId, InstanceId, ForumId, TopicId, SubscriptionTypes.Instant, UserId)))
                    {
                        //TODO: Fix Subscriptions
                        //Dim sc As New Data.Tracking
                        //sc.Subscription_Update(SiteId, InstanceId, ForumId, TopicId, 1, UserId)
                    }
                }
            }
            if (isApproved)
            {
                //Send Subscriptions
                try
                {
                    string sURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
                    Subscriptions.SendSubscriptions(SiteId, InstanceId, PageId, ForumId, TopicId, ReplyId, UserId);

#if !SKU_LITE
                    try
                    {
                        Social oSocial = new Social();
                        oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", sURL, Subject, sBody);
                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                    }

#endif
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                }
                //Redirect to show post
                string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
                HttpContext.Current.Response.Redirect(fullURL, false);
            }
            else if (isApproved == false)
            {
                Email.SendEmailToModerators(forumInfo.ModNotifyTemplateId, SiteId, ForumId, ri.TopicId, ReplyId, InstanceId, PageId, string.Empty);
                string[] Params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId };
                HttpContext.Current.Response.Redirect(Utilities.NavigateUrl(PageId, "", Params), false);
            }
            else
            {
                string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });

#if !SKU_LITE
                try
                {
                    Modules.ActiveForums.Social oSocial = new Modules.ActiveForums.Social();
                    oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", fullURL, Subject, sBody);
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }

#endif
                HttpContext.Current.Response.Redirect(fullURL, false);
            }

            //End If


        }
Exemple #20
0
		public int Reply_Save(ReplyInfo ri)
		{
			return Convert.ToInt32(Reply_Save(ri.TopicId, ri.ReplyId, ri.ReplyToId, ri.StatusId, ri.IsApproved, ri.IsDeleted, ri.Content.Subject.Trim(), ri.Content.Body.Trim(), ri.Content.DateCreated, ri.Content.DateUpdated, ri.Content.AuthorId, ri.Content.AuthorName, ri.Content.IPAddress));
		}