Exemplo n.º 1
0
        public AjaxResponse DoApprovedPost(int idPost, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idPost.ToString()
            };

            var post = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, idPost);

            if (post == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.ApprovePost, post))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            try
            {
                ForumDataProvider.ApprovePost(TenantProvider.CurrentTenantID, post.ID);
                resp.rs1 = "1";
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }
            return(resp);
        }
Exemplo n.º 2
0
        public static string AttachmentsList(Post post, Guid settingsID)
        {
            var           forumManager = ForumManager.GetForumManager(settingsID);
            StringBuilder sb           = new StringBuilder();

            if (post.Attachments.Count <= 0)
            {
                return("");
            }

            sb.Append("<div class=\"tintLight cornerAll borderBase forum_attachmentsBox\">");
            sb.Append("<div class='headerPanel'>" + Resources.ForumUCResource.AttachFiles + "</div>");
            foreach (Attachment attachment in post.Attachments)
            {
                sb.Append("<div id=\"forum_attach_" + attachment.ID + "\" class=\"borderBase  forum_attachItem clearFix\">");
                sb.Append("<table cellspacing='0' cellpadding='0' style='width:100%;'><tr>");
                sb.Append("<td style=\"width:350px;\">");
                sb.Append("<a target=\"_blank\" href=\"" + forumManager.GetAttachmentWebPath(attachment) + "\">" + HttpUtility.HtmlEncode(attachment.Name) + "</a>");
                sb.Append("</td>");

                if (forumManager.ValidateAccessSecurityAction(ForumAction.AttachmentDelete, post))
                {
                    sb.Append("<td style=\"width:100px;\">");
                    sb.Append("<a class=\"linkDescribe" + (SetupInfo.WorkMode == WorkMode.Promo ? " promoAction" : "") + "\" href=\"javascript:ForumManager.DeleteAttachment('" + attachment.ID + "','" + post.ID + "');\">" + Resources.ForumUCResource.DeleteButton + "</a>");
                    sb.Append("</td>");
                }
                sb.Append("<td style=\"text-align:right;\"><span class=\"textMediumDescribe\">" + ((float)attachment.Size / 1024f).ToString("####0.##") + " KB</span></td>");
                sb.Append("</tr></table>");
                sb.Append("</div>");
            }
            sb.Append("</div>");
            return(sb.ToString());
        }
Exemplo n.º 3
0
        public AjaxResponse DoDeletePost(int idPost, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idPost.ToString()
            };

            var post = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, idPost);

            if (post == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.PostDelete, post))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            try
            {
                var result = ForumDataProvider.RemovePost(TenantProvider.CurrentTenantID, post.ID);
                if (result == DeletePostResult.Successfully)
                {
                    resp.rs1 = "1";
                    resp.rs3 = Resources.ForumUCResource.SuccessfullyDeletePostMessage;
                    _forumManager.RemoveAttachments(post);

                    CommonControlsConfigurer.FCKUploadsRemoveForItem(_forumManager.Settings.FileStoreModuleID, idPost.ToString());
                }
                else if (result == DeletePostResult.ReferencesBlock)
                {
                    resp.rs1 = "0";
                    resp.rs3 = Resources.ForumUCResource.ExistsReferencesChildPosts;
                }
                else
                {
                    resp.rs1 = "0";
                    resp.rs3 = Resources.ForumUCResource.ErrorDeletePost;
                }
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }

            return(resp);
        }
Exemplo n.º 4
0
        public AjaxResponse DoDeleteTopic(int idTopic, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idTopic.ToString()
            };

            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic);

            if (topic == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.TopicDelete, topic))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            var topicName  = HttpUtility.HtmlEncode(topic.Title);
            var threadID   = topic.ThreadID;
            var threadName = topic.ThreadTitle;

            try
            {
                List <int> removedPostIDs;
                var        attachmantOffsetPhysicalPaths = ForumDataProvider.RemoveTopic(TenantProvider.CurrentTenantID, topic.ID, out removedPostIDs);

                resp.rs1 = "1";
                resp.rs3 = Resources.ForumUCResource.SuccessfullyDeleteTopicMessage;
                _forumManager.RemoveAttachments(attachmantOffsetPhysicalPaths.ToArray());

                removedPostIDs.ForEach(idPost => CommonControlsConfigurer.FCKUploadsRemoveForItem(_forumManager.Settings.FileStoreModuleID, idPost.ToString()));

                var settings = ForumManager.GetSettings(settingsID);
                if (settings != null && settings.ActivityPublisher != null)
                {
                    settings.ActivityPublisher.DeleteTopic(threadID, topicName, threadName);
                }
            }
            catch (Exception ex)
            {
                resp.rs1 = "0";
                resp.rs3 = ex.Message.HtmlEncode();
            }

            return(resp);
        }
Exemplo n.º 5
0
        public AjaxResponse DoStickyTopic(int idTopic, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse();

            resp.rs2 = idTopic.ToString();

            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic);

            if (topic == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.TopicSticky, topic))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            topic.Sticky = !topic.Sticky;
            try
            {
                ForumDataProvider.UpdateTopic(TenantProvider.CurrentTenantID, topic.ID, topic.Title, topic.Sticky, topic.Closed);

                resp.rs1 = "1";
                if (topic.Sticky)
                {
                    resp.rs3 = Resources.ForumUCResource.SuccessfullyStickyTopicMessage;
                }
                else
                {
                    resp.rs3 = Resources.ForumUCResource.SuccessfullyClearStickyTopicMessage;
                }

                var settings = ForumManager.GetSettings(settingsID);
                if (settings != null && settings.ActivityPublisher != null)
                {
                    settings.ActivityPublisher.TopicSticky(topic);
                }
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }
            return(resp);
        }
Exemplo n.º 6
0
        public bool VoteCallback(string pollID, List <string> selectedVariantIDs, string additionalParams, out string errorMessage)
        {
            errorMessage = "";
            var settingsID    = new Guid(additionalParams.Split(',')[0]);
            int idQuestion    = Convert.ToInt32(additionalParams.Split(',')[1]);
            var _forumManager = ForumManager.GetForumManager(settingsID);


            List <int> variantIDs = new List <int>(0);

            foreach (string id in selectedVariantIDs)
            {
                if (!String.IsNullOrEmpty(id))
                {
                    variantIDs.Add(Convert.ToInt32(id));
                }
            }

            var q = ForumDataProvider.GetPollByID(TenantProvider.CurrentTenantID, idQuestion);

            if (SetupInfo.WorkMode == WorkMode.Promo ||
                q == null ||
                !_forumManager.ValidateAccessSecurityAction(ForumAction.PollVote, q) ||
                ForumDataProvider.IsUserVote(TenantProvider.CurrentTenantID, idQuestion, SecurityContext.CurrentAccount.ID))
            {
                errorMessage = Resources.ForumUCResource.ErrorAccessDenied;
                return(false);
            }

            try
            {
                ForumDataProvider.PollVote(TenantProvider.CurrentTenantID, idQuestion, variantIDs);
            }
            catch (Exception e)
            {
                errorMessage = e.Message.HtmlEncode();
                return(false);
            }

            var settings = ForumManager.GetSettings(settingsID);

            if (settings != null && settings.ActivityPublisher != null)
            {
                settings.ActivityPublisher.Vote(q.Name, q.TopicID);
            }

            return(true);
        }
Exemplo n.º 7
0
        public AjaxResponse DoDeleteAttachment(int idAttachment, int idPost, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idAttachment.ToString()
            };

            var post = ForumDataProvider.GetPostByID(TenantProvider.CurrentTenantID, idPost);

            if (post == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.AttachmentDelete, post))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            try
            {
                var attachment = post.Attachments.Find(a => a.ID == idAttachment);
                if (attachment != null)
                {
                    ForumDataProvider.RemoveAttachment(TenantProvider.CurrentTenantID, attachment.ID);
                    _forumManager.RemoveAttachments(attachment.OffsetPhysicalPath);
                }

                resp.rs1 = "1";
                resp.rs3 = Resources.ForumUCResource.SuccessfullyDeleteAttachmentMessage;
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }

            return(resp);
        }
Exemplo n.º 8
0
        public AjaxResponse DoCloseTopic(int idTopic, Guid settingsID)
        {
            _forumManager = ForumManager.GetForumManager(settingsID);
            var resp = new AjaxResponse {
                rs2 = idTopic.ToString()
            };

            var topic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, idTopic);

            if (topic == null)
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            if (!_forumManager.ValidateAccessSecurityAction(ForumAction.TopicClose, topic))
            {
                resp.rs1 = "0";
                resp.rs3 = Resources.ForumUCResource.ErrorAccessDenied;
                return(resp);
            }

            topic.Closed = !topic.Closed;
            try
            {
                ForumDataProvider.UpdateTopic(TenantProvider.CurrentTenantID, topic.ID, topic.Title, topic.Sticky, topic.Closed);

                resp.rs1    = "1";
                resp.rs3    = topic.Closed ? Resources.ForumUCResource.SuccessfullyCloseTopicMessage : Resources.ForumUCResource.SuccessfullyOpenTopicMessage;
                resp.rs4    = topic.Closed ? Resources.ForumUCResource.OpenTopicButton : Resources.ForumUCResource.CloseTopicButton;
                resp.status = topic.Closed ? "close" : "open";
            }
            catch (Exception e)
            {
                resp.rs1 = "0";
                resp.rs3 = HttpUtility.HtmlEncode(e.Message);
            }

            return(resp);
        }
Exemplo n.º 9
0
        public static string AttachmentsList(Post post, Guid settingsID)
        {
            var forumManager = ForumManager.GetForumManager(settingsID);
            var sb           = new StringBuilder();

            if (post.Attachments.Count <= 0)
            {
                return("");
            }

            var closedTopic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, post.TopicID).Closed;

            sb.Append("<div class=\"cornerAll borderBase forum_attachmentsBox\">");
            sb.Append("<div class='headerPanel'>" + Resources.ForumUCResource.AttachFiles + "</div>");
            foreach (var attachment in post.Attachments)
            {
                sb.Append("<div id=\"forum_attach_" + attachment.ID + "\" class=\"borderBase  forum_attachItem clearFix\">");
                sb.Append("<table cellspacing='0' cellpadding='0' style='width:100%;'><tr>");
                sb.Append("<td>");
                sb.Append("<a class = 'link' target=\"_blank\" href=\"" + forumManager.GetAttachmentWebPath(attachment) + "\">" + HttpUtility.HtmlEncode(attachment.Name) + "</a>");
                sb.Append("</td>");

                sb.Append("<td style=\"text-align:right;width:100px;\"><span class=\"text-medium-describe\">" + ((float)attachment.Size / 1024f).ToString("####0.##") + " KB</span></td>");

                if (forumManager.ValidateAccessSecurityAction(ForumAction.AttachmentDelete, post) && !closedTopic)
                {
                    sb.Append("<td style=\"text-align:right;width:100px;\">");
                    sb.Append("<a class=\"link\" href=\"javascript:ForumManager.DeleteAttachment('" + attachment.ID + "','" + post.ID + "');\">" + Resources.ForumUCResource.DeleteButton + "</a>");
                    sb.Append("</td>");
                }

                sb.Append("</tr></table>");
                sb.Append("</div>");
            }
            sb.Append("</div>");
            return(sb.ToString());
        }