示例#1
0
 public IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status) {
     return _contentManager
         .Query<Comment, CommentRecord>()
         .Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
         .Where(ctx => ctx.Status == status)
         .List();
 }
        public ActionResult UpdateComment(string commentId, CommentStatus status = CommentStatus.Disable)
        {
            var pageCommentStore = CommentHelper.GetCommentStoreName();
            var id      = EPiServer.Data.Identity.NewIdentity(new Guid(commentId));
            var comment = CommentHelper.GetCommentById(pageCommentStore, id);

            if (comment != null)
            {
                if (status == CommentStatus.Enable || status == CommentStatus.Disable)
                {
                    comment.IsDeleted = status == CommentStatus.Disable ? true : false;
                    CommentHelper.UpdateComment(pageCommentStore, comment);
                }
                else
                {
                    CommentHelper.Delete(pageCommentStore, id);
                }
            }
            else
            {
                return(Json(new
                {
                    status = "error",
                    message = "Not found"
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                status = "ok",
                pageId = comment.PageId
            }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult ChangeStatus(int id, CommentStatus status)
        {
            Comment comment = commentService.GetById(id);

             comment.Status = status;
             comment.UpdatedBy = Context.CurrentUser;
             comment.UpdatedDate = DateTime.Now.ToUniversalTime();

             try
             {
            commentService.SaveComment(comment);

            // send the updated comment view
            return View("~/Areas/Admin/Views/AdminComment/Comment.ascx", comment);
             }
             catch (Exception ex)
             {
            log.Error("AdminCommentController.Update", ex);

            MessageModel message = new MessageModel
            {
               Text = GlobalResource("Message_GenericError"),
               Icon = MessageModel.MessageIcon.Alert,
            };

            return View("MessageUserControl", message);
             }
        }
        public void AddComment(Comment item, CommentStatus status)
        {
            switch (status)
            {
            case CommentStatus.Pending:
            {
                this.Pending.Add(item);
                break;
            }

            case CommentStatus.IsSpam:
            {
                this.Spam.Add(item);
                break;
            }

            case CommentStatus.IsApproved:
            {
                this.Approved.Add(item);
                break;
            }

            default:
            {
                throw new ArgumentException("Unable to add a comment for the specified status", "status");
            }
            }
        }
示例#5
0
        public int ModifyStatus(int id, CommentStatus status, out string error)
        {
            error = "";
            if (id <= 0)
            {
                error = "参数错误";
                return(0);
            }

            var model = dbContext.t_article_comments.FirstOrDefault(f => f.id == id);

            if (model == null)
            {
                error = "不存在评论信息";
                return(0);
            }

            try
            {
#warning 当评论被隐藏或者删除的时候,是否需要将对应文章的评论减少???思考ing...
                model.status = status;
                dbContext.SaveChanges();
                return(1);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(0);
            }
        }
        public void Delete(int commentId, CommentStatus status)
        {
            Comment itemToRemove;

            switch (status)
            {
            case CommentStatus.Pending:
            {
                itemToRemove = this.Pending.SingleOrDefault(x => x.Id == commentId);
                this.Pending.Remove(itemToRemove);
                break;
            }

            case CommentStatus.IsSpam:
            {
                itemToRemove = this.Spam.SingleOrDefault(x => x.Id == commentId);
                this.Spam.Remove(itemToRemove);
                break;
            }

            case CommentStatus.IsApproved:
            {
                itemToRemove = this.Approved.SingleOrDefault(x => x.Id == commentId);
                this.Approved.Remove(itemToRemove);
                break;
            }

            default:
            {
                throw new ArgumentException("Unable to find a comment with the specified id", "commentId");
            }
            }
        }
 /// <summary>
 /// Updates the comment status.
 /// </summary>
 /// <param name="commentStatus">The comment status.</param>
 /// <param name="ids">The ids.</param>
 /// <param name="userId">The user id.</param>
 public void UpdateCommentStatus(CommentStatus commentStatus, int[] ids, int userId)
 {
     foreach (int id in ids)
     {
         UpdateCommentStatus(commentStatus, id, userId);
     }
 }
示例#8
0
        public async Task <IActionResult> OnPostAsync(int id, CommentStatus status)
        {
            var comment = await Context.Comment.FirstOrDefaultAsync(
                m => m.CommentId == id);

            if (comment == null)
            {
                return(NotFound());
            }

            var commentOperation = (status == CommentStatus.Approved)
                                                       ? CommentOperations.Approve
                                                       : CommentOperations.Reject;

            var isAuthorized = await AuthorizationService.AuthorizeAsync(User, comment,
                                                                         commentOperation);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }
            comment.Status = status;
            Context.Comment.Update(comment);
            await Context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        /// <summary>
        /// Ges the commentt view.
        /// </summary>
        /// <param name="commentAction">The comment action.</param>
        /// <param name="getCommentsMethod">The get comments method.</param>
        /// <param name="cp">The cp.</param>
        /// <param name="view">The view.</param>
        /// <returns></returns>
        private ManageCommentsView GeCommentView(CommentAction commentAction, Func <List <Comment> > getCommentsMethod, string cp, string view)
        {
            string message;

            if (commentAction.CommentActionType != "-1")
            {
                if (commentAction.CommentId != null && commentAction.CommentId.Length > 0)
                {
                    CommentStatus commentStatus = commentAction.CommentActionType.ParseEnum <CommentStatus>();
                    _commentRepository.UpdateCommentStatus(commentStatus, commentAction.CommentId, Owner.Id);
                    message = string.Format("Selected comments have been changed to {0}.", commentAction.CommentActionType);
                }
                else
                {
                    message = "Please select one or more comments.";
                }
            }
            else
            {
                message = "Please select an action.";
            }

            ManageCommentsView commentView = GetManageCommentView(getCommentsMethod, cp, view);

            commentView.UIMessage = message;
            return(commentView);
        }
示例#10
0
 public async Task SetStatusAsync(List <int> commentIds, CommentStatus status)
 {
     await _repository.UpdateAsync(Q
                                   .Set(nameof(Comment.Status), status.GetValue())
                                   .WhereIn(nameof(Comment.Id), commentIds)
                                   );
 }
        public ActionResult LoadComment(int pageId = 0, CommentStatus status = CommentStatus.Enable)
        {
            var pageCommentStore = CommentHelper.GetCommentStoreName();
            var condition        = CreateCondition(pageId, status);
            var listComment      = CommentHelper.GetCommentByPageCondition(condition);

            return(PartialView("_ListComment", listComment));
        }
示例#12
0
        /// <summary>
        /// Sets the comment status.
        /// </summary>
        /// <param name="commentId">The comment id.</param>
        /// <param name="status">The status.</param>
        private void SetCommentStatus(int commentId, CommentStatus status)
        {
            var comment = Comments.Where(c => c.Id == commentId).SingleOrDefault();

            if (comment != null)
            {
                comment.Status = status;
            }
        }
 /// <summary>
 /// Updates the comment status.
 /// </summary>
 /// <param name="commentStatus">The comment status.</param>
 /// <param name="commentId">The comment id.</param>
 /// <param name="userId">The user id.</param>
 private void UpdateCommentStatus(CommentStatus commentStatus, int commentId, int userId)
 {
     database.NonQuery("Comment_UpdateStatus", new
     {
         CommentStatus = commentStatus.ToString(),
         commentId,
         userId
     }
                       );
 }
示例#14
0
 public bool Insert(CommentStatus commentstatus)
 {
     int autonumber = 0;
     CommentStatusDAC commentstatusComponent = new CommentStatusDAC();
     bool endedSuccessfuly = commentstatusComponent.InsertNewCommentStatus( ref autonumber,  commentstatus.CommentStatusName);
     if(endedSuccessfuly)
     {
         commentstatus.CommentStatusId = autonumber;
     }
     return endedSuccessfuly;
 }
示例#15
0
        /// <summary>
        /// Comments the colors.
        /// </summary>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        private static IEnumerable <Tuple <CommentStatus, string> > CommentColors(CommentStatus status)
        {
            const string format = "<label>{0}</label>";

            return(new List <Tuple <CommentStatus, string> >
            {
                new Tuple <CommentStatus, string>(CommentStatus.Approved, string.Format(format, status)),
                new Tuple <CommentStatus, string>(CommentStatus.Pending, string.Format(format, status)),
                new Tuple <CommentStatus, string>(CommentStatus.Spam, string.Format(format, status)),
            });
        }
        public async Task <IActionResult> UpdateCommentStatus(int commentId, CommentStatus commentStatus)
        {
            var result = await _commentRepository.UpdateCommentStatus(commentId, commentStatus);

            if (result)
            {
                return(Ok());
            }

            return(BadRequest());
        }
示例#17
0
        private void setStatus(Comment comment, CommentStatus status)
        {
            if (!_userContext.IsAuthenticated)
            {
                throw new UserNotLoggedInException("Approving comment requires User to be logged in.");
            }

            comment.CheckReferenceIsNull(nameof(comment));
            comment.Status         = status;
            comment.ModifierUserId = _userContext.UserId;
            comment.ModifyDate     = _dateService.UtcNow();
        }
示例#18
0
        public static string GetStatus(CommentStatus status)
        {
            switch (status)
            {
            case CommentStatus.Approved: return(GetText(@"Approved"));

            case CommentStatus.Denied: return(GetText(@"Denied"));

            case CommentStatus.Wait:
            default: return(GetText(@"Wait"));
            }
        }
        protected override string BuildPostContentString()
        {
            string result = string.Format(_content,
                                          BlogId,
                                          Credentials.UserName.HtmlEncode(),
                                          Credentials.Password.HtmlEncode(),
                                          PostId,
                                          CommentStatus.ToString(),
                                          Offset,
                                          Number);

            return(result);
        }
示例#20
0
 public int GetCommentCountForStatus(CommentStatus commentStatus)
 {
     try
     {
         return(this.Context.SitePageComment
                .Where(x => x.CommentStatus == commentStatus)
                .Count());
     }
     catch (Exception ex)
     {
         Log.Fatal(ex);
         throw new Exception("DB error", ex.InnerException);
     }
 }
        private IDictionary <string, object> CreateCondition(int pageId, CommentStatus status)
        {
            var condition = new Dictionary <string, object>
            {
                { "PageId", pageId }
            };

            if (status == CommentStatus.Enable || status == CommentStatus.Disable)
            {
                condition.Add("IsDeleted", status == CommentStatus.Disable);
            }

            return(condition);
        }
        /// <summary>
        /// used to generate the url for recent site comments
        /// </summary>
        /// <param name="site">the site url. insert without http:// prefix</param>
        /// <param name="type">the comments type to return</param>
        /// <param name="status">the comments status to return</param>
        /// <param name="number">The number of comments to return. Limit: 100. Default: 20.</param>
        /// /// <returns>the generated url for fetching recent site comments</returns>
        private static string siteCommentsUrl(string site, CommentType type, CommentStatus status, int?number = null, int?offset = null)
        {
            if (!number.HasValue)
            {
                number = 100;
            }

            if (!offset.HasValue)
            {
                offset = 0;
            }

            return(string.Format("https://public-api.wordpress.com/rest/v1/sites/{0}/comments/?number={1}&offset={2}&type={3}&status={4}", site, number, offset, type, status));
        }
示例#23
0
 public List <SitePageComment> GetCommentsForPage(int sitePageId, CommentStatus commentStatus)
 {
     try
     {
         return(this.Context.SitePageComment
                .Where(x => x.SitePageId == sitePageId && x.CommentStatus == commentStatus)
                .ToList());
     }
     catch (Exception ex)
     {
         Log.Fatal(ex);
         throw new Exception("DB error", ex.InnerException);
     }
 }
示例#24
0
        public static VoteState AsVoteState(this CommentStatus status)
        {
            switch (status)
            {
            case CommentStatus.VotedUp:
                return(VoteState.Up);

            case CommentStatus.VotedDown:
                return(VoteState.Down);

            default:
                return(VoteState.Default);
            }
        }
示例#25
0
        /// <summary>
        /// Edit comment.
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public bool EditComment(string comment_id, CommentStatus status, DateTime date_created_gmt, string content, string author, string author_url, string author_email)
        {
            var xmlRpcComment = new XmlRpcComment
            {
                author       = author,
                author_email = author_email,
                author_url   = author_url,
                dateCreated  = date_created_gmt,
                content      = content,
                status       = EnumsHelper.GetCommentStatusName(status)
            };

            return(_wrapper.EditComment(this.BlogID, Username, Password, xmlRpcComment));
        }
示例#26
0
 /// <summary>
 /// Gets the name for the given comment status.
 /// </summary>
 /// <param name="status">The status</param>
 /// <returns>The name</returns>
 public static string GetStatusName(CommentStatus status)
 {
     if (status == CommentStatus.New)
     {
         return(Piranha.Resources.Comment.New);
     }
     else if (status == CommentStatus.Approved)
     {
         return(Piranha.Resources.Comment.Approved);
     }
     else
     {
         return(Piranha.Resources.Comment.NotApproved);
     }
 }
示例#27
0
 public CommentStatus GetByID(int _commentStatusId)
 {
     CommentStatusDAC _commentStatusComponent = new CommentStatusDAC();
      IDataReader reader = _commentStatusComponent.GetByIDCommentStatus(_commentStatusId);
      CommentStatus _commentStatus = null;
      while(reader.Read())
      {
          _commentStatus = new CommentStatus();
          if(reader["CommentStatusId"] != DBNull.Value)
              _commentStatus.CommentStatusId = Convert.ToInt32(reader["CommentStatusId"]);
          if(reader["CommentStatusName"] != DBNull.Value)
              _commentStatus.CommentStatusName = Convert.ToString(reader["CommentStatusName"]);
      _commentStatus.NewRecord = false;             }             reader.Close();
      return _commentStatus;
 }
        public void AddComment(CommentDto comment, int itemId, CommentStatus status)
        {
            Item item = this.Session.Load<Item>(itemId);

            if (item == null)
            {
                throw new DexterItemNotFoundException(itemId);
            }

            ItemComments itemComments = this.Session.Load<ItemComments>(itemId)
                                        ?? new ItemComments();

            Comment domainComment = comment.MapTo<Comment>();

            itemComments.AddComment(domainComment, status);

            this.Session.Store(itemComments);
        }
        public void AddComment(CommentDto item, int itemId)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item", "The comment item must contain a valid instance.");
            }

            if (itemId < 1)
            {
                throw new ArgumentException("The item id must be greater than 0", "itemId");
            }

            BlogConfigurationDto configuration = this.configurationService.GetConfiguration();

            CommentStatus status = configuration.CommentSettings.EnablePremoderation ? CommentStatus.Pending : CommentStatus.IsApproved;

            this.commentDataService.AddComment(item, itemId, status);
        }
示例#30
0
        public void AddComment(CommentDto comment, int itemId, CommentStatus status)
        {
            Item item = this.Session.Load <Item>(itemId);

            if (item == null)
            {
                throw new DexterItemNotFoundException(itemId);
            }

            ItemComments itemComments = this.Session.Load <ItemComments>(itemId)
                                        ?? new ItemComments();

            Comment domainComment = comment.MapTo <Comment>();

            itemComments.AddComment(domainComment, status);

            this.Session.Store(itemComments);
        }
示例#31
0
 public List<CommentStatus> GetAll()
 {
     CommentStatusDAC _commentStatusComponent = new CommentStatusDAC();
      IDataReader reader =  _commentStatusComponent.GetAllCommentStatus().CreateDataReader();
      List<CommentStatus> _commentStatusList = new List<CommentStatus>();
      while(reader.Read())
      {
      if(_commentStatusList == null)
          _commentStatusList = new List<CommentStatus>();
          CommentStatus _commentStatus = new CommentStatus();
          if(reader["CommentStatusId"] != DBNull.Value)
              _commentStatus.CommentStatusId = Convert.ToInt32(reader["CommentStatusId"]);
          if(reader["CommentStatusName"] != DBNull.Value)
              _commentStatus.CommentStatusName = Convert.ToString(reader["CommentStatusName"]);
      _commentStatus.NewRecord = false;
      _commentStatusList.Add(_commentStatus);
      }             reader.Close();
      return _commentStatusList;
 }
示例#32
0
        public async Task <bool> UpdateCommentStatus(int commentId, CommentStatus commentStatus)
        {
            using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    var commentToUpdate = await _unitOfWork.Repository <Comment>().Query().Where(cm => cm.Id == commentId).SingleOrDefaultAsync();

                    commentToUpdate.CommentStatus = commentStatus;
                    await _unitOfWork.Repository <Comment>().UpdateAsync(commentToUpdate);

                    transaction.Complete();
                    return(true);
                }
                catch (Exception)
                {
                    _unitOfWork.Rollback();
                    return(false);
                }
            }
        }
示例#33
0
        public static List <SelectListItem> ToSelectListItems(this CommentStatus status) =>
        new List <SelectListItem>
        {
            new SelectListItem(
                AppTextDisplay.CommentStatusDeleted,
                ((int)CommentStatus.Deleted).ToString(),
                status == CommentStatus.Deleted),

            new SelectListItem(
                AppTextDisplay.CommentStatusWaiting,
                ((int)CommentStatus.Waiting).ToString(),
                status == CommentStatus.Waiting),

            new SelectListItem(
                AppTextDisplay.CommentStatusApproved,
                ((int)CommentStatus.Approved).ToString(),
                status == CommentStatus.Approved),

            new SelectListItem(
                AppTextDisplay.CommentStatusRejected,
                ((int)CommentStatus.Rejected).ToString(),
                status == CommentStatus.Rejected),

            new SelectListItem(
                AppTextDisplay.CommentStatusSpam,
                ((int)CommentStatus.Spam).ToString(),
                status == CommentStatus.Spam),

            new SelectListItem(
                AppTextDisplay.CommentStatusViewed,
                ((int)CommentStatus.Viewed).ToString(),
                status == CommentStatus.Viewed),

            new SelectListItem(
                AppTextDisplay.CommentStatusRead,
                ((int)CommentStatus.Read).ToString(),
                status == CommentStatus.Read)
        };
示例#34
0
        public Paginator<Comment> FindPagedCommentsBySiteAndCommentStatus(Site site, CommentStatus status, int pageSize)
        {
            if (site == null)
            throw new ArgumentNullException("site");

             DetachedCriteria criteria = DetachedCriteria.For<Comment>()
                                       .AddOrder(new Order("CreatedDate", false))
                                       .CreateAlias("ContentItem", "ci")
                                       .Add(Restrictions.Eq("ci.IsLogicallyDeleted", false))
                                       .Add(Restrictions.Eq("ci.Site", site))
                                       .Add(Restrictions.Eq("Status", status));

             return Repository<Comment>.GetPaginator(criteria, pageSize);
        }
示例#35
0
 public IContentQuery<CommentPart, CommentPartRecord> GetCommentsForCommentedContent(int id, CommentStatus status) {
     return GetCommentsForCommentedContent(id)
                .Where(c => c.Status == status);
 }
示例#36
0
 public IContentQuery<CommentPart, CommentPartRecord> GetComments(CommentStatus status) {
     return GetComments()
                .Where(c => c.Status == status);
 }
 /// <summary>
 /// Renders the name of the comment.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <returns></returns>
 private static string RenderCommentName(CommentStatus status)
 {
     return (from c in CommentColors(status)
            where c.Item1 == status
            select c.Item2).FirstOrDefault();
 }
示例#38
0
        /// <summary>
        /// Formats the post
        /// </summary>
        /// <param name="inputText"></param>
        /// <param name="hidden"></param>
        /// <param name="cleanHTMLTags"></param>
        /// <param name="applySkin"></param>
        /// <returns></returns>
        static public string FormatPost(string inputText, CommentStatus.Hidden hidden, bool cleanHTMLTags, bool applySkin)
        {
            if (hidden == CommentStatus.Hidden.Hidden_AwaitingPreModeration || hidden == CommentStatus.Hidden.Hidden_AwaitingReferral) // 3 means premoderated! - hidden!
            {
                return "This post has been hidden.";
            }
            else if (hidden != CommentStatus.Hidden.NotHidden)
            {
                return "This post has been removed.";
            }

            //strip invalid xml chars
            inputText = StringUtils.StripInvalidXmlChars(inputText);

            //converts all tags to &gt; or &lt;
            inputText = StringUtils.EscapeAllXml(inputText);


            // Perform Smiley Translations
            inputText = SmileyTranslator.TranslateText(inputText);

            // Quote translator.
            inputText = QuoteTranslator.TranslateText(inputText);

            if (cleanHTMLTags)
            {
                //Remove bad html tags and events
                inputText = HtmlUtils.CleanHtmlTags(inputText, true, true);
            }

            // Expand Links 
            //Note this must happen after removal because <LINK>s will be removed in the CleanHtmlTags call 
            inputText = LinkTranslator.TranslateTextLinks(inputText);

            //convert BRs to CRs
            inputText = HtmlUtils.ReplaceCRsWithBRs(inputText);

            if (applySkin)
            {
                //For h2g2 we want the A numbers and U numbers converted
                inputText = LinkTranslator.TranslateH2G2Text(inputText);

                string apiGuideSkin = ConfigurationManager.AppSettings["guideMLXSLTSkinPath"];
                string startH2G2Post = "<H2G2POST>";
                string endH2G2Post = "</H2G2POST>";

                int errorCount = 0;
                XmlDocument doc = new XmlDocument();
                doc.PreserveWhitespace = true;

                inputText = Entities.ReplaceEntitiesWithNumericValues(inputText);

                inputText = HtmlUtils.EscapeNonEscapedAmpersands(inputText);

                // reassign string and element after transformation     
                string textAsGuideML = startH2G2Post + inputText + endH2G2Post;

                try
                {
                    doc.LoadXml(textAsGuideML);
                }
                catch (XmlException e)
                {
                    //If something has gone wrong log stuff
                    DnaDiagnostics.Default.WriteExceptionToLog(e);

                    inputText = "There has been an issue with rendering this post, please contact the editors.";
                    return inputText;
                }
                
                string transformedContent = XSLTransformer.TransformUsingXslt(apiGuideSkin, doc, ref errorCount);

                // strip out the xml header and namespaces
                transformedContent = transformedContent.Replace(@"<?xml version=""1.0"" encoding=""utf-16""?>", "");
                transformedContent = transformedContent.Replace(@"xmlns=""http://www.w3.org/1999/xhtml""", "");

                if (errorCount != 0)
                {
                    DnaDiagnostics.Default.WriteToLog("FailedTransform", transformedContent);
                    throw new ApiException("GuideML Transform Failed.", ErrorType.GuideMLTransformationFailed);
                }
                inputText = transformedContent;
            }

            return inputText;
        }
        /// <summary>
        /// Comments the colors.
        /// </summary>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        private static IEnumerable<Tuple<CommentStatus, string>> CommentColors(CommentStatus status)
        {
            const string format = "<label>{0}</label>";

            return new List<Tuple<CommentStatus, string>>
                       {
                           new Tuple<CommentStatus, string>(CommentStatus.Approved, string.Format(format,  status)),
                           new Tuple<CommentStatus, string>(CommentStatus.Pending, string.Format(format, status)),
                           new Tuple<CommentStatus, string>(CommentStatus.Spam, string.Format(format, status)),
                       };
        }
示例#40
0
 public void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status) {
     CommentPart commentPart = GetComment(id);
     commentPart.Record.Author = name;
     commentPart.Record.Email = email;
     commentPart.Record.SiteName = siteName;
     commentPart.Record.CommentText = commentText;
     commentPart.Record.Status = status;
 }
 /// <summary>
 /// Comments the type of frefthe count by.
 /// </summary>
 /// <param name="commentStatuses">The comment statuses.</param>
 /// <param name="commentType">Type of the comment.</param>
 /// <returns></returns>
 public int CommentCountByType(List<StatusCount<CommentStatus>> commentStatuses, CommentStatus commentType)
 {
     return (from statusCount in commentStatuses where statusCount.Status == commentType select statusCount.Count).FirstOrDefault();
 }
示例#42
0
 public static string GetCommentStatusName(CommentStatus status)
 {
     return Enum.GetName(typeof(CommentStatus), status);
 }
示例#43
0
 public IContentQuery<CommentPart, CommentPartRecord> GetComments(CommentStatus status) {
     return _orchardServices.ContentManager
                .Query<CommentPart, CommentPartRecord>()
                .Where(c => c.Status == status);
 }
 /// <summary>
 /// Retrieves the comment by status and user id.
 /// </summary>
 /// <param name="userId">The user id.</param>
 /// <param name="commentstatus">The commentstatus.</param>
 /// <returns></returns>
 public List<Comment> RetrieveCommentByStatusAndUserId(int userId, CommentStatus commentstatus)
 {
     return database.PopulateCollection("Comment_RetrieveCommentByStatusAndUserId", new{userId, commentstatus = commentstatus.ToString()}, database.AutoPopulate<Comment>);
 }
示例#45
0
        /// <summary>
        /// Formats the comment string
        /// </summary>
        /// <param name="text"></param>
        /// <param name="style"></param>
        /// <param name="hidden"></param>
        /// <returns></returns>
        public static string FormatComment(string text, PostStyle.Style style, CommentStatus.Hidden hidden, bool isEditor)
        {
            if (hidden == CommentStatus.Hidden.Hidden_AwaitingPreModeration ||
                hidden == CommentStatus.Hidden.Hidden_AwaitingReferral)
            {
                return "This post is awaiting moderation.";
            }
            if (hidden != CommentStatus.Hidden.NotHidden)
            {
                return "This post has been removed.";
            }
            string _text = text;
            switch (style)
            {
                case Api.PostStyle.Style.plaintext:
                    if (!isEditor)
                    {
                        _text = HtmlUtils.RemoveAllHtmlTags(_text);
                    }
                    _text = HtmlUtils.ReplaceCRsWithBRs(_text);
                    _text = LinkTranslator.TranslateExLinksToHtml(_text);
                    break;

                case Api.PostStyle.Style.richtext:
                    if (!isEditor)
                    {
                        _text = HtmlUtils.CleanHtmlTags(_text, false, false);
                    }
                    _text = HtmlUtils.ReplaceCRsWithBRs(_text);
                    //<dodgey>
                    var temp = "<RICHPOST>" + _text + "</RICHPOST>";
                    temp = HtmlUtils.TryParseToValidHtml(temp);
                    _text = temp.Replace("<RICHPOST>", "").Replace("</RICHPOST>", "");
                    //</dodgey>

                    _text = LinkTranslator.TranslateExLinksToHtml(_text);
                    break;

                case Api.PostStyle.Style.rawtext:
                    //do nothing
                    break;

                case Api.PostStyle.Style.tweet:
                    if (!isEditor)
                    {
                        _text = HtmlUtils.RemoveAllHtmlTags(_text);
                    }
                    _text = LinkTranslator.TranslateExLinksToHtml(_text);
                    _text = LinkTranslator.TranslateTwitterTags(_text);
                    break;

                case Api.PostStyle.Style.unknown:
                    //do nothing
                    break;
            }
            return _text;
        }
示例#46
0
 public Comment()
 {
     this.topicField = new CommentTopic();
     this.statusField = CommentStatus.Unknown;
 }
 /// <summary>
 /// Updates the comment status.
 /// </summary>
 /// <param name="commentStatus">The comment status.</param>
 /// <param name="commentId">The comment id.</param>
 /// <param name="userId">The user id.</param>
 private void UpdateCommentStatus(CommentStatus commentStatus, int commentId, int userId)
 {
     database.NonQuery("Comment_UpdateStatus", new
                                                    {
                                                        CommentStatus = commentStatus.ToString(),
                                                        commentId,
                                                        userId
                                                    }
         );
 }
示例#48
0
        /// <summary>
        /// Edit comment.
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public bool EditComment(string comment_id, CommentStatus status, DateTime date_created_gmt, string content, string author, string author_url, string author_email)
        {
            var xmlRpcComment = new XmlRpcComment
            {

                author = author,
                author_email = author_email,
                author_url = author_url,
                dateCreated = date_created_gmt,
                content = content,
                status = EnumsHelper.GetCommentStatusName(status)
            };

            return _wrapper.EditComment(this.BlogID, Username, Password, xmlRpcComment);
        }
示例#49
0
 public CommentBCF()
 {
     this.statusField = CommentStatus.Unknown;
 }
 /// <summary>
 /// Updates the comment status.
 /// </summary>
 /// <param name="commentStatus">The comment status.</param>
 /// <param name="ids">The ids.</param>
 /// <param name="userId">The user id.</param>
 public void UpdateCommentStatus(CommentStatus commentStatus, int[] ids, int userId)
 {
     foreach (int id in ids)
     {
         UpdateCommentStatus(commentStatus, id, userId);
     }
 }
示例#51
0
 /// <summary>
 /// Gets the name for the given comment status.
 /// </summary>
 /// <param name="status">The status</param>
 /// <returns>The name</returns>
 public static string GetStatusName(CommentStatus status)
 {
     if (status == CommentStatus.New)
         return Paladino.Resources.Comment.New;
     else if (status == CommentStatus.Approved)
         return Paladino.Resources.Comment.Approved;
     else return Paladino.Resources.Comment.NotApproved;
 }
示例#52
0
 public IEnumerable<Comment> GetComments(CommentStatus status) {
     return _contentManager
         .Query<Comment, CommentRecord>()
         .Where(c => c.Status == status)
         .List();
 }
示例#53
0
        /// <summary>
        /// Formats a subject based on hidden flags etc
        /// </summary>
        /// <param name="inputText"></param>
        /// <param name="hidden"></param>
        /// <returns></returns>
        static public string FormatSubject(string inputText, CommentStatus.Hidden hidden)
        {
            if (hidden == CommentStatus.Hidden.Hidden_AwaitingPreModeration || hidden == CommentStatus.Hidden.Hidden_AwaitingReferral) // 3 means premoderated! - hidden!
            {
                return "Hidden";
            }
            if (hidden != CommentStatus.Hidden.NotHidden)
            {
                return "Removed";
            }

            return HtmlUtils.HtmlDecode(HtmlUtils.RemoveAllHtmlTags(inputText));
            

        }
示例#54
0
 public IContentQuery<CommentPart, CommentPartRecord> GetCommentsForCommentedContent(int id, CommentStatus status) {
     return _orchardServices.ContentManager
                .Query<CommentPart, CommentPartRecord>()
                .Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
                .Where(ctx => ctx.Status == status);
 }
        /// <summary>
        /// Sets the comment status.
        /// </summary>
        /// <param name="commentId">The comment id.</param>
        /// <param name="status">The status.</param>
        private void SetCommentStatus(int commentId, CommentStatus status)
        {
            var comment = Comments.Where(c => c.Id == commentId).SingleOrDefault();

            if (comment != null)
            {
                comment.Status = status;
            }
        }