Exemplo n.º 1
0
        public HttpResponseMessage ApprovePost(ModerationDTO dto)
        {
            var notify = NotificationsController.Instance.GetNotification(dto.NotificationId);

            ParseNotificationContext(notify.Context);

            var fc = new ForumController();

            var fi = fc.Forums_Get(_forumId, -1, false, true);
            if (fi == null)
                return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Forum Not Found" });

            if (!(IsMod(_forumId)))
                return Request.CreateResponse(HttpStatusCode.Forbidden, new { Message = "User is not a moderator for this forum"});

            if (_replyId > 0)
            {
                var rc = new ReplyController();
                var reply = rc.ApproveReply(PortalSettings.PortalId, _tabId, _moduleId, _forumId, _topicId, _replyId);
                if (reply == null)
                    return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Reply Not Found" });
            }
            else
            {
                var tc = new TopicsController();
                var topic = tc.ApproveTopic(PortalSettings.PortalId, _tabId, _moduleId, _forumId, _topicId);
                if (topic == null)
                    return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Topic Not Found" });
            }

            NotificationsController.Instance.DeleteNotification(dto.NotificationId);

            return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" });
        }
Exemplo n.º 2
0
        public ReplyInfo ApproveReply(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId, int ReplyId)
        {
            SettingsInfo    ms = DataCache.MainSettings(ModuleId);
            ForumController fc = new ForumController();
            Forum           fi = fc.Forums_Get(ForumId, -1, false, true);

            ReplyController rc    = new ReplyController();
            ReplyInfo       reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId);

            if (reply == null)
            {
                return(null);
            }
            reply.IsApproved = true;
            rc.Reply_Save(PortalId, reply);
            TopicsController tc = new TopicsController();

            tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId, ReplyId);
            TopicInfo topic = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false);

            if (fi.ModApproveTemplateId > 0 & reply.Author.AuthorId > 0)
            {
                Email oEmail = new Email();
                oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, reply.Author);
            }

            Subscriptions.SendSubscriptions(PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, reply.Content.AuthorId);

            try
            {
                ControlUtils ctlUtils = new ControlUtils();
                string       fullURL  = ctlUtils.BuildUrl(TabId, ModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, ForumId, TopicId, topic.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId);

                if (fullURL.Contains("~/"))
                {
                    fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
                }
                if (fullURL.EndsWith("/"))
                {
                    fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId;
                }
                Social amas = new Social();
                amas.AddReplyToJournal(PortalId, ModuleId, ForumId, TopicId, ReplyId, reply.Author.AuthorId, fullURL, reply.Content.Subject, string.Empty, reply.Content.Body, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
            return(reply);
        }
Exemplo n.º 3
0
        public ReplyInfo ApproveReply(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId, int ReplyId)
        {
            SettingsInfo ms = DataCache.MainSettings(ModuleId);
            ForumController fc = new ForumController();
            Forum fi = fc.Forums_Get(ForumId, -1, false, true);

            ReplyController rc = new ReplyController();
            ReplyInfo reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId);
            if (reply == null)
            {
                return null;
            }
            reply.IsApproved = true;
            rc.Reply_Save(PortalId, reply);
            TopicsController tc = new TopicsController();
            tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId, ReplyId);
            TopicInfo topic = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false);

            if (fi.ModApproveTemplateId > 0 & reply.Author.AuthorId > 0)
            {
                Email oEmail = new Email();
                oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, reply.Author);
            }

            Subscriptions.SendSubscriptions(PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, reply.Content.AuthorId);

            try
            {
                ControlUtils ctlUtils = new ControlUtils();
                string fullURL = ctlUtils.BuildUrl(TabId, ModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, ForumId, TopicId, topic.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId);

                if (fullURL.Contains("~/"))
                {
                    fullURL = Utilities.NavigateUrl(TabId, "", new string[] {ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId});
                }
                if (fullURL.EndsWith("/"))
                {
                    fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId;
                }
                Social amas = new Social();
                amas.AddReplyToJournal(PortalId, ModuleId, ForumId, TopicId, ReplyId, reply.Author.AuthorId, fullURL, reply.Content.Subject, string.Empty, reply.Content.Body, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
            return reply;
        }
Exemplo n.º 4
0
        public HttpResponseMessage ApprovePost(ModerationDTO dto)
        {
            var notify = NotificationsController.Instance.GetNotification(dto.NotificationId);

            ParseNotificationContext(notify.Context);

            var fc = new ForumController();

            var fi = fc.Forums_Get(_forumId, -1, false, true);

            if (fi == null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Forum Not Found" }));
            }


            if (!(IsMod(_forumId)))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, new { Message = "User is not a moderator for this forum" }));
            }


            if (_replyId > 0)
            {
                var rc    = new ReplyController();
                var reply = rc.ApproveReply(PortalSettings.PortalId, _tabId, _moduleId, _forumId, _topicId, _replyId);
                if (reply == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Reply Not Found" }));
                }
            }
            else
            {
                var tc    = new TopicsController();
                var topic = tc.ApproveTopic(PortalSettings.PortalId, _tabId, _moduleId, _forumId, _topicId);
                if (topic == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Topic Not Found" }));
                }
            }

            NotificationsController.Instance.DeleteNotification(dto.NotificationId);

            return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" }));
        }
Exemplo n.º 5
0
        private void SaveReply()
        {
            var subject = ctlForm.Subject;
            var body = ctlForm.Body;
            subject = Utilities.CleanString(PortalId, subject, false, EditorTypes.TEXTBOX, _fi.UseFilter, false, ForumModuleId, _themePath, false);
            body = Utilities.CleanString(PortalId, body, _allowHTML, _editorType, _fi.UseFilter, _fi.AllowScript, ForumModuleId, _themePath, _fi.AllowEmoticons);
            // This HTML decode is used to make Quote functionality work properly even when it appears in Text Box instead of Editor
            if (Request.Params[ParamKeys.QuoteId] != null)
            {
                body = Utilities.HTMLDecode(body);
            }
            int authorId;
            string authorName;
            if (Request.IsAuthenticated)
            {
                authorId = UserInfo.UserID;
                switch (MainSettings.UserNameDisplay.ToUpperInvariant())
                {
                    case "USERNAME":
                        authorName = UserInfo.Username.Trim(' ');
                        break;
                    case "FULLNAME":
                        authorName = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' ');
                        break;
                    case "FIRSTNAME":
                        authorName = UserInfo.FirstName.Trim(' ');
                        break;
                    case "LASTNAME":
                        authorName = UserInfo.LastName.Trim(' ');
                        break;
                    case "DISPLAYNAME":
                        authorName = UserInfo.DisplayName.Trim(' ');
                        break;
                    default:
                        authorName = UserInfo.DisplayName;
                        break;
                }
            }
            else
            {
                authorId = -1;
                authorName = Utilities.CleanString(PortalId, ctlForm.AuthorName, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, _themePath, false);
                if (authorName.Trim() == string.Empty)
                    return;
            }

            var tc = new TopicsController();
            var rc = new ReplyController();
            ReplyInfo ri;

            if (PostId > 0)
            {
                ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, PostId);
                ri.Content.DateUpdated = DateTime.Now;
            }
            else
            {
                ri = new ReplyInfo();
                var dt = DateTime.Now;
                ri.Content.DateCreated = dt;
                ri.Content.DateUpdated = dt;
            }

            if (!_isEdit)
            {
                ri.Content.AuthorId = authorId;
                ri.Content.AuthorName = authorName;
                ri.Content.IPAddress = Request.UserHostAddress;
            }

            if (Regex.IsMatch(body, "<CODE([^>]*)>", RegexOptions.IgnoreCase))
            {
                foreach (Match m in Regex.Matches(body, "<CODE([^>]*)>(.*?)</CODE>", RegexOptions.IgnoreCase))
                    body = body.Replace(m.Value, m.Value.Replace("<br>", System.Environment.NewLine));
            }

            ri.Content.Body = body;
            ri.Content.Subject = subject;
            ri.Content.Summary = string.Empty;

            if (_canModApprove && ri.Content.AuthorId != UserId)
                ri.IsApproved = ctlForm.IsApproved;
            else
                ri.IsApproved = _isApproved;

            var bSend = ri.IsApproved;
            ri.IsDeleted = false;
            ri.StatusId = ctlForm.StatusId;
            ri.TopicId = TopicId;
            var tmpReplyId = rc.Reply_Save(PortalId, ri);
            ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, tmpReplyId);
            SaveAttachments(ri.ContentId);
            //tc.ForumTopicSave(ForumID, TopicId, ReplyId)
            var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
            DataCache.CacheClearPrefix(cachekey);
            try
            {
                if (ctlForm.Subscribe && authorId == UserId)
                {
                    if (!(Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, authorId)))
                    {
                        var sc = new SubscriptionController();
                        sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, authorId, ForumUser.UserRoles);
                    }
                }
                else if (_isEdit)
                {
                    var isSub = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, authorId);
                    if (isSub && !ctlForm.Subscribe)
                    {
                        var sc = new SubscriptionController();
                        sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, authorId, ForumUser.UserRoles);
                    }
                }
                if (bSend && !_isEdit)
                {
                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, _fi, TopicId, tmpReplyId, ri.Content.AuthorId);
                }
                if (ri.IsApproved == false)
                {
                    var ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId);

                    var mods = Utilities.GetListOfModerators(PortalId, ForumId);
                    var notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration");
                    var notifySubject = Utilities.GetSharedResource("NotificationSubjectReply");
                    notifySubject = notifySubject.Replace("[DisplayName]", UserInfo.DisplayName);
                    notifySubject = notifySubject.Replace("[TopicSubject]", ti.Content.Subject);
                    var notifyBody = Utilities.GetSharedResource("NotificationBodyReply");
                    notifyBody = notifyBody.Replace("[Post]", ri.Content.Body);
                    var notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ri.ReplyId);

                    var notification = new Notification
                                           {
                                               NotificationTypeID = notificationType.NotificationTypeId,
                                               Subject = notifySubject,
                                               Body = notifyBody,
                                               IncludeDismissAction = false,
                                               SenderUserID = UserInfo.UserID,
                                               Context = notificationKey
                                           };

                    NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);

                    string[] @params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.MessagePending };
                    Response.Redirect(Utilities.NavigateUrl(ForumTabId, "", @params), false);
                }
                else
                {
                    var ctlUtils = new ControlUtils();
                    var ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false);
                    var fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, tmpReplyId, SocialGroupId);

                    if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                        fullURL = Utilities.NavigateUrl(ForumTabId, "", new[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });

                    if (fullURL.EndsWith("/"))
                        fullURL += "?" + ParamKeys.ContentJumpId + "=" + tmpReplyId;

                    if (!_isEdit)
                    {
                        try
                        {
                            var amas = new Social();
                            amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, subject, string.Empty, body, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                            //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then
                            //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, Body, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                            //Else
                            //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, Body)
                            //End If

                        }
                        catch (Exception ex)
                        {
                            Services.Exceptions.Exceptions.LogException(ex);
                        }

                    }
                    Response.Redirect(fullURL);
                }
            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Prepares the post form for creating a reply.
        /// </summary>
        private void PrepareReply()
        {
            ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.Reply;

            string template;
            if (_fi.ReplyFormId == 0)
            {
                var myFile = Request.MapPath(Common.Globals.ApplicationPath) + "\\DesktopModules\\ActiveForums\\config\\templates\\ReplyEditor.txt";
                template = File.ReadAllText(myFile);
            }
            else
            {
                var tc = new TemplateController();
                var ti = tc.Template_Get(_fi.ReplyFormId, PortalId, ForumModuleId);
                template = ti.TemplateHTML;
            }

            if (MainSettings.UseSkinBreadCrumb)
                template = template.Replace("<div class=\"afcrumb\">[AF:LINK:FORUMMAIN] > [AF:LINK:FORUMGROUP] > [AF:LINK:FORUMNAME]</div>", string.Empty);

            ctlForm.Template = template;
            if (!(TopicId > 0))
            {
                //Can't Find Topic
                var im = new InfoMessage { Message = GetSharedResource("[RESX:Message:LoadTopicFailed]") };
                plhContent.Controls.Add(im);
            }
            else if (!CanReply)
            {
                //No permission to reply
                var im = new InfoMessage { Message = GetSharedResource("[RESX:Message:AccessDenied]") };
                plhContent.Controls.Add(im);
            }
            else
            {
                var tc = new TopicsController();
                var ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, UserId, true);

                if(ti == null)
                    Response.Redirect(NavigateUrl(ForumTabId));

                ctlForm.Subject = Utilities.GetSharedResource("[RESX:SubjectPrefix]") + " " + ti.Content.Subject;
                ctlForm.TopicSubject = ti.Content.Subject;
                var body = string.Empty;

                if (ti.IsLocked && (CurrentUserType == CurrentUserTypes.Anon || CurrentUserType == CurrentUserTypes.Auth))
                    Response.Redirect(NavigateUrl(ForumTabId));

                if (Request.Params[ParamKeys.QuoteId] != null | Request.Params[ParamKeys.ReplyId] != null | Request.Params[ParamKeys.PostId] != null)
                {
                    //Setup form for Quote or Reply with body display
                    var isQuote = false;
                    var postId = 0;
                    var sPostedBy = Utilities.GetSharedResource("[RESX:PostedBy]") + " {0} {1} {2}";
                    if (Request.Params[ParamKeys.QuoteId] != null)
                    {
                        isQuote = true;
                        if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.QuoteId]))
                            postId = Convert.ToInt32(Request.Params[ParamKeys.QuoteId]);

                    }
                    else if (Request.Params[ParamKeys.ReplyId] != null)
                    {
                        if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.ReplyId]))
                            postId = Convert.ToInt32(Request.Params[ParamKeys.ReplyId]);
                    }
                    else if (Request.Params[ParamKeys.PostId] != null)
                    {
                        if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.PostId]))
                            postId = Convert.ToInt32(Request.Params[ParamKeys.PostId]);
                    }

                    if (postId != 0)
                    {
                        var userDisplay = MainSettings.UserNameDisplay;
                        if (_editorType == EditorTypes.TEXTBOX)
                            userDisplay = "none";

                        Content ci;
                        if (postId == TopicId)
                        {
                            ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId);
                            ci = ti.Content;
                            sPostedBy = string.Format(sPostedBy, UserProfiles.GetDisplayName(ForumModuleId, true, false, false, ti.Content.AuthorId, ti.Author.Username, ti.Author.FirstName, ti.Author.LastName, ti.Author.DisplayName), Utilities.GetSharedResource("On.Text"), GetServerDateTime(ti.Content.DateCreated));
                        }
                        else
                        {
                            var rc = new ReplyController();
                            var ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, postId);
                            ci = ri.Content;
                            sPostedBy = string.Format(sPostedBy, UserProfiles.GetDisplayName(ForumModuleId, true, false, false, ri.Content.AuthorId, ri.Author.Username, ri.Author.FirstName, ri.Author.LastName, ri.Author.DisplayName), Utilities.GetSharedResource("On.Text"), GetServerDateTime(ri.Content.DateCreated));
                        }

                        if (ci != null)
                            body = ci.Body;

                    }

                    if (_allowHTML && _editorType != EditorTypes.TEXTBOX)
                    {
                        if (body.ToUpper().Contains("<CODE") | body.ToUpper().Contains("[CODE]"))
                        {
                            var objCode = new CodeParser();
                            body = CodeParser.ParseCode(Utilities.HTMLDecode(body));
                        }
                    }
                    else
                    {
                        body = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, body, _allowHTML, _editorType);
                    }

                    if (isQuote)
                    {
                        ctlForm.EditorMode = SubmitForm.EditorModes.Quote;
                        if (_allowHTML && _editorType != EditorTypes.TEXTBOX)
                        {
                            body = "<blockquote>" + System.Environment.NewLine + sPostedBy + System.Environment.NewLine + "<br />" + System.Environment.NewLine + body + System.Environment.NewLine + "</blockquote><br /><br />";
                        }
                        else
                        {
                            body = "[quote]" + System.Environment.NewLine + sPostedBy + System.Environment.NewLine + body + System.Environment.NewLine + "[/quote]" + System.Environment.NewLine;
                        }
                    }
                    else
                    {
                        ctlForm.EditorMode = SubmitForm.EditorModes.ReplyWithBody;
                        body = sPostedBy + "<br />" + body;
                    }
                    ctlForm.Body = body;

                }
            }
            if (ctlForm.EditorMode != SubmitForm.EditorModes.EditReply && _canModApprove)
            {
                ctlForm.ShowModOptions = false;
            }
        }
Exemplo n.º 7
0
        private void LoadReply()
        {
            //Edit a Reply
            ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.EditReply;

            var rc = new ReplyController();
            var ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, PostId);

            if (ri == null)
                Response.Redirect(NavigateUrl(ForumTabId));
            else if ((ri.Content.AuthorId != UserId && _canModEdit == false) | (ri.Content.AuthorId == UserId && _canEdit == false) | (_canEdit == false && _canModEdit))
                Response.Redirect(NavigateUrl(ForumTabId));

            else if (!_canModEdit && (ri.Content.AuthorId == UserId && _canEdit && MainSettings.EditInterval > 0 & SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, ri.Content.DateCreated, DateTime.Now) > MainSettings.EditInterval))
            {
                var im = new Controls.InfoMessage
                             {
                                 Message = "<div class=\"afmessage\">" +  string.Format(GetSharedResource("[RESX:Message:EditIntervalReached]"), MainSettings.EditInterval.ToString()) + "</div>"
                             };
                plhMessage.Controls.Add(im);
                plhContent.Controls.Clear();
            }
            else
            {
                var sBody = ri.Content.Body;
                var sSubject = ri.Content.Subject;
                sBody = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, sBody, _allowHTML, _editorType);
                sSubject = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, sSubject, false, EditorTypes.TEXTBOX);
                ctlForm.Subject = sSubject;
                ctlForm.Body = sBody;
                ctlForm.IsApproved = ri.IsApproved;
                _contentId = ri.ContentId;
                _authorId = ri.Author.AuthorId;

                if (ri.Author.AuthorId > 0)
                    ctlForm.Subscribe = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, ri.Author.AuthorId);

                if (ri.Content.AuthorId != UserId && _canModApprove)
                    ctlForm.ShowModOptions = true;
            }
        }
Exemplo n.º 8
0
        private void btnSend_Click(object sender, System.EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                Email objEmail = new Email();
                string Comments = null;
                Comments = drpReasons.SelectedItem.Value + "<br>";
                Comments += Utilities.CleanString(PortalId, txtComments.Text, false, EditorTypes.TEXTBOX, false, false, ModuleId, string.Empty, false);
                int templateId = 0;
                TemplateController tc = new TemplateController();
                TemplateInfo ti = tc.Template_Get("ModAlert", PortalId, ModuleId);
                string sUrl = NavigateUrl(Convert.ToInt32(Request.QueryString["TabId"]), "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.AlertSent });

                NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ContentAlert");
                TopicsController topicController = new TopicsController();
                TopicInfo topic = topicController.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false);
                string sBody = string.Empty;
                string authorName = string.Empty;
                string sSubject = string.Empty;
                string sTopicURL = string.Empty;
                sTopicURL = topic.TopicUrl;
                if (ReplyId > 0 & TopicId != ReplyId)
                {
                    ReplyController rc = new ReplyController();
                    ReplyInfo reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId);
                    sBody = reply.Content.Body;
                    sSubject = reply.Content.Subject;
                    authorName = reply.Author.DisplayName;

                }
                else
                {
                    sBody = topic.Content.Body;
                    sSubject = topic.Content.Subject;
                    authorName = topic.Author.DisplayName;

                }
                ControlUtils ctlUtils = new ControlUtils();
                string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, sTopicURL, -1, -1, string.Empty, 1, ReplyId, SocialGroupId);
                string subject = Utilities.GetSharedResource("AlertSubject");
                subject = subject.Replace("[DisplayName]", authorName);
                subject = subject.Replace("[Subject]", sSubject);
                string body = Utilities.GetSharedResource("AlertBody");
                body = body.Replace("[Post]", sBody);
                body = body.Replace("[Comment]", Comments);
                body = body.Replace("[URL]", fullURL);
                body = body.Replace("[Reason]", drpReasons.SelectedItem.Value);
                List<Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId);


                string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId);

                Notification notification = new Notification();
                notification.NotificationTypeID = notificationType.NotificationTypeId;
                notification.Subject = subject;
                notification.Body = body;
                notification.IncludeDismissAction = false;
                notification.SenderUserID = UserInfo.UserID;
                notification.Context = notificationKey;


                NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);



                Response.Redirect(sUrl);
            }
        }
Exemplo n.º 9
0
        public static string ParseEmailTemplate(string template, string templateName, int portalID, int moduleID, int tabID, int forumID, int topicId, int replyId, string comments, Entities.Users.UserInfo user, int userId, int timeZoneOffset)
        {
            var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            var ms             = DataCache.MainSettings(moduleID);
            var sOut           = template;

            // If we have a template name, load the template into sOut
            if (templateName != string.Empty)
            {
                if (templateName.Contains("_Subject_"))
                {
                    templateName = templateName.Replace("_Subject_" + moduleID, string.Empty);
                    var objTemplate = GetTemplateByName(templateName, moduleID, portalID);
                    sOut = objTemplate.Subject;
                }
                else
                {
                    var objTemplate = GetTemplateByName(templateName, moduleID, portalID);
                    sOut = objTemplate.TemplateHTML;
                }
            }

            // Load Subject and body from topic or reply

            var subject     = string.Empty;
            var body        = string.Empty;
            var dateCreated = Utilities.NullDate();
            var authorName  = string.Empty;

            if (topicId > 0 && replyId > 0)
            {
                var ri = new ReplyController().Reply_Get(portalID, moduleID, topicId, replyId);
                if (ri != null)
                {
                    subject     = ri.Content.Subject;
                    body        = ri.Content.Body;
                    dateCreated = ri.Content.DateCreated;
                    authorName  = ri.Content.AuthorName;
                }
            }
            else
            {
                var ti = new TopicsController().Topics_Get(portalID, moduleID, topicId);
                if (ti != null)
                {
                    subject     = ti.Content.Subject;
                    body        = ti.Content.Body;
                    dateCreated = ti.Content.DateCreated;
                    authorName  = ti.Content.AuthorName;
                }
            }

            body = Utilities.ManageImagePath(body, Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)));

            // load the forum information
            var fi = new ForumController().Forums_Get(forumID, -1, false);

            // Load the user if needed
            if (user == null)
            {
                var objUsers = new Entities.Users.UserController();
                var objUser  = objUsers.GetUser(portalID, userId);
                user = objUser;
            }

            // Load the user properties

            string sFirstName;
            string sLastName;
            string sDisplayName;
            string sUsername;

            if (user != null)
            {
                sFirstName   = user.FirstName;
                sLastName    = user.LastName;
                sDisplayName = user.DisplayName;
                sUsername    = user.Username;
            }
            else
            {
                sFirstName   = string.Empty;
                sLastName    = string.Empty;
                sDisplayName = string.Empty;
                sUsername    = string.Empty;
            }

            // Build the link

            string link;

            if (string.IsNullOrEmpty(fi.PrefixURL) || !Utilities.IsRewriteLoaded())
            {
                if (replyId == 0)
                {
                    link = ms.UseShortUrls ? Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.TopicId + "=" + topicId })
                        : Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + topicId });
                }
                else
                {
                    link = ms.UseShortUrls ? Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.TopicId + "=" + topicId, ParamKeys.ContentJumpId + "=" + replyId })
                        : Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + topicId, ParamKeys.ContentJumpId + "=" + replyId });
                }
            }
            else
            {
                var contentId = (replyId > 0) ? replyId : -1;
                link = new Data.Common().GetUrl(moduleID, -1, forumID, topicId, -1, contentId);
            }

            if (!(link.StartsWith("http")))
            {
                if (!link.StartsWith("/"))
                {
                    link = "/" + link;
                }

                if (link.IndexOf(HttpContext.Current.Request.Url.Host, StringComparison.Ordinal) == -1)
                {
                    link = Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + link;
                }
            }


            // Build the forum Url
            var forumURL = ms.UseShortUrls ? Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID })
                : Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID, ParamKeys.ViewType + "=" + Views.Topics });

            // Build Moderation url
            var modLink = Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ViewType + "=modtopics", ParamKeys.ForumId + "=" + forumID });

            if (modLink.IndexOf(HttpContext.Current.Request.Url.Host, StringComparison.Ordinal) == -1)
            {
                modLink = Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + modLink;
            }

            var result = new StringBuilder(sOut);

            result.Replace("[DISPLAYNAME]", UserProfiles.GetDisplayName(moduleID, userId, authorName, sFirstName, sLastName, sDisplayName));
            result.Replace("[USERNAME]", sUsername);
            result.Replace("[USERID]", userId.ToString());
            result.Replace("[FORUMNAME]", fi.ForumName);
            result.Replace("[PORTALID]", portalID.ToString());
            result.Replace("[FIRSTNAME]", sFirstName);
            result.Replace("[LASTNAME]", sLastName);
            result.Replace("[FULLNAME]", sFirstName + " " + sLastName);
            result.Replace("[GROUPNAME]", fi.GroupName);
            result.Replace("[POSTDATE]", Utilities.GetDate(dateCreated, moduleID, timeZoneOffset));
            result.Replace("[COMMENTS]", comments);
            result.Replace("[PORTALNAME]", portalSettings.PortalName);
            result.Replace("[MODLINK]", "<a href=\"" + modLink + "\">" + modLink + "</a>");
            result.Replace("[LINK]", "<a href=\"" + link + "\">" + link + "</a>");
            result.Replace("[HYPERLINK]", "<a href=\"" + link + "\">" + link + "</a>");
            result.Replace("[LINKURL]", link);
            result.Replace("[FORUMURL]", forumURL);
            result.Replace("[FORUMLINK]", "<a href=\"" + forumURL + "\">" + forumURL + "</a>");


            if (user != null)
            {
                result.Replace("[SENDERUSERNAME]", user.UserID.ToString());
                result.Replace("[SENDERFIRSTNAME]", user.FirstName);
                result.Replace("[SENDERLASTNAME]", user.LastName);
                result.Replace("[SENDERDISPLAYNAME]", user.DisplayName);
            }
            else
            {
                result.Replace("[SENDERUSERNAME]", string.Empty);
                result.Replace("[SENDERFIRSTNAME]", string.Empty);
                result.Replace("[SENDERLASTNAME]", string.Empty);
                result.Replace("[SENDERDISPLAYNAME]", string.Empty);
            }

            result.Replace("[SUBJECT]", subject);
            result.Replace("[BODY]", body);
            result.Replace("[Body]", body);

            return(result.ToString());
        }
Exemplo n.º 10
0
        private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            Forum fi = null;
            if (e.Parameters.Length > 0)
            {
                if (ForumId < 1)
                {
                    SetPermissions(Convert.ToInt32(e.Parameters[1]));
                    ForumController fc = new ForumController();
                    fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true);
                }
                else
                {
                    fi = ForumInfo;
                }
                switch (e.Parameters[0].ToLowerInvariant())
                {
                    case "moddel":
                        {
                            if (bModDelete)
                            {
                                int delAction = ms.DeleteBehavior;
                                int tmpForumId = -1;
                                int tmpTopicId = -1;
                                int tmpReplyId = -1;
                                tmpForumId = Convert.ToInt32(e.Parameters[1]);
                                tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                                tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                                Author auth = null;
                                if (fi.ModDeleteTemplateId > 0)
                                {
                                    try
                                    {
                                        Email oEmail = new Email();
                                        oEmail.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth);
                                    }
                                    catch (Exception ex)
                                    {

                                    }

                                }
                                if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                                {
                                    TopicsController tc = new TopicsController();
                                    TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId);
                                    if (ti != null)
                                    {
                                        auth = ti.Author;
                                    }
                                    tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction);
                                }
                                else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                                {
                                    ReplyController rc = new ReplyController();
                                    ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                                    if (ri != null)
                                    {
                                        auth = ri.Author;
                                    }
                                    rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction);
                                }

                            }
                            break;
                        }
                    case "modreject":
                        {
                            int tmpForumId = 0;
                            int tmpTopicId = 0;
                            int tmpReplyId = 0;
                            int tmpAuthorId = 0;
                            tmpForumId = Convert.ToInt32(e.Parameters[1]);
                            tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                            tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                            tmpAuthorId = Convert.ToInt32(e.Parameters[4]);
                            ModController mc = new ModController();
                            mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId);
                            if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0)
                            {
                                DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                                DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, tmpAuthorId);
                                if (ui != null)
                                {
                                    Author au = new Author();
                                    au.AuthorId = tmpAuthorId;
                                    au.DisplayName = ui.DisplayName;
                                    au.Email = ui.Email;
                                    au.FirstName = ui.FirstName;
                                    au.LastName = ui.LastName;
                                    au.Username = ui.Username;
                                    Email oEmail = new Email();
                                    oEmail.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au);
                                }

                            }

                            break;
                        }
                    case "modappr":
                        {
                            int tmpForumId = -1;
                            int tmpTopicId = -1;
                            int tmpReplyId = -1;
                            tmpForumId = Convert.ToInt32(e.Parameters[1]);
                            tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                            tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                            string sSubject = string.Empty;
                            string sBody = string.Empty;
                            if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                            {
                                TopicsController tc = new TopicsController();
                                TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                                if (ti != null)
                                {
                                    sSubject = ti.Content.Subject;
                                    sBody = ti.Content.Body;
                                    ti.IsApproved = true;
                                    tc.TopicSave(PortalId, ti);
                                    tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId);
                                    //TODO: Add Audit log for who approved topic
                                    if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0)
                                    {
                                        Email oEmail = new Email();
                                        oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author);
                                    }

                                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId);

                                    try
                                    {
                                        ControlUtils ctlUtils = new ControlUtils();
                                        string sUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId)
                                        if (sUrl.Contains("~/") || Request.QueryString["asg"] != null)
                                        {
                                            sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
                                        }
                                        Social amas = new Social();
                                        if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled)
                                        {
                                            amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId);
                                        }
                                        else
                                        {
                                            amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody);
                                        }

                                    }
                                    catch (Exception ex)
                                    {
                                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                                    }
                                }
                            }
                            else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                            {
                                ReplyController rc = new ReplyController();
                                ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                                if (ri != null)
                                {
                                    ri.IsApproved = true;
                                    sSubject = ri.Content.Subject;
                                    sBody = ri.Content.Body;
                                    rc.Reply_Save(PortalId, ri);
                                    TopicsController tc = new TopicsController();
                                    tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId);
                                    TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                                    //TODO: Add Audit log for who approved topic
                                    if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0)
                                    {
                                        Email oEmail = new Email();
                                        oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author);
                                    }

                                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId);

                                    try
                                    {
                                        ControlUtils ctlUtils = new ControlUtils();
                                        string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId);
                                        if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                                        {
                                            fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
                                        }
                                        Social amas = new Social();
                                        if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly)
                                        {
                                            amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
                                        }
                                        else
                                        {
                                            amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                                    }

                                }

                            }

                            break;
                        }
                }
                string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
            }
            BuildModList();
            litTopics.RenderControl(e.Output);
        }
        private XmlRpcStruct Reply(int forumId, int topicId, string subject, string body, IEnumerable<string> attachmentIds, string groupID, bool returnHtml)
        {
            var aftContext = ActiveForumsTapatalkModuleContext.Create(Context);

            Context.Response.AddHeader("Mobiquo_is_login", aftContext.UserId > 0 ? "true" : "false");

            var portalId = aftContext.Module.PortalID;
            var forumModuleId = aftContext.ModuleSettings.ForumModuleId;

            var fc = new AFTForumController();

            var forumInfo = fc.GetForum(portalId, forumModuleId, forumId);

            // Verify Post Permissions
            if (!ActiveForums.Permissions.HasPerm(forumInfo.Security.Reply, aftContext.ForumUser.UserRoles))
            {
                return new XmlRpcStruct
                                {
                                    {"result", "false"}, //"true" for success
                                    {"result_text", "Not Authorized to Reply".ToBytes()}, 
                                };
            }

            // Build User Permissions
            var canModApprove = ActiveForums.Permissions.HasPerm(forumInfo.Security.ModApprove, aftContext.ForumUser.UserRoles);
            var canTrust = ActiveForums.Permissions.HasPerm(forumInfo.Security.Trust, aftContext.ForumUser.UserRoles);
            var canDelete = ActiveForums.Permissions.HasPerm(forumInfo.Security.Delete, aftContext.ForumUser.UserRoles);
            var canModDelete = ActiveForums.Permissions.HasPerm(forumInfo.Security.ModDelete, aftContext.ForumUser.UserRoles);
            var canEdit = ActiveForums.Permissions.HasPerm(forumInfo.Security.Edit, aftContext.ForumUser.UserRoles);
            var canModEdit = ActiveForums.Permissions.HasPerm(forumInfo.Security.ModEdit, aftContext.ForumUser.UserRoles);

            var userProfile = aftContext.UserId > 0 ? aftContext.ForumUser.Profile : new UserProfileInfo { TrustLevel = -1 };
            var userIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, userProfile.TrustLevel, canTrust, forumInfo.AutoTrustLevel, userProfile.PostCount);

            // Determine if the post should be approved
            var isApproved = !forumInfo.IsModerated || userIsTrusted || canModApprove;

            var mainSettings = new SettingsInfo { MainSettings = new Entities.Modules.ModuleController().GetModuleSettings(forumModuleId) };

            var dnnUser = Entities.Users.UserController.GetUserById(portalId, aftContext.UserId);

            var authorName = GetAuthorName(mainSettings, dnnUser);

            var themePath = string.Format("{0}://{1}{2}", Context.Request.Url.Scheme, Context.Request.Url.Host, VirtualPathUtility.ToAbsolute("~/DesktopModules/activeforums/themes/" + mainSettings.Theme + "/"));

            subject = Utilities.CleanString(portalId, subject, false, EditorTypes.TEXTBOX, forumInfo.UseFilter, false, forumModuleId, themePath, false);
            body = Utilities.CleanString(portalId, TapatalkToHtml(body), forumInfo.AllowHTML, EditorTypes.HTMLEDITORPROVIDER, forumInfo.UseFilter, false, forumModuleId, themePath, forumInfo.AllowEmoticons);

            var dt = DateTime.Now;

            var ri = new ReplyInfo();
            ri.Content.DateCreated = dt;
            ri.Content.DateUpdated = dt;
            ri.Content.AuthorId = aftContext.UserId;
            ri.Content.AuthorName = authorName;
            ri.Content.IPAddress = Context.Request.UserHostAddress;
            ri.Content.Subject = subject;
            ri.Content.Summary = string.Empty;
            ri.Content.Body = body;
            ri.TopicId = topicId;
            ri.IsApproved = isApproved;
            ri.IsDeleted = false;
            ri.StatusId = -1;

            // Save the topic
            var rc = new ReplyController();
            var replyId = rc.Reply_Save(portalId, ri);
            ri = rc.Reply_Get(portalId, forumModuleId, topicId, replyId);

            if (ri == null)
            {
                return new XmlRpcStruct
                                {
                                    {"result", "false"}, //"true" for success
                                    {"result_text", "Error Creating Post".ToBytes()}, 
                                };
            }

            try
            {
                // Clear the cache
                var cachekey = string.Format("AF-FV-{0}-{1}", portalId, forumModuleId);
                DataCache.CacheClearPrefix(cachekey);

                // Subscribe the user if they have auto-subscribe set.
                if (userProfile.PrefSubscriptionType != SubscriptionTypes.Disabled && !(Subscriptions.IsSubscribed(portalId, forumModuleId, forumId, topicId, SubscriptionTypes.Instant, aftContext.UserId)))
                {
                    new SubscriptionController().Subscription_Update(portalId, forumModuleId, forumId, topicId, (int)userProfile.PrefSubscriptionType, aftContext.UserId, aftContext.ForumUser.UserRoles);
                }

                if (isApproved)
                {
                    // Send User Notifications
                    Subscriptions.SendSubscriptions(portalId, forumModuleId, aftContext.ModuleSettings.ForumTabId, forumInfo, topicId, ri.ReplyId, ri.Content.AuthorId);

                    // Add Journal entry
                    var forumTabId = aftContext.ModuleSettings.ForumTabId;
                    var ti = new TopicsController().Topics_Get(portalId, forumModuleId, topicId, forumId, -1, false);
                    var fullURL = new ControlUtils().BuildUrl(forumTabId, forumModuleId, forumInfo.ForumGroup.PrefixURL, forumInfo.PrefixURL, forumInfo.ForumGroupId, forumInfo.ForumID, topicId, ti.TopicUrl, -1, -1, string.Empty, 1, replyId, forumInfo.SocialGroupId);
                    new Social().AddReplyToJournal(portalId, forumModuleId, forumId, topicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, ri.Content.Body, forumInfo.ActiveSocialSecurityOption, forumInfo.Security.Read, forumInfo.SocialGroupId);
                }
                else
                {
                    // Send Mod Notifications
                    var mods = Utilities.GetListOfModerators(portalId, forumId);
                    var notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration");
                    var notifySubject = Utilities.GetSharedResource("NotificationSubjectReply");
                    notifySubject = notifySubject.Replace("[DisplayName]", dnnUser.DisplayName);
                    notifySubject = notifySubject.Replace("[TopicSubject]", ri.Content.Subject);
                    var notifyBody = Utilities.GetSharedResource("NotificationBodyReply");
                    notifyBody = notifyBody.Replace("[Post]", ri.Content.Body);
                    var notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", aftContext.ModuleSettings.ForumTabId, forumModuleId, forumId, topicId, replyId);

                    var notification = new Notification
                    {
                        NotificationTypeID = notificationType.NotificationTypeId,
                        Subject = notifySubject,
                        Body = notifyBody,
                        IncludeDismissAction = false,
                        SenderUserID = dnnUser.UserID,
                        Context = notificationKey
                    };

                    NotificationsController.Instance.SendNotification(notification, portalId, null, mods);
                }

            }
            catch (Exception ex)
            {
                Services.Exceptions.Exceptions.LogException(ex);
            }


            var result = new XmlRpcStruct
            {
                {"result", true}, //"true" for success
                //{"result_text", "OK".ToBytes()}, 
                {"post_id", ri.ContentId.ToString()},
                {"post_content", HtmlToTapatalk(ri.Content.Body, false).ToBytes() },
                {"can_edit", canEdit || canModEdit },
                {"can_delete", canDelete || canModDelete },
                {"post_time", dt}/*,
                {"attachments", new {}}*/
            };

            if (!isApproved)
                result.Add("state", 1);

            return result;


        }
Exemplo n.º 12
0
        private void SaveQuickReply()
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            int iFloodInterval = MainSettings.FloodInterval;
            if (iFloodInterval > 0)
            {

                UserProfileInfo upi = ForumUser.Profile;
                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(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>";
                        plhMessage.Controls.Add(im);
                        return;
                    }
                }
            }
            if (!Request.IsAuthenticated)
            {
                if ((!ctlCaptcha.IsValid) || txtUserName.Value == "")
                {
                    return;
                }
            }
            UserProfileInfo ui = new UserProfileInfo();
            if (UserId > 0)
            {
                ui = ForumUser.Profile;
            }
            else
            {
                ui.TopicCount = 0;
                ui.ReplyCount = 0;
                ui.RewardPoints = 0;
                ui.IsMod = false;
                ui.TrustLevel = -1;

            }
            bool UserIsTrusted = false;
            UserIsTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ui.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles), ForumInfo.AutoTrustLevel, ui.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();
            ReplyController rc = new ReplyController();
            int ReplyId = -1;
            string sUsername = string.Empty;
            if (Request.IsAuthenticated)
            {
                switch (MainSettings.UserNameDisplay.ToUpperInvariant())
                {
                    case "USERNAME":
                        sUsername = UserInfo.Username.Trim(' ');
                        break;
                    case "FULLNAME":
                        sUsername = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' ');
                        break;
                    case "FIRSTNAME":
                        sUsername = UserInfo.FirstName.Trim(' ');
                        break;
                    case "LASTNAME":
                        sUsername = UserInfo.LastName.Trim(' ');
                        break;
                    case "DISPLAYNAME":
                        sUsername = UserInfo.DisplayName.Trim(' ');
                        break;
                    default:
                        sUsername = UserInfo.DisplayName;
                        break;
                }

            }
            else
            {
                sUsername = Utilities.CleanString(PortalId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, ThemePath, false);
            }

            //Dim sSubject As String = Server.HtmlEncode(Request.Form("txtSubject"))
            //If (UseFilter) Then
            //    sSubject = Utilities.FilterWords(PortalId,  ForumModuleId, ThemePath, sSubject)
            //End If
            string sBody = string.Empty;
            if (AllowHTML)
            {
                AllowHTML = IsHtmlPermitted(ForumInfo.EditorPermittedUsers, IsTrusted, Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles));
            }
            sBody = Utilities.CleanString(PortalId, Request.Form["txtBody"], AllowHTML, EditorTypes.TEXTBOX, UseFilter, AllowScripts, ForumModuleId, 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 = Request.UserHostAddress;
            ReplyId = rc.Reply_Save(PortalId, ri);
            //Check if is subscribed
            string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
            DataCache.CacheClearPrefix(cachekey);


            // Subscribe or unsubscribe if needed
            if (AllowSubscribe && UserId > 0)
            {
                var subscribe = Request.Params["chkSubscribe"] == "1";
                var currentlySubscribed = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, UserId);

                if (subscribe != currentlySubscribed)
                {
                    // Will need to update this to support multiple subscrition types later
                    // Subscription_Update works as a toggle, so you only call it if you want to change the value.
                    var sc = new SubscriptionController();
                    sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, UserId, ForumUser.UserRoles);
                }
            }



            ControlUtils ctlUtils = new ControlUtils();
            TopicsController tc = new TopicsController();
            TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false);
            string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, -1, ReplyId, SocialGroupId);

            if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
            {
                fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
            }
            if (fullURL.EndsWith("/"))
            {
                fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId;
            }
            if (isApproved)
            {

                //Send Subscriptions

                try
                {
                    //Dim sURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, TabId, ForumId, TopicId, ReplyId, UserId);
                    try
                    {
                        Social amas = new Social();
                        amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                        //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then
                        //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                        //Else
                        //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody)
                        //End If

                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                    }
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                }
                //Redirect to show post

                Response.Redirect(fullURL, false);
            }
            else if (isApproved == false)
            {
                List<Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId);
                NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration");
                string subject = Utilities.GetSharedResource("NotificationSubjectReply");
                subject = subject.Replace("[DisplayName]", UserInfo.DisplayName);
                subject = subject.Replace("[TopicSubject]", ti.Content.Subject);
                string body = Utilities.GetSharedResource("NotificationBodyReply");
                body = body.Replace("[Post]", sBody);
                string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId);

                Notification notification = new Notification();
                notification.NotificationTypeID = notificationType.NotificationTypeId;
                notification.Subject = subject;
                notification.Body = body;
                notification.IncludeDismissAction = false;
                notification.SenderUserID = UserInfo.UserID;
                notification.Context = notificationKey;

                NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);

                var @params = new List<string> { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId };
                if (SocialGroupId > 0)
                {
                    @params.Add("GroupId=" + SocialGroupId);
                }
                Response.Redirect(Utilities.NavigateUrl(TabId, "", @params.ToArray()), false);
            }
            else
            {
                //Dim fullURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                //If MainSettings.UseShortUrls Then
                //    fullURL = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                //End If

                try
                {
                    Social amas = new Social();
                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                    //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled Then
                    //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                    //Else
                    //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody)
                    //End If

                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
                Response.Redirect(fullURL, false);
            }

            //End If


        }
Exemplo n.º 13
0
        private void SaveQuickReply()
        {
            SettingsInfo ms             = DataCache.MainSettings(ForumModuleId);
            int          iFloodInterval = MainSettings.FloodInterval;

            if (iFloodInterval > 0)
            {
                UserProfileInfo upi = ForumUser.Profile;
                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(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>";
                        plhMessage.Controls.Add(im);
                        return;
                    }
                }
            }
            if (!Request.IsAuthenticated)
            {
                if ((!ctlCaptcha.IsValid) || txtUserName.Value == "")
                {
                    return;
                }
            }
            UserProfileInfo ui = new UserProfileInfo();

            if (UserId > 0)
            {
                ui = ForumUser.Profile;
            }
            else
            {
                ui.TopicCount   = 0;
                ui.ReplyCount   = 0;
                ui.RewardPoints = 0;
                ui.IsMod        = false;
                ui.TrustLevel   = -1;
            }
            bool UserIsTrusted = false;

            UserIsTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ui.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles), ForumInfo.AutoTrustLevel, ui.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();
            ReplyController rc        = new ReplyController();
            int             ReplyId   = -1;
            string          sUsername = string.Empty;

            if (Request.IsAuthenticated)
            {
                switch (MainSettings.UserNameDisplay.ToUpperInvariant())
                {
                case "USERNAME":
                    sUsername = UserInfo.Username.Trim(' ');
                    break;

                case "FULLNAME":
                    sUsername = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' ');
                    break;

                case "FIRSTNAME":
                    sUsername = UserInfo.FirstName.Trim(' ');
                    break;

                case "LASTNAME":
                    sUsername = UserInfo.LastName.Trim(' ');
                    break;

                case "DISPLAYNAME":
                    sUsername = UserInfo.DisplayName.Trim(' ');
                    break;

                default:
                    sUsername = UserInfo.DisplayName;
                    break;
                }
            }
            else
            {
                sUsername = Utilities.CleanString(PortalId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, ThemePath, false);
            }

            //Dim sSubject As String = Server.HtmlEncode(Request.Form("txtSubject"))
            //If (UseFilter) Then
            //    sSubject = Utilities.FilterWords(PortalId,  ForumModuleId, ThemePath, sSubject)
            //End If
            string sBody = string.Empty;

            if (AllowHTML)
            {
                AllowHTML = IsHtmlPermitted(ForumInfo.EditorPermittedUsers, IsTrusted, Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles));
            }
            sBody = Utilities.CleanString(PortalId, Request.Form["txtBody"], AllowHTML, EditorTypes.TEXTBOX, UseFilter, AllowScripts, ForumModuleId, 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   = Request.UserHostAddress;
            ReplyId = rc.Reply_Save(PortalId, ri);
            //Check if is subscribed
            string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);

            DataCache.CacheClearPrefix(cachekey);


            // Subscribe or unsubscribe if needed
            if (AllowSubscribe && UserId > 0)
            {
                var subscribe           = Request.Params["chkSubscribe"] == "1";
                var currentlySubscribed = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, UserId);

                if (subscribe != currentlySubscribed)
                {
                    // Will need to update this to support multiple subscrition types later
                    // Subscription_Update works as a toggle, so you only call it if you want to change the value.
                    var sc = new SubscriptionController();
                    sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, UserId, ForumUser.UserRoles);
                }
            }



            ControlUtils     ctlUtils = new ControlUtils();
            TopicsController tc       = new TopicsController();
            TopicInfo        ti       = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false);
            string           fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, -1, ReplyId, SocialGroupId);

            if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
            {
                fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId });
            }
            if (fullURL.EndsWith("/"))
            {
                fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId;
            }
            if (isApproved)
            {
                //Send Subscriptions

                try
                {
                    //Dim sURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                    Subscriptions.SendSubscriptions(PortalId, ForumModuleId, TabId, ForumId, TopicId, ReplyId, UserId);
                    try
                    {
                        Social amas = new Social();
                        amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                        //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then
                        //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                        //Else
                        //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody)
                        //End If
                    }
                    catch (Exception ex)
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                    }
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                }
                //Redirect to show post

                Response.Redirect(fullURL, false);
            }
            else if (isApproved == false)
            {
                List <Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId);
                NotificationType notificationType   = NotificationsController.Instance.GetNotificationType("AF-ForumModeration");
                string           subject            = Utilities.GetSharedResource("NotificationSubjectReply");
                subject = subject.Replace("[DisplayName]", UserInfo.DisplayName);
                subject = subject.Replace("[TopicSubject]", ti.Content.Subject);
                string body = Utilities.GetSharedResource("NotificationBodyReply");
                body = body.Replace("[Post]", sBody);
                string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId);

                Notification notification = new Notification();
                notification.NotificationTypeID = notificationType.NotificationTypeId;
                notification.Subject            = subject;
                notification.Body = body;
                notification.IncludeDismissAction = false;
                notification.SenderUserID         = UserInfo.UserID;
                notification.Context = notificationKey;

                NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);

                var @params = new List <string> {
                    ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId
                };
                if (SocialGroupId > 0)
                {
                    @params.Add("GroupId=" + SocialGroupId);
                }
                Response.Redirect(Utilities.NavigateUrl(TabId, "", @params.ToArray()), false);
            }
            else
            {
                //Dim fullURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                //If MainSettings.UseShortUrls Then
                //    fullURL = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId})
                //End If

                try
                {
                    Social amas = new Social();
                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId);
                    //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled Then
                    //    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read)
                    //Else
                    //    amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody)
                    //End If
                }
                catch (Exception ex)
                {
                    DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                }
                Response.Redirect(fullURL, false);
            }

            //End If
        }
Exemplo n.º 14
0
        private void btnSend_Click(object sender, System.EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                Email  objEmail = new Email();
                string Comments = null;
                Comments  = drpReasons.SelectedItem.Value + "<br>";
                Comments += Utilities.CleanString(PortalId, txtComments.Text, false, EditorTypes.TEXTBOX, false, false, ModuleId, string.Empty, false);
                int templateId          = 0;
                TemplateController tc   = new TemplateController();
                TemplateInfo       ti   = tc.Template_Get("ModAlert", PortalId, ModuleId);
                string             sUrl = NavigateUrl(Convert.ToInt32(Request.QueryString["TabId"]), "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.AlertSent });

                NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ContentAlert");
                TopicsController topicController  = new TopicsController();
                TopicInfo        topic            = topicController.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false);
                string           sBody            = string.Empty;
                string           authorName       = string.Empty;
                string           sSubject         = string.Empty;
                string           sTopicURL        = string.Empty;
                sTopicURL = topic.TopicUrl;
                if (ReplyId > 0 & TopicId != ReplyId)
                {
                    ReplyController rc    = new ReplyController();
                    ReplyInfo       reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId);
                    sBody      = reply.Content.Body;
                    sSubject   = reply.Content.Subject;
                    authorName = reply.Author.DisplayName;
                }
                else
                {
                    sBody      = topic.Content.Body;
                    sSubject   = topic.Content.Subject;
                    authorName = topic.Author.DisplayName;
                }
                ControlUtils ctlUtils = new ControlUtils();
                string       fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, sTopicURL, -1, -1, string.Empty, 1, ReplyId, SocialGroupId);
                string       subject  = Utilities.GetSharedResource("AlertSubject");
                subject = subject.Replace("[DisplayName]", authorName);
                subject = subject.Replace("[Subject]", sSubject);
                string body = Utilities.GetSharedResource("AlertBody");
                body = body.Replace("[Post]", sBody);
                body = body.Replace("[Comment]", Comments);
                body = body.Replace("[URL]", fullURL);
                body = body.Replace("[Reason]", drpReasons.SelectedItem.Value);
                List <Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId);


                string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId);

                Notification notification = new Notification();
                notification.NotificationTypeID = notificationType.NotificationTypeId;
                notification.Subject            = subject;
                notification.Body = body;
                notification.IncludeDismissAction = false;
                notification.SenderUserID         = UserInfo.UserID;
                notification.Context = notificationKey;


                NotificationsController.Instance.SendNotification(notification, PortalId, null, mods);



                Response.Redirect(sUrl);
            }
        }
Exemplo n.º 15
0
        public HttpResponseMessage RejectPost(ModerationDTO dto)
        {
            var notify = NotificationsController.Instance.GetNotification(dto.NotificationId);
            
            ParseNotificationContext(notify.Context);
            
            var fc = new ForumController();
            var fi = fc.Forums_Get(_forumId, -1, false, true);
            if (fi == null)
                return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Forum Not Found" });

            if (!(IsMod(_forumId)))
                return Request.CreateResponse(HttpStatusCode.Forbidden, new { Message = "User is not a moderator for this forum" });


            var mc = new ModController();
            mc.Mod_Reject(PortalSettings.PortalId, _moduleId, UserInfo.UserID, _forumId, _topicId, _replyId);
            
            int authorId;
            
            if (_replyId > 0)
            {
                var rc = new ReplyController();
                var reply = rc.Reply_Get(PortalSettings.PortalId, _moduleId, _topicId, _replyId);

                if (reply == null)
                    return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Reply Not Found" });

                authorId = reply.Content.AuthorId;
            }
            else
            {
                var tc = new TopicsController();
                var topic = tc.Topics_Get(PortalSettings.PortalId, _moduleId, _topicId);
                if (topic == null)
                    return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Topic Not Found" });

                authorId = topic.Content.AuthorId;
            }

            if (fi.ModRejectTemplateId > 0 && authorId > 0)
            {
                var uc = new Entities.Users.UserController();
                var ui = uc.GetUser(PortalSettings.PortalId, authorId);
                if (ui != null)
                {
                    var au = new Author
                                 {
                                     AuthorId = authorId,
                                     DisplayName = ui.DisplayName,
                                     Email = ui.Email,
                                     FirstName = ui.FirstName,
                                     LastName = ui.LastName,
                                     Username = ui.Username
                                 };
                    Email.SendEmail(fi.ModRejectTemplateId, PortalSettings.PortalId, _moduleId, _tabId, _forumId, _topicId, _replyId, string.Empty, au);
                }

            }

            NotificationsController.Instance.DeleteNotification(dto.NotificationId);
            return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" });
        }
Exemplo n.º 16
0
        private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e)
        {
            SettingsInfo ms = DataCache.MainSettings(ForumModuleId);
            Forum        fi = null;

            if (e.Parameters.Length > 0)
            {
                if (ForumId < 1)
                {
                    SetPermissions(Convert.ToInt32(e.Parameters[1]));
                    ForumController fc = new ForumController();
                    fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true);
                }
                else
                {
                    fi = ForumInfo;
                }
                switch (e.Parameters[0].ToLowerInvariant())
                {
                case "moddel":
                {
                    if (bModDelete)
                    {
                        int delAction  = ms.DeleteBehavior;
                        int tmpForumId = -1;
                        int tmpTopicId = -1;
                        int tmpReplyId = -1;
                        tmpForumId = Convert.ToInt32(e.Parameters[1]);
                        tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                        tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                        Author auth = null;
                        if (fi.ModDeleteTemplateId > 0)
                        {
                            try
                            {
                                //Email.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth);
                                Email.SendEmailToModerators(fi.ModDeleteTemplateId, PortalId, tmpForumId, tmpTopicId, tmpReplyId, ForumModuleId, ForumTabId, string.Empty);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                        {
                            TopicsController tc = new TopicsController();
                            TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId);
                            if (ti != null)
                            {
                                auth = ti.Author;
                            }
                            tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction);
                        }
                        else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                        {
                            ReplyController rc = new ReplyController();
                            ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                            if (ri != null)
                            {
                                auth = ri.Author;
                            }
                            rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction);
                        }
                    }
                    break;
                }

                case "modreject":
                {
                    int tmpForumId  = 0;
                    int tmpTopicId  = 0;
                    int tmpReplyId  = 0;
                    int tmpAuthorId = 0;
                    tmpForumId  = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId  = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId  = Convert.ToInt32(e.Parameters[3]);
                    tmpAuthorId = Convert.ToInt32(e.Parameters[4]);
                    ModController mc = new ModController();
                    mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId);
                    if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0)
                    {
                        DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController();
                        DotNetNuke.Entities.Users.UserInfo       ui = uc.GetUser(PortalId, tmpAuthorId);
                        if (ui != null)
                        {
                            Author au = new Author();
                            au.AuthorId    = tmpAuthorId;
                            au.DisplayName = ui.DisplayName;
                            au.Email       = ui.Email;
                            au.FirstName   = ui.FirstName;
                            au.LastName    = ui.LastName;
                            au.Username    = ui.Username;
                            Email.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au);
                        }
                    }

                    break;
                }

                case "modappr":
                {
                    int tmpForumId = -1;
                    int tmpTopicId = -1;
                    int tmpReplyId = -1;
                    tmpForumId = Convert.ToInt32(e.Parameters[1]);
                    tmpTopicId = Convert.ToInt32(e.Parameters[2]);
                    tmpReplyId = Convert.ToInt32(e.Parameters[3]);
                    string sSubject = string.Empty;
                    string sBody    = string.Empty;
                    if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0)
                    {
                        TopicsController tc = new TopicsController();
                        TopicInfo        ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                        if (ti != null)
                        {
                            sSubject      = ti.Content.Subject;
                            sBody         = ti.Content.Body;
                            ti.IsApproved = true;
                            tc.TopicSave(PortalId, ti);
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       sUrl     = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId)
                                if (sUrl.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled)
                                {
                                    amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }
                    else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0)
                    {
                        ReplyController rc = new ReplyController();
                        ReplyInfo       ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId);
                        if (ri != null)
                        {
                            ri.IsApproved = true;
                            sSubject      = ri.Content.Subject;
                            sBody         = ri.Content.Body;
                            rc.Reply_Save(PortalId, ri);
                            TopicsController tc = new TopicsController();
                            tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId);
                            TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false);
                            //TODO: Add Audit log for who approved topic
                            if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0)
                            {
                                Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author);
                            }

                            Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId);

                            try
                            {
                                ControlUtils ctlUtils = new ControlUtils();
                                string       fullURL  = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId);
                                if (fullURL.Contains("~/") || Request.QueryString["asg"] != null)
                                {
                                    fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
                                }
                                Social amas = new Social();
                                if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly)
                                {
                                    amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId);
                                }
                                else
                                {
                                    amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody);
                                }
                            }
                            catch (Exception ex)
                            {
                                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                            }
                        }
                    }


                    break;
                }
                }
                string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId);
                DataCache.CacheClearPrefix(cachekey);
            }
            BuildModList();
            litTopics.RenderControl(e.Output);
        }
Exemplo n.º 17
0
        public static string ParseEmailTemplate(string template, string templateName, int portalID, int moduleID, int tabID, int forumID, int topicId, int replyId, string comments, Entities.Users.UserInfo user, int userId, int timeZoneOffset)
        {
            var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            var ms = DataCache.MainSettings(moduleID);
            var sOut = template;

            // If we have a template name, load the template into sOut
            if (templateName != string.Empty)
            {
                if (templateName.Contains("_Subject_"))
                {
                    templateName = templateName.Replace("_Subject_" + moduleID, string.Empty);
                    var objTemplate = GetTemplateByName(templateName, moduleID, portalID);
                    sOut = objTemplate.Subject;
                }
                else
                {
                    var objTemplate = GetTemplateByName(templateName, moduleID, portalID);
                    sOut = objTemplate.TemplateHTML;
                }
            }

               // Load Subject and body from topic or reply

            var subject = string.Empty;
            var body = string.Empty;
            var dateCreated = Utilities.NullDate();
            var authorName = string.Empty;

            if (topicId > 0 && replyId > 0)
            {
                var ri = new ReplyController().Reply_Get(portalID, moduleID, topicId, replyId);
                if (ri != null)
                {
                    subject = ri.Content.Subject;
                    body = ri.Content.Body;
                    dateCreated = ri.Content.DateCreated;
                    authorName = ri.Content.AuthorName;
                }
            }
            else
            {
                var ti = new TopicsController().Topics_Get(portalID, moduleID, topicId);
                if (ti != null)
                {
                    subject = ti.Content.Subject;
                    body = ti.Content.Body;
                    dateCreated = ti.Content.DateCreated;
                    authorName = ti.Content.AuthorName;
                }
            }

            body = Utilities.ManageImagePath(body, Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)));

            // load the forum information
            var fi = new ForumController().Forums_Get(forumID, -1, false);

            // Load the user if needed
            if (user == null)
            {
                var objUsers = new Entities.Users.UserController();
                var objUser = objUsers.GetUser(portalID, userId);
                user = objUser;
            }

            // Load the user properties

            string sFirstName;
            string sLastName;
            string sDisplayName;
            string sUsername;

            if (user != null)
            {
                sFirstName = user.FirstName;
                sLastName = user.LastName;
                sDisplayName = user.DisplayName;
                sUsername = user.Username;
            }
            else
            {
                sFirstName = string.Empty;
                sLastName = string.Empty;
                sDisplayName = string.Empty;
                sUsername = string.Empty;
            }

            // Build the link

            string link;
            if (string.IsNullOrEmpty(fi.PrefixURL) || !Utilities.IsRewriteLoaded())
            {
                if (replyId == 0)
                    link = ms.UseShortUrls ? Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.TopicId + "=" + topicId })
                        : Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + topicId });
                else
                    link = ms.UseShortUrls ? Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.TopicId + "=" + topicId, ParamKeys.ContentJumpId + "=" + replyId })
                        : Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + topicId, ParamKeys.ContentJumpId + "=" + replyId });
            }
            else
            {
                var contentId = (replyId > 0) ? replyId : -1;
                link = new Data.Common().GetUrl(moduleID, -1, forumID, topicId, -1, contentId);
            }

            if (!(link.StartsWith("http")))
            {
                if (!link.StartsWith("/"))
                    link = "/" + link;

                if (link.IndexOf(HttpContext.Current.Request.Url.Host, StringComparison.Ordinal) == -1)
                    link = Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + link;
            }

            // Build the forum Url
            var forumURL = ms.UseShortUrls ? Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID })
                : Common.Globals.NavigateURL(tabID, string.Empty, new[] { ParamKeys.ForumId + "=" + forumID, ParamKeys.ViewType + "=" + Views.Topics });

            // Build Moderation url
            var modLink = Common.Globals.NavigateURL(tabID, string.Empty, new[] {ParamKeys.ViewType + "=modtopics", ParamKeys.ForumId + "=" + forumID});
            if (modLink.IndexOf(HttpContext.Current.Request.Url.Host, StringComparison.Ordinal) == -1)
                modLink = Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + modLink;

            var result = new StringBuilder(sOut);

            result.Replace("[DISPLAYNAME]", UserProfiles.GetDisplayName(moduleID, userId, authorName, sFirstName, sLastName, sDisplayName));
            result.Replace("[USERNAME]", sUsername);
            result.Replace("[USERID]", userId.ToString());
            result.Replace("[FORUMNAME]", fi.ForumName);
            result.Replace("[PORTALID]", portalID.ToString());
            result.Replace("[FIRSTNAME]", sFirstName);
            result.Replace("[LASTNAME]", sLastName);
            result.Replace("[FULLNAME]", sFirstName + " " + sLastName);
            result.Replace("[GROUPNAME]", fi.GroupName);
            result.Replace("[POSTDATE]", Utilities.GetDate(dateCreated, moduleID, timeZoneOffset));
            result.Replace("[COMMENTS]", comments);
            result.Replace("[PORTALNAME]", portalSettings.PortalName);
            result.Replace("[MODLINK]", "<a href=\"" + modLink + "\">" + modLink + "</a>");
            result.Replace("[LINK]", "<a href=\"" + link + "\">" + link + "</a>");
            result.Replace("[HYPERLINK]", "<a href=\"" + link + "\">" + link + "</a>");
            result.Replace("[LINKURL]", link);
            result.Replace("[FORUMURL]", forumURL);
            result.Replace("[FORUMLINK]", "<a href=\"" + forumURL + "\">" + forumURL + "</a>");

             // Introduced for Active Forum Email Connector plug-in Starts
            if (result.ToString().Contains("[EMAILCONNECTORITEMID]"))
            {
                // This Try with empty catch is introduced here because this code section is for Email Connector functionality only and this section should not
                // cause any issue to Active Forums functionality in case it does not run successfully.
                try
                {
                    long itemID = GetEmailInfo(portalID, moduleID, forumID, topicId, HttpContext.Current.Request.UserHostAddress);
                    result.Replace("[EMAILCONNECTORITEMID]", itemID.ToString());
                }
                catch
                { }
            }
            // Introduced for Active Forum Email Connector plug-in Ends

            if (user != null)
            {
                result.Replace("[SENDERUSERNAME]", user.UserID.ToString());
                result.Replace("[SENDERFIRSTNAME]", user.FirstName);
                result.Replace("[SENDERLASTNAME]", user.LastName);
                result.Replace("[SENDERDISPLAYNAME]", user.DisplayName);
            }
            else
            {
                result.Replace("[SENDERUSERNAME]", string.Empty);
                result.Replace("[SENDERFIRSTNAME]", string.Empty);
                result.Replace("[SENDERLASTNAME]", string.Empty);
                result.Replace("[SENDERDISPLAYNAME]", string.Empty);
            }

            result.Replace("[SUBJECT]", subject);
            result.Replace("[BODY]", body);
            result.Replace("[Body]", body);

            return result.ToString();
        }
Exemplo n.º 18
0
        public HttpResponseMessage RejectPost(ModerationDTO dto)
        {
            var notify = NotificationsController.Instance.GetNotification(dto.NotificationId);

            ParseNotificationContext(notify.Context);

            var fc = new ForumController();
            var fi = fc.Forums_Get(_forumId, -1, false, true);

            if (fi == null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Forum Not Found" }));
            }

            if (!(IsMod(_forumId)))
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden, new { Message = "User is not a moderator for this forum" }));
            }


            var mc = new ModController();

            mc.Mod_Reject(PortalSettings.PortalId, _moduleId, UserInfo.UserID, _forumId, _topicId, _replyId);

            int authorId;

            if (_replyId > 0)
            {
                var rc    = new ReplyController();
                var reply = rc.Reply_Get(PortalSettings.PortalId, _moduleId, _topicId, _replyId);

                if (reply == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Reply Not Found" }));
                }

                authorId = reply.Content.AuthorId;
            }
            else
            {
                var tc    = new TopicsController();
                var topic = tc.Topics_Get(PortalSettings.PortalId, _moduleId, _topicId);
                if (topic == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Topic Not Found" }));
                }

                authorId = topic.Content.AuthorId;
            }

            if (fi.ModRejectTemplateId > 0 && authorId > 0)
            {
                var uc = new Entities.Users.UserController();
                var ui = uc.GetUser(PortalSettings.PortalId, authorId);
                if (ui != null)
                {
                    var au = new Author
                    {
                        AuthorId    = authorId,
                        DisplayName = ui.DisplayName,
                        Email       = ui.Email,
                        FirstName   = ui.FirstName,
                        LastName    = ui.LastName,
                        Username    = ui.Username
                    };
                    var oEmail = new Email();
                    oEmail.SendEmail(fi.ModRejectTemplateId, PortalSettings.PortalId, _moduleId, _tabId, _forumId, _topicId, _replyId, string.Empty, au);
                }
            }

            NotificationsController.Instance.DeleteNotification(dto.NotificationId);
            return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" }));
        }